···7done
89if $needsTarget; then
10- extraBefore+=(-target @defaultTarget@)
11fi
···7done
89if $needsTarget; then
10+ extraBefore+=(-target @defaultTarget@ @march@)
11fi
+8-1
pkgs/build-support/cc-wrapper/default.nix
···604 # Always add -march based on cpu in triple. Sometimes there is a
605 # discrepency (x86_64 vs. x86-64), so we provide an "arch" arg in
606 # that case.
000607 # TODO: aarch64-darwin has mcpu incompatible with gcc
608- + optionalString ((targetPlatform ? gcc.arch) && (isClang || !(stdenv.isDarwin && stdenv.isAarch64)) &&
609 isGccArchSupported targetPlatform.gcc.arch) ''
610 echo "-march=${targetPlatform.gcc.arch}" >> $out/nix-support/cc-cflags-before
611 ''
···694 ## Needs to go after ^ because the for loop eats \n and makes this file an invalid script
695 ##
696 + optionalString isClang ''
0000697 export defaultTarget=${targetPlatform.config}
698 substituteAll ${./add-clang-cc-cflags-before.sh} $out/nix-support/add-local-cc-cflags-before.sh
699 ''
···604 # Always add -march based on cpu in triple. Sometimes there is a
605 # discrepency (x86_64 vs. x86-64), so we provide an "arch" arg in
606 # that case.
607+ #
608+ # For clang, this is handled in add-clang-cc-cflags-before.sh
609+610 # TODO: aarch64-darwin has mcpu incompatible with gcc
611+ + optionalString ((targetPlatform ? gcc.arch) && !isClang && !(stdenv.isDarwin && stdenv.isAarch64) &&
612 isGccArchSupported targetPlatform.gcc.arch) ''
613 echo "-march=${targetPlatform.gcc.arch}" >> $out/nix-support/cc-cflags-before
614 ''
···697 ## Needs to go after ^ because the for loop eats \n and makes this file an invalid script
698 ##
699 + optionalString isClang ''
700+ # Escape twice: once for this script, once for the one it gets substituted into.
701+ export march=${lib.escapeShellArg
702+ (lib.optionalString (targetPlatform ? gcc.arch)
703+ (lib.escapeShellArg "-march=${targetPlatform.gcc.arch}"))}
704 export defaultTarget=${targetPlatform.config}
705 substituteAll ${./add-clang-cc-cflags-before.sh} $out/nix-support/add-local-cc-cflags-before.sh
706 ''