anchor.diff:    infixSalt  = stdenv.lib.optionalString (targetPlatform != hostPlatform) dashlessTarget;
     infixSalt_ = stdenv.lib.optionalString (targetPlatform != hostPlatform) (dashlessTarget + "_");
     _infixSalt = stdenv.lib.optionalString (targetPlatform != hostPlatform) ("_" + dashlessTarget);
  +
  +  # We want to prefix all NIX_ flags with the target triple
  +  preWrap = textFile:
  +    # TODO: Do even when not cross on next mass-rebuild
  +    # TODO: use @target_tripple@ for consistency
  +    if targetPlatform == hostPlatform
  +    then textFile
  +    else runCommand "sed-nix-env-vars" {} ''
  +      cp ${textFile} $out
  +
  +      sed -i $out \
  +        -e 's^NIX_^NIX_${infixSalt_}^g' \
  +        -e 's^addCVars^addCVars${_infixSalt}^g' \
  +        -e 's^\[ -z "\$crossConfig" \]^\[\[ "${builtins.toString (targetPlatform != hostPlatform)}" || -z "$crossConfig" \]\]^g'
  +
  +      # NIX_ things which we don't both use and define, we revert them
  +      #asymmetric=$(
  +      #  for pre in "" "\\$"
  +      #  do
  +      #    grep -E -ho $pre'NIX_[a-zA-Z_]*' ./* | sed 's/\$//' | sort | uniq
  +      #  done | sort | uniq -c | sort -nr | sed -n 's/^1 NIX_//gp')
  +
  +      # hard-code for now
  +      asymmetric=("CXXSTDLIB_COMPILE" "CC")
  +
  +      # The ([^a-zA-Z_]|$) bussiness is to ensure environment variables that
  +      # begin with `NIX_CC` don't also get blacklisted.
  +      for var in "''${asymmetric[@]}"
  +      do
  +        sed -i $out -E -e "s~NIX_${infixSalt_}$var([^a-zA-Z_]|$)~NIX_$var\1~g"
  +      done
  +    '';
   in
   
   stdenv.mkDerivation {
  
positive.code:         ln -s $ldPath/${prefix}as $out/bin/${prefix}as
        fi
  
        wrap ${prefix}ld ${./ld-wrapper.sh} ''${ld:-$ldPath/${prefix}ld}
  
        if [ -e ${binutils_bin}/bin/${prefix}ld.gold ]; then
          wrap ${prefix}ld.gold ${./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.gold
        fi
  
        if [ -e ${binutils_bin}/bin/ld.bfd ]; then
          wrap ${prefix}ld.bfd ${./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.bfd
        fi
  
        export real_cc=${prefix}cc
  
negative.code:   cc != null && binutils != null && coreutils != null && gnugrep != null;
  assert !(nativeLibc && noLibc);
  assert (noLibc || nativeLibc) == (libc == null);
  
  assert targetPlatform != hostPlatform -> runCommand != null;
  
  # For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper.
  assert cc.langVhdl or false -> zlib != null;
  