dcavalca / rpms / rpm

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