Repository navigation
Cannot compile node #30180
Description
Activity
- addedbuildIssues and PRs related to Node.js builds or CI infrastructure.Issues and PRs related to Node.js builds or CI infrastructure.confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.i18n-apiIssues and PRs related to Node.js internationalization support.Issues and PRs related to Node.js internationalization support.
on Oct 30, 2019 Relevant bits of the stack trace:
#0 0x0000000000000000 in ?? () #1 0x0000000000538d09 in std::condition_variable::notify_all() () #2 0x000000000043e67b in icu_64::umtx_initImplPostInit (uio=...) at ../deps/icu-small/source/common/umutex.cpp:151It looks like
initCondition()calls out to thestd::condition_variableconstructor but actually returns an useless object in the end.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
call 0isn’t quite right.¹ This only happens when linkingout/Debug/gen-regexp-special-casewith-static.¹ Edit: Looks like that should have been a call to
pthread_cond_broadcast, according to the relocation data in my static libstdc++.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:
Reacted by Jehiah CzebotarYes, 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
--enable-staticjust means that it (also?) builds a static library from Node.js for embedding, in addition to the binary, but I think I might be wrong.- added a commit that references this issue
on Oct 31, 2019 Issues persist on v17.3.1. Unfortunately, the provided patch didn't solve it for me. Not present on v11.15.0.
Reacted by Dmitry Babushkin and Mike WilleIssue still exists in v18.14.0 -- I used the patch and it worked.
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.
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-staticAnd it has been successfully compiled.
Reacted by Yanghang ZhengThank you so much! My question seems to be done.
Cannot compile node 13.0.1 with flags
./configure --fully-static --with-intl=full-icuinside docker image for nodeGetting this output
Steps to reproduce:
docker run -it node bash//inside docker shell
git clone https://github.com/nodejs/node.gitcd nodegit checkout v13.0.1./configure --fully-static --with-intl=full-icumake -j8Also not working with flags
./configure --fully-static --enable-static --with-intl=full-icuwith the same errorBut it compiles without errors with version 11.1.0 with flags
./configure --fully-static --with-intl=full-icu --download=all