diff options
author | Elias Naur <mail@eliasnaur.com> | 2023-04-08 12:55:40 -0600 |
---|---|---|
committer | Elias Naur <mail@eliasnaur.com> | 2023-04-27 15:57:17 -0600 |
commit | c10a195ab1b577918fdfa1f4a08b7b634f137be9 (patch) | |
tree | 6c4cf0b0c100276d188503b83861e00357d92e72 /pkgs/development/compilers/gcc/common/platform-flags.nix | |
parent | f7cb50b3cfd4c6c4be75f5e33172021be562a49b (diff) |
gcc: tighten platform flags special-case for aarch64-darwin
The 4aa95e33121c316c5b34031bb08106d2dc113e38 commit added support for aarch64-darwin but also ignored platform flags if the build platform is aarch64-darwin. This leads to confusing errors such as `pkgsCross.raspberryPi` packages compiled with soft-float even though the platform supports hard-float (and is built as such on other platforms). The correct way to ignore platform flags is to check `targetPlatform`, not the build platform. This change fixes that. While we're here, tigthen the special-case to cover only the problematic flags: `-with-cpu` and `-with-arch`.
Diffstat (limited to 'pkgs/development/compilers/gcc/common/platform-flags.nix')
-rw-r--r-- | pkgs/development/compilers/gcc/common/platform-flags.nix | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pkgs/development/compilers/gcc/common/platform-flags.nix b/pkgs/development/compilers/gcc/common/platform-flags.nix index c0593cd781ed4..57d7438fcd3a9 100644 --- a/pkgs/development/compilers/gcc/common/platform-flags.nix +++ b/pkgs/development/compilers/gcc/common/platform-flags.nix @@ -1,12 +1,15 @@ { lib, targetPlatform }: let + isAarch64Darwin = targetPlatform.isDarwin && targetPlatform.isAarch64; gcc = targetPlatform.gcc or {}; p = gcc // targetPlatform.parsed.abi; in lib.concatLists [ - (lib.optional (!targetPlatform.isx86_64 && p ? arch) "--with-arch=${p.arch}") # --with-arch= is unknown flag on x86_64 - (lib.optional (p ? cpu) "--with-cpu=${p.cpu}") + # --with-arch= is unknown flag on x86_64 and aarch64-darwin. + (lib.optional (!targetPlatform.isx86_64 && !isAarch64Darwin && p ? arch) "--with-arch=${p.arch}") + # --with-cpu on aarch64-darwin fails with "Unknown cpu used in --with-cpu=apple-a13". + (lib.optional (!isAarch64Darwin && p ? cpu) "--with-cpu=${p.cpu}") (lib.optional (p ? abi) "--with-abi=${p.abi}") (lib.optional (p ? fpu) "--with-fpu=${p.fpu}") (lib.optional (p ? float) "--with-float=${p.float}") |