gcc: fix building with gcc.cpu on some platforms

This fixes, for example, cross compiling to
{ system = "riscv64-linux"; gcc.cpu = "sifive-u74"; }.
This commit is contained in:
Alyssa Ross 2024-06-04 19:17:21 +01:00
parent 2286531945
commit 0a71bbb64a

View File

@ -8,8 +8,9 @@ let
in lib.concatLists [
# --with-arch= is unknown flag on x86_64 and aarch64-darwin.
(lib.optional (!targetPlatform.isx86_64 && !isAarch64Darwin && p ? arch) "--with-arch=${p.arch}")
# See supported_defaults in gcc/config.gcc for architecture support.
# --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 (with targetPlatform; !isLoongArch64 && !isMips && !isRiscV && !isS390 && !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}")