-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Ability to set dlopen flags used to load .node modules #436
Comments
The dlopen call in node.cc uses RTLD_LAZY: https://github.com/ry/node/blob/master/src/node.cc#L1257 Would it be possible to expose the ability to customize those flags? I've found I need to be able to pass RTLD_NOW in a specific circumstance (see explanation below). If this is acceptable I will then start work on a patch to node.cc. The background on needing to pass RTLD_NOW is this: I am writing a node addon in C++, wrapping Mapnik (http://mapnik.org) and mapnik has, itself, a plugin system that uses dlopen. Calls inside of Mapnik to dlopen on linux fail because the symbols of the mapnik library are not visible within the node process that mapnik.node has been loaded into. My sense is that this fails because RTLD_LAZY does not make the mapnik symbols available to mapnik's plugins. If I change RTLD_LAZY to RTLD_NOW in node.cc#L1257 the loading of mapnik plugins immediately starts working. My workaround right now is suboptimal, basically I've found I can "preload" the necessary mapnik symbols by manually calling dlopen with the RTLD flag from the node module: Instead I would love to do something more like this in index.js:
This would be similar to python: http://docs.python.org/library/sys.html#sys.setdlopenflags Any feedback greatly appreciated! |
I ran into the same problem you describe. I made the change you suggested, though instead of putting the dlopen flags in sys I put them in process. I also added the relevant constants from dlfcn.h to node_constants.h. E.g., If you have a chance test it with your mapnik extension and see if it works ok for you. |
I've encountered the need to call |
I'm going to close this. If someone still has problems loading shared objects from modules, please open a libuv issue. |
No description provided.
The text was updated successfully, but these errors were encountered: