Skip to content

Commit cf1132e

Browse files
committed
Strip rpath from built extension modules
pg_config --ldflags emits -Wl,-rpath,<libdir>, which gets passed to the linker through PG_LDFLAGS and ends up baked into the shared modules as a RUNPATH. Drop those entries before they reach the linker so the modules rely on the standard library search path instead of a hardcoded one.
1 parent bc908c3 commit cf1132e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ get_pg_config(PG_CFLAGS --cflags)
386386
get_pg_config(PG_CFLAGS_SL --cflags_sl)
387387
get_pg_config(PG_CPPFLAGS --cppflags)
388388
get_pg_config(PG_LDFLAGS --ldflags)
389+
390+
# Strip any -Wl,-rpath,... entries that pg_config may have emitted so the
391+
# resulting shared modules do not bake in a hardcoded library search path.
392+
string(REGEX REPLACE "-Wl,-rpath,[^ ]+" "" PG_LDFLAGS "${PG_LDFLAGS}")
389393
get_pg_config(PG_LIBS --libs)
390394

391395
separate_arguments(PG_CFLAGS)

0 commit comments

Comments
 (0)