about summary refs log tree commit diff
path: root/pkgs/build-support/setup-hooks
diff options
context:
space:
mode:
authorLinus Heckemann <git@sphalerite.org>2022-12-15 23:13:39 +0100
committerLinus Heckemann <git@sphalerite.org>2023-07-10 12:24:13 +0200
commit70945eb79bae07d272105d21c6cf50d2ed3a5e20 (patch)
tree8960b96dae9f321fea8d98eac9b720af5b15ae08 /pkgs/build-support/setup-hooks
parente6ca034dec5f8a2d00eff05733ea0c64500a894d (diff)
setup-hooks/strip: parallelise stripping
This makes bootstrapping to GNU hello ~1-2% faster on an 8-core
machine and ~3-4% faster on a 64-core machine.
Diffstat (limited to 'pkgs/build-support/setup-hooks')
-rw-r--r--pkgs/build-support/setup-hooks/strip.sh7
1 files changed, 6 insertions, 1 deletions
diff --git a/pkgs/build-support/setup-hooks/strip.sh b/pkgs/build-support/setup-hooks/strip.sh
index 849148e92149d..8f0543b7ee739 100644
--- a/pkgs/build-support/setup-hooks/strip.sh
+++ b/pkgs/build-support/setup-hooks/strip.sh
@@ -62,7 +62,12 @@ stripDirs() {
     if [ -n "${paths}" ]; then
         echo "stripping (with command $cmd and flags $stripFlags) in $paths"
         # Do not strip lib/debug. This is a directory used by setup-hooks/separate-debug-info.sh.
-        find $paths -type f -a '!' -wholename "$prefix/lib/debug/*" -exec $cmd $stripFlags '{}' \; 2>/dev/null
+        find $paths -type f -a '!' -path "$prefix/lib/debug/*" -print0 |
+            xargs -r -0 -n1 -P "$NIX_BUILD_CORES" $cmd $stripFlags 2>/dev/null || exit_code=$?
+        # xargs exits with status code 123 if some but not all of the
+        # processes fail. We don't care if some of the files couldn't
+        # be stripped, so ignore specifically this code.
+        [[ "$exit_code" = 123 || -z "$exit_code" ]]
         # 'strip' does not normally preserve archive index in .a files.
         # This usually causes linking failures against static libs like:
         #   ld: ...-i686-w64-mingw32-stage-final-gcc-13.0.0-lib/i686-w64-mingw32/lib/libstdc++.dll.a: