borkdude / plsci

PostgreSQL procedural language handler for Clojure via SCI
Eclipse Public License 1.0
49 stars 3 forks source link

Second invocation of `cargo pgx run pg13` after building libplsci fails with "Symbol not found: _eval_string" #4

Open borkdude opened 3 years ago

borkdude commented 3 years ago

The first time after building libplsci I can successfully run cargo pgx run:

installing extension
     Copying control file to `/Users/borkdude/.pgx/13.0/pgx-install/share/postgresql/extension/plsci.control`
     Copying shared library to `/Users/borkdude/.pgx/13.0/pgx-install/lib/postgresql/plsci.so`
     Writing extension schema to `/Users/borkdude/.pgx/13.0/pgx-install/share/postgresql/extension/plsci--1.0.sql`
    Finished installing plsci
    Starting Postgres v13 on port 28813
    Re-using existing database plsci
psql (13.0)
Type "help" for help.

plsci=# select * from plsci('(+ 1 2 3)');
 plsci
-------
 6
(1 row)

plsci=# ^D\q

However, the second time, I get:

$ cargo pgx run pg13
    Stopping Postgres v13
building extension with features `pg13`
"cargo" "build" "--features" "pg13" "--no-default-features"
   Compiling plsci v0.0.0 (/Users/borkdude/Dropbox/dev/clojure/plsci)
    Finished dev [unoptimized + debuginfo] target(s) in 2.83s

installing extension
     Copying control file to `/Users/borkdude/.pgx/13.0/pgx-install/share/postgresql/extension/plsci.control`
     Copying shared library to `/Users/borkdude/.pgx/13.0/pgx-install/lib/postgresql/plsci.so`
     Writing extension schema to `/Users/borkdude/.pgx/13.0/pgx-install/share/postgresql/extension/plsci--1.0.sql`
    Finished installing plsci
    Starting Postgres v13 on port 28813
    Re-using existing database plsci
psql (13.0)
Type "help" for help.

plsci=# select * from plsci('(+ 1 2 3)');
ERROR:  could not load library "/Users/borkdude/.pgx/13.0/pgx-install/lib/postgresql/plsci.so": dlopen(/Users/borkdude/.pgx/13.0/pgx-install/lib/postgresql/plsci.so, 10): Symbol not found: _eval_string
  Referenced from: /Users/borkdude/.pgx/13.0/pgx-install/lib/postgresql/plsci.so
  Expected in: flat namespace
 in /Users/borkdude/.pgx/13.0/pgx-install/lib/postgresql/plsci.so
plsci=#
borkdude commented 3 years ago

@eeeebbbbrrrr any ideas maybe? it seems related to a build cache in target. Only when I remove target, then it works again, but not the second time.

borkdude commented 3 years ago

This is what I'm seeing with otool the first and second time:

$ otool -hV /Users/borkdude/.pgx/13.0/pgx-install/lib/postgresql/plsci.so
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
MH_MAGIC_64  X86_64        ALL  0x00       DYLIB    15       2136   NOUNDEFS DYLDLINK TWOLEVEL NO_REEXPORTED_DYLIBS MH_HAS_TLV_DESCRIPTORS
$ otool -hV /Users/borkdude/.pgx/13.0/pgx-install/lib/postgresql/plsci.so
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
MH_MAGIC_64  X86_64        ALL  0x00       DYLIB    15       2152   NOUNDEFS DYLDLINK TWOLEVEL NO_REEXPORTED_DYLIBS MH_HAS_TLV_DESCRIPTORS

It seems that sizeofcmds has grown (I'm not sure what this means).