From 5093766f79b6d14a6a833de1b91f5557b4160232 Mon Sep 17 00:00:00 2001 From: Artturin Date: Wed, 19 Jul 2023 22:34:46 +0300 Subject: [PATCH 1/3] setup-hooks/strip: Print strip stderr if command fails This is easiest to do through a file. mktemp needs six X because busybox only accepts exactly six X. --- pkgs/build-support/setup-hooks/strip.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/setup-hooks/strip.sh b/pkgs/build-support/setup-hooks/strip.sh index 8f0543b7ee739..032b816154a89 100644 --- a/pkgs/build-support/setup-hooks/strip.sh +++ b/pkgs/build-support/setup-hooks/strip.sh @@ -61,13 +61,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: From 2ae18b7e10a064c1d2c4d4720d0a88f3d3d29296 Mon Sep 17 00:00:00 2001 From: Artturin Date: Thu, 20 Jul 2023 06:49:38 +0300 Subject: [PATCH 2/3] setup-hooks/strip: Add -- before $cmd --- pkgs/build-support/setup-hooks/strip.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/build-support/setup-hooks/strip.sh b/pkgs/build-support/setup-hooks/strip.sh index 032b816154a89..ed374dbb960f3 100644 --- a/pkgs/build-support/setup-hooks/strip.sh +++ b/pkgs/build-support/setup-hooks/strip.sh @@ -65,7 +65,7 @@ stripDirs() { 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>"$striperr" || 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. From f46c8c1bcd9830d5e7b0d9264c8dd8f688518d9d Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 21 Jul 2023 21:56:38 +0300 Subject: [PATCH 3/3] setup-hooks/strip: Exit if `cmd` or `ranlibCmd` are empty --- pkgs/build-support/setup-hooks/strip.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/build-support/setup-hooks/strip.sh b/pkgs/build-support/setup-hooks/strip.sh index ed374dbb960f3..1d65c10c52308 100644 --- a/pkgs/build-support/setup-hooks/strip.sh +++ b/pkgs/build-support/setup-hooks/strip.sh @@ -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