Open nicolasnoble opened 6 years ago
@nicolasnoble Thanks for reporting!
Could this issue explain the problem: https://github.com/android-ndk/ndk/issues/201 or is it something else? Do you have any idea how to improve things (I don't know much about node.js internals myself)?
It's very likely the case, yes. NodeJS is expecting its dependencies to be transitively available to its addons. If LD_PRELOAD is a way to put the dependents in the global space, we could wrap the Node binary to make sure that all of its dependencies are pre-loaded.
I'll give it a try.
Yes, it's making it load using a wrapper script that LD_PRELOAD all the node libraries. I don't know yet if the module works properly, but that's outside the scope of this bug :-)
I'd recommend that the termux package ships with a similar script by renaming the binary to something else, and having the wrapper be the name "node", this way the node binary on Termux will behave the same as the official distribution.
Also, the module seems to be working flawlessly, so only the wrapper script around the node binary is needed to properly fix this issue.
This issue/PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
¯\(ツ)/¯
The problem(?) is that there is more than one way to fix this.
I would rather do something like:
CXXFLAGS="-I$TERMUX_PREFIX/include" LDFLAGS="-L$TERMUX_PREFIX/lib -lz" npm install grpc
Of course the LD_PRELOAD
hack will also work, as suggested above. And to patchelf
the binaries is yet another.
Is this still reproducible?
I'm not sure if this one is even fixable, but the normal NodeJS runtime exposes libraries' API such as zlib or openssl to native addons. See https://nodejs.org/api/addons.html#addons_linking_to_node_js_own_dependencies
With termux's nodejs package, it seems this isn't working properly. See attached screenshot, when trying to load grpc (
npm install grpc
)