richardphibel / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
ed184b
From 1fd84fa0cfa6e493d1c15edfb7d9f0bb05e4f920 Mon Sep 17 00:00:00 2001
ed184b
From: Florian Festi <ffesti@redhat.com>
ed184b
Date: Thu, 2 May 2019 17:17:56 +0200
ed184b
Subject: [PATCH] Fix brp-strip-static-archive parallelism
ed184b
ed184b
The change made in fc2c986 can break for large values of %_smp_build_ncpus as
ed184b
this many processes are able to overflow the following pipe.
ed184b
ed184b
Thanks to Denys Vlasenko for testing this.
ed184b
ed184b
This change solves this problem by running a whole processing pileline for each
ed184b
parallel (file) process. This has also the benefit of running at least some
ed184b
stip commands in parallel.
ed184b
ed184b
The -n param fro xargs was increased to 32 to further reduce the over head of
ed184b
spawing the helpers as they are now needed for each run of the file command.
ed184b
---
ed184b
 scripts/brp-strip-static-archive | 10 +++-------
ed184b
 1 file changed, 3 insertions(+), 7 deletions(-)
ed184b
ed184b
diff --git a/scripts/brp-strip-static-archive b/scripts/brp-strip-static-archive
ed184b
index 4dc449061..13d9a098b 100755
ed184b
--- a/scripts/brp-strip-static-archive
ed184b
+++ b/scripts/brp-strip-static-archive
ed184b
@@ -13,10 +13,6 @@ Darwin*) exit 0 ;;
ed184b
 esac
ed184b
 
ed184b
 # Strip static libraries.
ed184b
-for f in `find "$RPM_BUILD_ROOT" -type f | \
ed184b
-	grep -v "^${RPM_BUILD_ROOT}/\?usr/lib/debug" | \
ed184b
-	xargs -r -P$NCPUS -n16 file | sed 's/:  */: /' | \
ed184b
-	grep 'current ar archive' | \
ed184b
-	sed -n -e 's/^\(.*\):[  ]*current ar archive/\1/p'`; do
ed184b
-	$STRIP -g "$f"
ed184b
-done
ed184b
+find "$RPM_BUILD_ROOT" -type f | \
ed184b
+    grep -v "^${RPM_BUILD_ROOT}/\?usr/lib/debug" | \
ed184b
+    xargs -r -P$NCPUS -n32 sh -c "file \"\$@\" | sed 's/:  */: /' | grep 'current ar archive' | sed -n -e 's/^\(.*\):[  ]*current ar archive/\1/p' | xargs -I\{\} $STRIP -g \{\}" ARG0
ed184b
-- 
ed184b
2.21.0
ed184b