Skip to content

Need a way to use shared libraries with RTLD_GLOBAL flag #2312

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

Closed
stevengj opened this issue Feb 15, 2013 · 1 comment · Fixed by #2380
Closed

Need a way to use shared libraries with RTLD_GLOBAL flag #2312

stevengj opened this issue Feb 15, 2013 · 1 comment · Fixed by #2380

Comments

@stevengj
Copy link
Member

In order to ccall a function in a shared library foo that itself dynamically links a shared library bar which calls functions in foo, one needs to dlopen the library foo with the RTLD_GLOBAL flag. Currently, Julia does not do this, so the only workaround seems to be to patch dlload.c:jl_uv_dlopen and recompile Julia.

I'm running into this in writing a PyCall module to call Python code from Julia. This involves using ccall to call functions in libpython, but libpython itself dynamically loads other libraries when it imports Python modules, and those Python modules need to call Python routines themselves. So, importing such modules fails unless libpython is loaded with RTLD_GLOBAL.

@stevengj
Copy link
Member Author

I just noticed that ccall allow you to use a library opened with dlopen, combined with dlsym to look up the symbol. So all that is needed here is:

  • Implement dlopen_global(s::String) or similar to call dlopen with the RTLD_GLOBAL flag (or its equivalent).

This way you don't need to use RTLD_GLOBAL on all libraries (where it might not be appropriate).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants