nodejs: use a response file with llvm-ar#243683
Conversation
nodejs produces a static archive in its `postInstall`. It detects if the `ar` is GNU ar and uses a response file. Otherwise, it adds the files individually. This is apparently very slow with `llvm-ar`, which Darwin now uses by default. Fortunately, `llvm-ar` also supports response files, so detect whether the `ar` is `llvm-ar` and use a response file. I tested the build on aarch64-darwin. `postInstall` took less than a minute to generate a 59 MiB static archive. Comparing to the build on master, the only difference between the two archives is `llvm-ar` zeroes out the dates, uids, and gids by default. Compared disassembly of the archives appeared identical. This fixes the timeouts on staging-next. NixOS#241951 https://hydra.nixos.org/build/227170390
toonn
left a comment
There was a problem hiding this comment.
LGTM
I'll start a build on x86_64-darwin but since this is blocking staging-next maybe we don't want to wait for that?
| # llvm-ar supports response files, so take advantage of it if it’s available. | ||
| if [ "$(basename $(readlink -f $(command -v ar)))" = "llvm-ar" ]; then |
There was a problem hiding this comment.
Looks fine to me too. I wonder though if there some way to find out whether llvm-ar is expected at eval time in nix so the block becomes:
${if stdenv.buildPlatform.isGnu || stdenv.buildPlatform.isLlvmAr} then ''
ar -cqs $libv8/lib/libv8.a @files
'' else ''
...
''
There was a problem hiding this comment.
Not currently. We discussed in the Matrix room.
There was a problem hiding this comment.
Ideally we would set isLLVM, but Darwin isn’t a pure-LLVM platform. Maybe someday, but that’s still a ways off.
|
Result of 2 packages built:
|
|
not sure if this is a direct consequence of this PR, but I'm getting x86_64-darwin failure on building nodejs-20 This is not an emergency for me, just saying. |
|
Is there more to the crash? That looks like it happened in clang. This change was made in |
|
@vcunat sorry to ping you, but you're the only one that knows about hydra that I know. |
|
The log says so yes, that instance does look like it ran out of space ;-) Let me retry the build 🤷🏽 Overall the nodejs impact of this PR looks very good on Hydra: |
|
✅ succeeded |
Description of changes
nodejs produces a static archive in its
postInstall. It detects if thearis GNU ar and uses a response file. Otherwise, it adds the files individually. This is apparently very slow withllvm-ar, which Darwin now uses by default. Fortunately,llvm-aralso supports response files, so detect whether thearisllvm-arand use a response file.I tested the build on aarch64-darwin.
postInstalltook less than a minute to generate a 59 MiB static archive. Comparing to the build on master, the only difference between the two archives isllvm-arzeroes out the dates, uids, and gids by default. Compared disassembly of the archives appeared identical.This fixes the timeouts on staging-next. #241951
https://hydra.nixos.org/build/227170390
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/)