-
Notifications
You must be signed in to change notification settings - Fork 1
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
Native Node.js Addons do not work #2
Comments
Yep, the To build without the Note, though, that native modules will need to be compiled with Musl to be loadable. Which module are you trying to use? Here's an example using sqlite3:
|
Hmmm. Thats strange. I copied line by line from your example.
When looking at
For some unknow reason I can only execute binaries generated by a musl-toolchain if I build them completely static... :-( If your example works for you the reason might be somewhere else. I'm using Manjaro Linux. I'm interested, because I would like to build my own node addons. Everythings works fine with a glibc |
Hmm, odd; just as a sanity check did you I ran those steps verbatim in a clean (node) container; and also on my normal dev machine :-s (Which is Arch, so shouldn't be that different?) Personally, I actually use the static linking with native modules -> rebuilding them all with musl, and then doing some code replacement to use
It's dynamically linked against musl, but the musl libc isn't in the /lib/... location (hence it fails); it shouldn't be dynamically linked :-s (this makes me think a |
I think we found the reason of the problem:
I used It worked in your example, because you used a clean node container, probably completely musl based. So I will investigate if there is a way to force a library search path. I'm aware of Basically I like your idea of static link my modules to node, but I have to check how much fiddling it is to mix cmake and gyp when building node. Yes, I did Thanks for your help! |
Well, this is not the problem. But I'm getting closer:
This part concerns me: |
Yeah, cool; are you happy to bundle the linker with your app? You can move the linker path using patchelf, eg And you're right; I did have a stray I'm going to have a look into that... (Just for reference, the linker that is built into the package is available at a path akin to .../node_modules/node-musl/x64-linux-musl/x86_64-linux-musl/lib/libc.so if you wanted to use it, hence you could |
Thanks a lot! Relative pathes like: Now there is just the remaining problem: When node is build it creates these binaries like I probably need a whole musl based container to make this work without manual intervention and in this case node-musl does not help me that much. If I find a simple solution using node-musl I let you know. Edit: Well, I only have to build node if I switch to a new node release, not for every build of my AddOn! So I'll try now if I can complete the build process of node with Edit2: No I still can not finish the build process. It re-creates |
I did something akin to the following, if it helps any?
Which is using (I haven't tried all those steps in sequence, so there might be gremlins, but it was along those lines.) |
Yes! Finally, there is a partly dnyamically linked node build with the musl toolchain. Your script contained no gremlins and worked on the first paste. Thanks, again! |
Trying to compile a "Native Node.js Addon" does not work. I get the error:
Error: Dynamic loading not supported
I assume it should work, because in the example there is this line:
# eval "$("$(npm bin)/musl-exports")" # sets CC CXX and LD in the shell
which is only needed when compiling native AddOns.
Am I doing something wrong?
I tried compiling node without
--fully-static
to solve this problem, but then I get an error when compiling node:> make -C out BUILDTYPE=Release V=1 touch 34387d1d5929e5a61662c04af32f67604a0a34b9.intermediate LD_LIBRARY_PATH=/home/XXX/Node-Musl/src/out/Release/lib.host:/home/XXX/Node-Musl/src/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../deps/v8/gypfiles; mkdir -p /home/XXX/Node-Musl/src/out/Release/obj/gen/torque-generated; "/home/XXX/Node-Musl/src/out/Release/torque" ../src/builtins/base.tq ../src/builtins/array.tq ../src/builtins/array-copywithin.tq ../src/builtins/array-foreach.tq ../src/builtins/array-reverse.tq ../src/builtins/typed-array.tq ../src/builtins/data-view.tq ../third_party/v8/builtins/array-sort.tq -o "/home/XXX/Node-Musl/src/out/Release/obj/gen/torque-generated" /bin/sh: /home/XXX/Node-Musl/src/out/Release/torque: No such file or directory make[1]: *** [deps/v8/gypfiles/v8_torque.host.mk:17: 34387d1d5929e5a61662c04af32f67604a0a34b9.intermediate] Error 127 rm 34387d1d5929e5a61662c04af32f67604a0a34b9.intermediate
The text was updated successfully, but these errors were encountered: