nodejs: fix build with clang 16#253009
Merged
toonn merged 3 commits intoNixOS:stagingfrom Oct 19, 2023
Merged
Conversation
toonn
reviewed
Sep 29, 2023
Contributor
toonn
left a comment
There was a problem hiding this comment.
Looks pretty good to me, only one nit. Still trying to run test builds.
toonn
reviewed
Oct 13, 2023
Contributor
There was a problem hiding this comment.
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++).
Contributor
Author
|
I rebased on staging and dropped the node v18 commit. Upstream has cherry-picked the required commits to fix building with clang 16. |
13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
Node.js requires severals fixes to build with clang 16:
posix_memalignon 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-conversionmay 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 = trueset 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/)