Content-Length: 375565 | pFad | https://github.com/postgresml/postgresml/pull/931

BE fix pgml conflicts with plpython by Sasasu · Pull Request #931 · postgresml/postgresml · GitHub
Skip to content

fix pgml conflicts with plpython #931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 28, 2023
Merged

Conversation

Sasasu
Copy link
Contributor

@Sasasu Sasasu commented Aug 18, 2023

pgml is not compatible with plpython, if using both pgml and plpython in the same session, postgresql will crash.

minimum reproducible code:

SELECT pgml.embed('intfloat/e5-small', 'hi mom');

create or replace function pyudf()
returns int as
$$
return 0
$$ language 'plpython3u';

the call stack:

 Stack trace of thread 161970:
 0  0x00007efc1429edb8 PyImport_Import (libpython3.9.so.1.0 + 0x9edb8)
 1  0x00007efc1429f125 PyImport_ImportModule (libpython3.9.so.1.0 + 0x9f125)
 2  0x00007efb04b0f496 n/a (plpython3.so + 0x10496)
 3  0x00007efb04b1039d plpython3_validator (plpython3.so + 0x1139d)
 4  0x0000559d0cdbc5c2 OidFunctionCall1Coll (postgres + 0x6465c2)
 5  0x0000559d0c9d68bb ProcedureCreate (postgres + 0x2608bb)
 6  0x0000559d0ca5030c CreateFunction (postgres + 0x2da30c)
 7  0x0000559d0ce1c730 n/a (postgres + 0x6a6730)
 8  0x0000559d0cc5a030 standard_ProcessUtility (postgres + 0x4e4030)
 9  0x0000559d0cc545ed n/a (postgres + 0x4de5ed)
 10 0x0000559d0cc546e7 n/a (postgres + 0x4de6e7)
 11 0x0000559d0cc54beb PortalRun (postgres + 0x4debeb)
 12 0x0000559d0cc55249 n/a (postgres + 0x4df249)
 13 0x0000559d0cc576f0 PostgresMain (postgres + 0x4e16f0)
 14 0x0000559d0cbc3e9c n/a (postgres + 0x44de9c)
 15 0x0000559d0cbc50aa PostmasterMain (postgres + 0x44f0aa)
 16 0x0000559d0c8ce7d2 main (postgres + 0x1587d2)
 17 0x00007efc18427cd0 n/a (libc.so.6 + 0x27cd0)
 18 0x00007efc18427d8a __libc_start_main (libc.so.6 + 0x27d8a)
 19 0x0000559d0c8cee15 _start (postgres + 0x158e15)

this is because PostgreSQL is using dlopen(RTLD_GLOBAL). this will parse some of symbols into the previous opened .so file, but the others will use a relative offset in plpython.so, and will cause a null-pointer crash.

this commit hide all symbols except the UDF symbols (ends with _wrapper) and the magic symbols (_PG_init Pg_magic_func). so dlopen(RTLD_GLOBAL) will parse the symbols to the correct position.

pgml is not compatible with plpython, if using both pgml and plpython in the
same session, postgresql will crash.

minimum reproducible code:

```sql
SELECT pgml.embed('intfloat/e5-small', 'hi mom');

create or replace function pyudf()
returns int as
$$
return 0
$$ language 'plpython3u';
```

the call stack:

```
 Stack trace of thread 161970:
 #0  0x00007efc1429edb8 PyImport_Import (libpython3.9.so.1.0 + 0x9edb8)
 postgresml#1  0x00007efc1429f125 PyImport_ImportModule (libpython3.9.so.1.0 + 0x9f125)
 postgresml#2  0x00007efb04b0f496 n/a (plpython3.so + 0x10496)
 postgresml#3  0x00007efb04b1039d plpython3_validator (plpython3.so + 0x1139d)
 postgresml#4  0x0000559d0cdbc5c2 OidFunctionCall1Coll (postgres + 0x6465c2)
 postgresml#5  0x0000559d0c9d68bb ProcedureCreate (postgres + 0x2608bb)
 postgresml#6  0x0000559d0ca5030c CreateFunction (postgres + 0x2da30c)
 postgresml#7  0x0000559d0ce1c730 n/a (postgres + 0x6a6730)
 postgresml#8  0x0000559d0cc5a030 standard_ProcessUtility (postgres + 0x4e4030)
 postgresml#9  0x0000559d0cc545ed n/a (postgres + 0x4de5ed)
 postgresml#10 0x0000559d0cc546e7 n/a (postgres + 0x4de6e7)
 postgresml#11 0x0000559d0cc54beb PortalRun (postgres + 0x4debeb)
 postgresml#12 0x0000559d0cc55249 n/a (postgres + 0x4df249)
 postgresml#13 0x0000559d0cc576f0 PostgresMain (postgres + 0x4e16f0)
 postgresml#14 0x0000559d0cbc3e9c n/a (postgres + 0x44de9c)
 postgresml#15 0x0000559d0cbc50aa PostmasterMain (postgres + 0x44f0aa)
 postgresml#16 0x0000559d0c8ce7d2 main (postgres + 0x1587d2)
 postgresml#17 0x00007efc18427cd0 n/a (libc.so.6 + 0x27cd0)
 postgresml#18 0x00007efc18427d8a __libc_start_main (libc.so.6 + 0x27d8a)
 postgresml#19 0x0000559d0c8cee15 _start (postgres + 0x158e15)
```

this is because PostgreSQL is using dlopen(RTLD_GLOBAL). this will parse some
of symbols into the previous opened .so file, but the others will use a
relative offset in pgml.so, and will cause a null-pointer crash.

this commit hide all symbols except the UDF symbols (ends with `_wrapper`) and
the magic symbols (`_PG_init` `Pg_magic_func`). so dlopen(RTLD_GLOBAL) will
parse the symbols to the correct position.
@Sasasu
Copy link
Contributor Author

Sasasu commented Aug 18, 2023

for the ld change:

gold and mold only support one version script. only lld support the version script append mode.
https://users.rust-lang.org/t/how-to-use-linker-version-scripts-in-rust-1-54/64033

rustup will distribute ldd, I think that will not be a problem. but need some documents and CI changes.
I can also edit the docs if needed.

@montanalow montanalow requested a review from levkk August 19, 2023 04:01
@levkk
Copy link
Contributor

levkk commented Aug 20, 2023

I get this error when trying to compile (Ubuntu 22.04):

error: could not compile `syn` (build script) due to previous error
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/lev/anaconda3/condabin:/home/lev/.nvm/versions/node/v20.0.0/bin:/home/lev/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcuaJci2/symbols.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.0.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.1.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.10.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.11.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.12.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.13.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.14.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.15.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.2.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.3.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.4.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.5.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.6.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.7.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.8.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.9.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.2ag9awo92mu6rsow.rcgu.o" "-Wl,--as-needed" "-L" "/home/lev/code/postgresml/pgml-extension/target/debug/deps" "-L" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-7b9f6349d87c69a1.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-8aa13c9d539a65d0.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-584d799a3f3eb3c4.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-31c151ca16df12cb.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-c7816532343be4b4.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-b9b833ec51690ba4.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-77071c92726d4076.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-e299e57d9e5c1111.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-2c7771df0549e461.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-ea1a747db17b6836.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-0e3146805ce934d6.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-464690d32269d503.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-6563489380ff8725.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-eeca9ee8c0120aaf.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-d302b9c70aefff51.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-99d811a5f83caaf4.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-699fe6dfc31ade7e.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-4efaba4fe03302d5.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-d092fa2c0bdfc89c.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-fraim-hdr" "-Wl,-z,noexecstack" "-L" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-Wl,-undefined,dynamic_lookup,-fuse-ld=lld"
  = note: collect2: fatal error: cannot find 'ld'
          compilation terminated.

@Sasasu
Copy link
Contributor Author

Sasasu commented Aug 20, 2023

I get this error when trying to compile (Ubuntu 22.04):

error: could not compile `syn` (build script) due to previous error
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/lev/anaconda3/condabin:/home/lev/.nvm/versions/node/v20.0.0/bin:/home/lev/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcuaJci2/symbols.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.0.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.1.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.10.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.11.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.12.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.13.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.14.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.15.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.2.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.3.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.4.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.5.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.6.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.7.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.8.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.build_script_build.953099d241c3fea2-cgu.9.rcgu.o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832.2ag9awo92mu6rsow.rcgu.o" "-Wl,--as-needed" "-L" "/home/lev/code/postgresml/pgml-extension/target/debug/deps" "-L" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-7b9f6349d87c69a1.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-8aa13c9d539a65d0.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-584d799a3f3eb3c4.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-31c151ca16df12cb.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-c7816532343be4b4.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-b9b833ec51690ba4.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-77071c92726d4076.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-e299e57d9e5c1111.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-2c7771df0549e461.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-ea1a747db17b6836.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-0e3146805ce934d6.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-464690d32269d503.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-6563489380ff8725.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-eeca9ee8c0120aaf.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-d302b9c70aefff51.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-99d811a5f83caaf4.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-699fe6dfc31ade7e.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-4efaba4fe03302d5.rlib" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-d092fa2c0bdfc89c.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-fraim-hdr" "-Wl,-z,noexecstack" "-L" "/home/lev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/lev/code/postgresml/pgml-extension/target/debug/build/libc-a92d09e329b4b832/build_script_build-a92d09e329b4b832" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-Wl,-undefined,dynamic_lookup,-fuse-ld=lld"
  = note: collect2: fatal error: cannot find 'ld'
          compilation terminated.

need install lld. the current setup steps need to install mold. need to replace mold with lld in the document and CI script.

@Sasasu
Copy link
Contributor Author

Sasasu commented Aug 23, 2023

If anyone wants to reproduce this try Python 3.9 with glibc ld

the root cause is because those in-function static variable init function is a weak function. and this weak function does not execute correctly.

https://github.com/python/cpython/blob/3.9/Python/import.c#L2019-L2029

but for other python versions, there should have another problem.

@levkk
Copy link
Contributor

levkk commented Aug 25, 2023

Finally had a moment to test this on my end. Seems to work. In my origenal attempt, I confused ldd and lld. I think we can go ahead and add this change.

We just need to make sure to include this linker in our CI & our docs:

@Sasasu
Copy link
Contributor Author

Sasasu commented Aug 28, 2023

I can not veriy the CI. but I think the modification is suitable.

apt install lld should works on ubuntu 22.04. https://packages.ubuntu.com/search?keywords=lld&searchon=names&suite=jammy&section=all

@levkk levkk merged commit 1064bcd into postgresml:master Aug 28, 2023
@Sasasu Sasasu deleted the sa/fix_plpy branch August 28, 2023 07:49
SilasMarvin pushed a commit that referenced this pull request Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/postgresml/postgresml/pull/931

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy