diff options
author | Adam Joseph <adam@westernsemico.com> | 2022-12-08 19:57:17 -0800 |
---|---|---|
committer | sternenseemann <sternenseemann@systemli.org> | 2023-01-10 14:05:03 +0100 |
commit | dfa3f1449343738c8a5c261cc0770bd74a2cfdb5 (patch) | |
tree | d8fda9fc42d1a56bf16526ab857a7de3b5d613a8 /pkgs/build-support | |
parent | ad92b19e362ce0be181c616e8c528e571c38926d (diff) |
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.
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/cc-wrapper/default.nix | 6 |
1 files 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 |