-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Cannot compile node #30180
Comments
Relevant bits of the stack trace:
It looks like |
Machine code of the stdlib method in question: 0000000000538d00 <_ZNSt18condition_variable10notify_allEv>:
538d00: 48 83 ec 08 sub $0x8,%rsp
538d04: e8 f7 72 ac ff callq 0 <_nl_current_LC_CTYPE>
538d09: 85 c0 test %eax,%eax
538d0b: 75 05 jne 538d12 <_ZNSt18condition_variable10notify_allEv+0x12>
538d0d: 48 83 c4 08 add $0x8,%rsp
538d11: c3 retq
538d12: 89 c7 mov %eax,%edi
538d14: e8 a7 e9 f9 ff callq 4d76c0 <_ZSt20__throw_system_errori>
538d19: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) Obviously ¹ Edit: Looks like that should have been a call to |
Tiny repro: $ cat test.cpp
#include <condition_variable>
int main () {
std::condition_variable a; a.notify_all();
}
$ g++ -g -pthread -static -Wall -o test test.cpp && ./test
Segmentation fault (core dumped) Googling a bit gives https://stackoverflow.com/questions/35116327/when-g-static-link-pthread-cause-segmentation-fault-why, which does not quite seem to answer why this is crashing but does provide a helpful solution. @bgnx Can you confirm that this solves your issue? diff --git a/configure.py b/configure.py
index 8790b3c13fcc..5f7fdb55aed9 100755
--- a/configure.py
+++ b/configure.py
@@ -1266,7 +1266,7 @@ def configure_static(o):
return
if options.fully_static:
- o['libraries'] += ['-static']
+ o['libraries'] += ['-static', '-Wl,--whole-archive', '-lpthread', '-Wl,--no-whole-archive']
elif options.partly_static:
o['libraries'] += ['-static-libgcc', '-static-libstdc++']
if options.enable_asan: |
Yes, now it compiles without errors. Thanks! (By the way I don't understand what has caused this error - I've tested different node versions and node compiles without this error up to 12.8.1 release and starting from 12.9.0 release static compilation breaks with this error) And little off-topic question - do I need to add --enable-static flag if I already added --fully-static flag ? I just need statically compiled node to run inside docker "FROM scratch" image and seems like in both cases (with and without --enable-static flag) I am getting executable /out/Release/node file |
@bgnx I think |
This resolves a crash during the build of Node.js when built with `./configure --fully-static`. Fixes: nodejs#30180
Issues persist on v17.3.1. Unfortunately, the provided patch didn't solve it for me. Not present on v11.15.0. |
Issue still exists in v18.14.0 -- I used the patch and it worked. |
May I ask which patch you used? I have met the same problem. |
@YanghangZheng-GDUT I use sed -i "s/'-static'/'-static', '-Wl,--whole-archive', '-lpthread', '-Wl,--no-whole-archive'/" configure.py
./configure --fully-static --enable-static And it has been successfully compiled. |
Thank you so much! My question seems to be done. |
Cannot compile node 13.0.1 with flags
./configure --fully-static --with-intl=full-icu
inside docker image for nodeGetting this output
Steps to reproduce:
docker run -it node bash
//inside docker shell
git clone https://github.com/nodejs/node.git
cd node
git checkout v13.0.1
./configure --fully-static --with-intl=full-icu
make -j8
Also not working with flags
./configure --fully-static --enable-static --with-intl=full-icu
with the same errorBut it compiles without errors with version 11.1.0 with flags
./configure --fully-static --with-intl=full-icu --download=all
The text was updated successfully, but these errors were encountered: