Skip to content

Commit

Permalink
Merge pull request #244400 from Artturin/stripprinterr
Browse files Browse the repository at this point in the history
  • Loading branch information
Artturin authored Jul 23, 2023
2 parents 5765a9f + f46c8c1 commit 2afcd08
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkgs/build-support/setup-hooks/strip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ stripDirs() {
local stripFlags="$4"
local pathsNew=

[ -z "$cmd" ] && echo "stripDirs: Strip command is empty" 1>&2 && exit 1
[ -z "$ranlibCmd" ] && echo "stripDirs: Ranlib command is empty" 1>&2 && exit 1

local p
for p in ${paths}; do
if [ -e "$prefix/$p" ]; then
Expand All @@ -61,13 +64,17 @@ stripDirs() {

if [ -n "${paths}" ]; then
echo "stripping (with command $cmd and flags $stripFlags) in $paths"
local striperr
striperr="$(mktemp 'striperr.XXXXXX')"
# Do not strip lib/debug. This is a directory used by setup-hooks/separate-debug-info.sh.
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 -r -0 -n1 -P "$NIX_BUILD_CORES" -- $cmd $stripFlags 2>"$striperr" || 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" ]]
[[ "$exit_code" = 123 || -z "$exit_code" ]] || (cat "$striperr" 1>&2 && exit 1)

rm "$striperr"
# '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:
Expand Down

0 comments on commit 2afcd08

Please sign in to comment.