You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduce a new rpath.0 custom section into Emscripten WASM module that stores runtime path for the module and can be used to locate shared libraries per-module (or extend the current dylink.0 section to have such value?)
Background
ELF binaries (or shared libraries) has rpath or runtime path section that is used to locate its dependent shared libraries. In addition to LD_LIBRARY_PATH which is a system-wide path for searching shared libraries, rpath can be used per-module path for searching its dependencies.
For now, -rpath flag is ignored when it is passed to emcc.
it would be nice if this is also available in Emscripten.
Alternatives / Current workaround
Currently, Pyodide performs rpath-like behavior in the following ways.
We directly use loadDynamicLibrary JS function instead of using dlopen.
When calling loadDynamicLibrary, we pass fs parameter with custom findObject function.
1.a. This function was removed in latest emscripten, but we are using a patched-version of it (Move dlopen file operations into native code. NFC #19310)
In out custom findObject function, we search shared libraries by looking at some pre-defined search path per module, which behaves like rpath.
Proposal
Introduce a new
rpath.0custom section into Emscripten WASM module that stores runtime path for the module and can be used to locate shared libraries per-module (or extend the currentdylink.0section to have such value?)Background
ELF binaries (or shared libraries) has
rpathorruntime pathsection that is used to locate its dependent shared libraries. In addition toLD_LIBRARY_PATHwhich is a system-wide path for searching shared libraries,rpathcan be used per-module path for searching its dependencies.For now,
-rpathflag is ignored when it is passed to emcc.Reason for the proposal
Pyodide loads python packages with shared libraries in runtime. In order to ensure that each Python package is self-contained, Python utilizes rpaths to locate dependent dynamic libraries within a single package.
For instance,
numpyPython package for linux has following runtime path:and it is used to locate shared libraries in
numpy.libs, which is not inLD_LIBRARY_PATH.it would be nice if this is also available in Emscripten.
Alternatives / Current workaround
Currently, Pyodide performs rpath-like behavior in the following ways.
loadDynamicLibraryJS function instead of usingdlopen.loadDynamicLibrary, we passfsparameter with customfindObjectfunction.1.a. This function was removed in latest emscripten, but we are using a patched-version of it (Move dlopen file operations into native code. NFC #19310)
findObjectfunction, we search shared libraries by looking at some pre-defined search path per module, which behaves like rpath.References
allowUndefined: true#22052 (comment)Above all, thank you for maintaining such an amazing project! We (Pyodide) benefit a lot from Emscripten :)
cc: @hoodmane @agriyakhetarpal for visibility