git.iko.soy/typeable/nixpkgs
on master help sign in
cc-wrapper: when cross building, wedge in setting AR, AS, and LD env vars to their cross building versions

I think it's ok to export things which aren't wrapped. The cc-wrapper can be thought of as responsible for all of binutils and the c compiler, only wrapping those binaries which are necessary to interposition---as opposed to all binaries it thinks are relevaant. Conversely, adding the setup hook to the unwrapped compilers would be unforunate as hooks are ugly hacks and the compilers themselves take a long time to rebuild. Better to wholely separate "pure packages" from hacks.

commitc1fb71b74a15eba29c01ce8b2aa514310c437992 authorRoss MacLeod <rmm-github@z.odi.ac> dateTue 30 May 2017, 23:31 (10 years ago) parente0492d5
1 file changed+17−3
pkgs/build-support/cc-wrapper/default.nix+17−3
pkgs/build-support/cc-wrapper/default.nix+17−3
@@ -61,14 +61,28 @@ let
6161 # TODO: use @target_tripple@ for consistency
6262 if targetPlatform == hostPlatform
6363 then textFile
64− else runCommand "sed-nix-env-vars" {} ''
65− cp ${textFile} $out
64+ else runCommand "sed-nix-env-vars" {} (''
65+ cp --no-preserve=mode ${textFile} $out
6666
6767 sed -i $out \
6868 -e 's^NIX_^NIX_${infixSalt_}^g' \
6969 -e 's^addCVars^addCVars${_infixSalt}^g' \
7070 -e 's^\[ -z "\$crossConfig" \]^\[\[ "${builtins.toString (targetPlatform != hostPlatform)}" || -z "$crossConfig" \]\]^g'
7171
72+ '' + stdenv.lib.optionalString (textFile == ./setup-hook.sh) ''
73+ cat << 'EOF' >> $out
74+ for CMD in ar as nm objcopy ranlib strip strings size ld
75+ do
76+ # which is not part of stdenv, but compgen will do for now
77+ if
78+ PATH=$_PATH type -p ${prefix}$CMD > /dev/null
79+ then
80+ export ''$(echo "$CMD" | tr "[:lower:]" "[:upper:]")=${prefix}''${CMD};
81+ fi
82+ done
83+ EOF
84+ '' + ''
85+
7286 # NIX_ things which we don't both use and define, we revert them
7387 #asymmetric=$(
7488 # for pre in "" "\\$"
@@ -85,7 +99,7 @@ let
8599 do
86100 sed -i $out -E -e "s~NIX_${infixSalt_}$var([^a-zA-Z_]|$)~NIX_$var\1~g"
87101 done
88− '';
102+ '');
89103in
90104
91105stdenv.mkDerivation {