-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Support rpath
to locate shared libraries?
#22126
Comments
Seems like a reasonable request yes. It would make sense to add this to the existing |
HI @sbc100, what would be the steps I should take to move this forward? I'm not sure exactly what I need to do to add a subsection, but I'm guessing I would need to do the following.
|
Yup those steps look correct to me! |
Thanks. Let me prepare a PR in the WebAssembly/tool-conventions repository then. |
@sbc100 can you merge llvm/llvm-project#126080? |
Done |
Proposal
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 currentdylink.0
section to have such value?)Background
ELF binaries (or shared libraries) has
rpath
orruntime path
section that is used to locate its dependent shared libraries. In addition toLD_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.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,
numpy
Python 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.
loadDynamicLibrary
JS function instead of usingdlopen
.loadDynamicLibrary
, we passfs
parameter with customfindObject
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)
findObject
function, 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
The text was updated successfully, but these errors were encountered: