emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

Fix nested dynamic library loading via RPATH

Open hoodmane opened this issue 2 months ago • 2 comments

There is a bug with dynamic library loading. Suppose liba.so is on LD_LIBRARY_PATH and it has an RPATH of $ORIGIN/other_dir and loads libb.so from other_dir. Then suppose libb.so has an RPATH of $ORIGIN and wants to load libc.so also from other_dir.

Before this PR this doesn't work. The problem is that flags.rpath.parentLibPath is set to libb.so and we replace $ORIGIN with PATH.dirname(parentLibName) which is .. So unless other_dir is on the LD_LIBRARY_PATH or is the current working directory, loading will fail.

The fix: if findLibraryFS() returns a value that is not undefined, replace libName with the returned value.

hoodmane avatar Oct 31 '25 22:10 hoodmane

I think this is the same thing I wanted to fix in https://github.com/emscripten-core/emscripten/pull/24234 and which is already in Pyodide patches

ryanking13 avatar Nov 01 '25 00:11 ryanking13

Apologies for now getting around to reviewing #24234 for such a long time.

@hoodmane does that look like it solving the same issue? Do you have a preference which approach is better?

sbc100 avatar Nov 01 '25 02:11 sbc100

Does this also fix https://github.com/emscripten-core/emscripten/issues/25814?

sbc100 avatar Nov 17 '25 23:11 sbc100

I think we can probably close this now that #24234 has landed. If #24234 doesn't solve your issue feel free to re-open

sbc100 avatar Nov 21 '25 20:11 sbc100