makeBinaryWrapper: fix passthru.extractCmd on darwin

On darwin, strings does not support -d. Regardless of darwin, the
generated extract script has `strings` without a full nix store path,
making it potentially impure.

The solution is to always pull `strings` from GNU toolchain, regardless
of the platform.

Note: this change should have no implications for darwin bootstrap
because `passthru.extractCmd` has very limited use in the tree,
basically only used when building Firefox, and is not evaluated
otherwise.

Note: previous attempt to resolve the issue was incorrect, effectively
doing nothing on Darwin, see #379014. (The
`targetPackages.gnuStdenv.cc.bintools.targetPrefix` was empty.)
This commit is contained in:
Ihar Hrachyshka
2026-01-25 13:38:09 -05:00
parent 4f4305abc5
commit 6057da3eea

View File

@@ -24,9 +24,13 @@ makeSetupHook {
passthru = {
# Extract the function call used to create a binary wrapper from its embedded docstring
extractCmd = writeShellScript "extract-binary-wrapper-cmd" ''
${targetPackages.gnuStdenv.cc.bintools.targetPrefix}strings -dw "$1" | sed -n '/^makeCWrapper/,/^$/ p'
'';
extractCmd =
let
bintools = targetPackages.gnuStdenv.cc.bintools;
in
writeShellScript "extract-binary-wrapper-cmd" ''
${lib.getExe' bintools "${bintools.targetPrefix}strings"} -dw "$1" | sed -n '/^makeCWrapper/,/^$/ p'
'';
tests = tests.makeBinaryWrapper;
};