From 1cc4015a4c9170949328b31523e19aa7f9c8cbc3 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Thu, 8 Dec 2022 19:57:17 -0800 Subject: [PATCH] cc-wrapper: -march= is not allowed on powerpc Gcc does not allow `-march=` on PowerPC: https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/RS_002f6000-and-PowerPC-Options.html#RS_002f6000-and-PowerPC-Options Instead, `-mcpu=` should be used to set the minimum instruction set and `-mtune=` is used to optimize instruction scheduling for a specific processor. Both flags take the same set of valid values, which includes `native`. This commit causes `isGccArchSupported` to return `false` for PowerPC targets so we never pass an `-march=` flag, since that will always be rejected by gcc. --- pkgs/build-support/cc-wrapper/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index a59505d082584..7b0fbc4ec6db3 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -73,6 +73,7 @@ let # older compilers (for example bootstrap's GCC 5) fail with -march=too-modern-cpu isGccArchSupported = arch: + if targetPlatform.isPower then false else # powerpc does not allow -march= if isGNU then { # Intel skylake = versionAtLeast ccVersion "6.0"; @@ -441,8 +442,9 @@ stdenv.mkDerivation { echo "-march=${targetPlatform.gcc.arch}" >> $out/nix-support/cc-cflags-before '' - # -mcpu is not very useful. You should use mtune and march - # instead. It’s provided here for backwards compatibility. + # -mcpu is not very useful, except on PowerPC where it is used + # instead of march. On all other platforms you should use mtune + # and march instead. # TODO: aarch64-darwin has mcpu incompatible with gcc + optionalString ((targetPlatform ? gcc.cpu) && (isClang || !(stdenv.isDarwin && stdenv.isAarch64))) '' echo "-mcpu=${targetPlatform.gcc.cpu}" >> $out/nix-support/cc-cflags-before