stdenv: move --enable-deterministic-archives flag into GNU wrapper

`--enable-deterministic-archives` is a GNU specific strip flag and
causes other strip implementations (for example LLVM's, see #138013)
to fail. Since strip failures are ignored, this means that stripping
doesn't work at all in certain situation (causing unnecessary
dependencies etc.).

To fix this, no longer pass `--enable-deterministic-archives`
unconditionally, but instead add it in a GNU binutils specific strip
wrapper only.

`commonStripFlags` was only used for this flag, so we can remove
it altogether.

Future work could be to make a generic strip wrapper, with support for
nix-support/strip-flags-{before,after} and NIX_STRIP_FLAGS_{BEFORE,AFTER}.
This possibly overkill and unnecessary though -- also with the
additional challenge of incorporating the darwin strip wrapper somehow.

Changed files
+16 -7
pkgs
build-support
bintools-wrapper
setup-hooks
stdenv
linux
+10
pkgs/build-support/bintools-wrapper/default.nix
···
echo "-arch ${targetPlatform.darwinArch}" >> $out/nix-support/libc-ldflags
''
+
##
+
## GNU specific extra strip flags
+
##
+
+
# TODO(@sternenseemann): make a generic strip wrapper?
+
+ optionalString (bintools.isGNU or false) ''
+
wrap ${targetPrefix}strip ${./gnu-binutils-strip-wrapper.sh} \
+
"${bintools_bin}/bin/${targetPrefix}strip"
+
''
+
###
### Remove LC_UUID
###
+4
pkgs/build-support/bintools-wrapper/gnu-binutils-strip-wrapper.sh
···
+
#! @shell@
+
# shellcheck shell=bash
+
+
exec @prog@ --enable-deterministic-archives "$@"
+1 -1
pkgs/build-support/setup-hooks/strip.sh
···
if [ -n "${dirs}" ]; then
header "stripping (with command $cmd and flags $stripFlags) in$dirs"
-
find $dirs -type f -exec $cmd $commonStripFlags $stripFlags '{}' \; 2>/dev/null
+
find $dirs -type f -exec $cmd $stripFlags '{}' \; 2>/dev/null
stopNest
fi
}
+1 -6
pkgs/stdenv/linux/default.nix
···
targetPlatform = localSystem;
inherit config;
-
preHook = ''
-
# Make "strip" produce deterministic output, by setting
-
# timestamps etc. to a fixed value.
-
commonStripFlags="--enable-deterministic-archives"
-
${commonPreHook}
-
'';
+
preHook = commonPreHook;
initialPath =
((import ../common-path.nix) {pkgs = prevStage;});