-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
nodejs: fix build with clang 16 #253009
nodejs: fix build with clang 16 #253009
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good to me, only one nit. Still trying to run test builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebasing this on the LLVM 16 bump I'm getting a permission error about env
not being permitted as an interpreter?
Last lines of the build log:
LD_LIBRARY_PATH=/private/tmp/nix-build-nodejs-18.17.1.drv-0/node-v18.17.1/out/
Release/lib.host:/private/tmp/nix-build-nodejs-18.17.1.drv-0/node-v18.17.1/out/R
elease/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../.; mkdir -p /p
rivate/tmp/nix-build-nodejs-18.17.1.drv-0/node-v18.17.1/out/Release/obj/gen/src;
python tools/inspector_protocol/convert_protocol_to_json.py src/inspector/node_
protocol.pdl "/private/tmp/nix-build-nodejs-18.17.1.drv-0/node-v18.17.1/out/Rele
ase/obj/gen/src/node_protocol.json"
rm -f /private/tmp/nix-build-nodejs-18.17.1.drv-0/node-v18.17.1/out/Release/li
bbase64.a && ./gyp-mac-tool filter-libtool libtool -static -o /private/tmp/nix-
build-nodejs-18.17.1.drv-0/node-v18.17.1/out/Release/libbase64.a /private/tmp/ni
x-build-nodejs-18.17.1.drv-0/node-v18.17.1/out/Release/obj.target/base64/deps/ba
se64/base64/lib/arch/generic/codec.o /private/tmp/nix-build-nodejs-18.17.1.drv-0
/node-v18.17.1/out/Release/obj.target/base64/deps/base64/base64/lib/tables/table
s.o /private/tmp/nix-build-nodejs-18.17.1.drv-0/node-v18.17.1/out/Release/obj.ta
rget/base64/deps/base64/base64/lib/codec_choose.o /private/tmp/nix-build-nodejs-
18.17.1.drv-0/node-v18.17.1/out/Release/obj.target/base64/deps/base64/base64/lib/lib.o /private/tmp/nix-build-nodejs-18.17.1.drv-0/node-v18.17.1/out/Release/obj.target/base64/deps/base64/base64/lib/arch/neon32/codec.o /private/tmp/nix-build-nodejs-18.17.1.drv-0/node-v18.17.1/out/Release/obj.target/base64/deps/base64/base64/lib/arch/neon64/codec.o
In file included from <built-in>:440:
<command line>:32:9: warning: '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' macro redefined [-Wmacro-redefined]
#define __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 101300
^
<built-in>:431:9: note: previous definition is here
#define __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 101500
^
/nix/store/0iqd25xfcld27z9kg92qdayj872rw2k9-bash-5.2-p15/bin/bash: ./gyp-mac-tool: /usr/bin/env: bad interpreter: Operation not permitted
make[1]: *** [deps/base64/base64.target.mk:174: /private/tmp/nix-build-nodejs-18.17.1.drv-0/node-v18.17.1/out/Release/libbase64.a] Error 126
make[1]: *** Waiting for unfinished jobs....
21 warnings generated.
1 warning generated.
23 warnings generated.
rm bd7fbf3b03451c23263e00021ee01d702a3b9540.intermediate c5009241ae6960ccbf1b3255e5c7cbad052383eb.intermediate
make: *** [Makefile:134: node] Error 2
error: builder for '/nix/store/ag1bvf2wxfbwz0559dihhzhavd1blcmg-nodejs-18.17.1.drv' failed with exit code 2
Might still be doing something wrong, I don't remember this error from when I looked at this earlier but I can't seem to get around it now.
EDIT: The relation to env
actually seems tenuous. Sometimes it's the bad interpreter error, other times it's just make error 2.
Make aligned allocations work on x86_64-darwin by ensuring libc++ uses `posix_memalign` instead of `aligned_alloc`, which was added in 10.15.
Node v14 can’t build with clang 16 due to `-Wenum-constexpr-conversion` errors. Since the backport patch from v8 does not apply to Node v14, and it is likely this will become a hard error in future versions of clang, use clang 15 when the version in the stdenv is newer. The version of libc++ used with the clang is made to match the one used in the stdenv to avoid possible issues with mixing multiple versions of libc++ in one binary (e.g., icu links against libc++).
Node v16 can’t build with clang 16 due to `-Wenum-constexpr-conversion` errors. Since the backport patch from v8 does not apply to Node v14, and it is likely this will become a hard error in future versions of clang, use clang 15 when the version in the stdenv is newer. The version of libc++ used with the clang is made to match the one used in the stdenv to avoid possible issues with mixing multiple versions of libc++ in one binary (e.g., icu links against libc++).
I rebased on staging and dropped the node v18 commit. Upstream has cherry-picked the required commits to fix building with clang 16. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description of changes
Node.js requires severals fixes to build with clang 16:
posix_memalign
on x86_64-darwin. Otherwise, libc++ will try to usealigned_alloc
, which is not available until 10.15. This is done by defining it as using the 10.13 SDK even though the 10.12 SDK is sufficient;-Wenum-constexpr-conversion
may become a hard error in a future clang release. Using an older version ensures it builds until these versions are dropped from nixpkgs.Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)