Merge #291901: clang: don't set -march for overridden target

...into staging-next
This commit is contained in:
Vladimír Čunát 2024-03-01 11:32:18 +01:00
commit 0e4d8e918e
No known key found for this signature in database
GPG Key ID: E747DF1F9575A3AA
2 changed files with 9 additions and 2 deletions

View File

@ -7,5 +7,5 @@ for p in "${params[@]}"; do
done
if $needsTarget; then
extraBefore+=(-target @defaultTarget@)
extraBefore+=(-target @defaultTarget@ @march@)
fi

View File

@ -604,8 +604,11 @@ stdenv.mkDerivation {
# Always add -march based on cpu in triple. Sometimes there is a
# discrepency (x86_64 vs. x86-64), so we provide an "arch" arg in
# that case.
#
# For clang, this is handled in add-clang-cc-cflags-before.sh
# TODO: aarch64-darwin has mcpu incompatible with gcc
+ optionalString ((targetPlatform ? gcc.arch) && (isClang || !(stdenv.isDarwin && stdenv.isAarch64)) &&
+ optionalString ((targetPlatform ? gcc.arch) && !isClang && !(stdenv.isDarwin && stdenv.isAarch64) &&
isGccArchSupported targetPlatform.gcc.arch) ''
echo "-march=${targetPlatform.gcc.arch}" >> $out/nix-support/cc-cflags-before
''
@ -694,6 +697,10 @@ stdenv.mkDerivation {
## Needs to go after ^ because the for loop eats \n and makes this file an invalid script
##
+ optionalString isClang ''
# Escape twice: once for this script, once for the one it gets substituted into.
export march=${lib.escapeShellArg
(lib.optionalString (targetPlatform ? gcc.arch)
(lib.escapeShellArg "-march=${targetPlatform.gcc.arch}"))}
export defaultTarget=${targetPlatform.config}
substituteAll ${./add-clang-cc-cflags-before.sh} $out/nix-support/add-local-cc-cflags-before.sh
''