From 87478fdfdff0980ab8d14bc28940463c60abd436 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sat, 15 Jul 2023 10:58:26 -0600 Subject: [PATCH] nodejs: use a response file with llvm-ar 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. #241951 https://hydra.nixos.org/build/227170390 --- pkgs/development/web/nodejs/nodejs.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/development/web/nodejs/nodejs.nix b/pkgs/development/web/nodejs/nodejs.nix index 75690367ec93..bd90641c16f2 100644 --- a/pkgs/development/web/nodejs/nodejs.nix +++ b/pkgs/development/web/nodejs/nodejs.nix @@ -160,9 +160,14 @@ let ${if stdenv.buildPlatform.isGnu then '' ar -cqs $libv8/lib/libv8.a @files '' else '' - cat files | while read -r file; do - ar -cqS $libv8/lib/libv8.a $file - done + # llvm-ar supports response files, so take advantage of it if it’s available. + if [ "$(basename $(readlink -f $(command -v ar)))" = "llvm-ar" ]; then + ar -cqs $libv8/lib/libv8.a @files + else + cat files | while read -r file; do + ar -cqS $libv8/lib/libv8.a $file + done + fi ''} popd