From 3d0de0e8c81d097c7bed0e482f47e24089df8ff9 Mon Sep 17 00:00:00 2001 From: Winter Date: Sat, 18 Feb 2023 20:41:24 -0500 Subject: [PATCH] gcc12: fix building foreign toolchain on aarch64-darwin It seems that the patchset we apply to get some fixes for aarch64-darwin support [0] breaks in unexpected ways when compiling a foreign toolchain [1]. Luckily, according to the branch's author, the patchset isn't required for merely using aarch64-darwin as the build system [2], so let's only apply it when hostPlatform == aarch64-darwin to fix cross. [0]: https://github.com/iains/gcc-12-branch [1]: https://github.com/iains/gcc-12-branch/issues/18 [2]: https://github.com/iains/gcc-12-branch/issues/18#issuecomment-1435792834 --- pkgs/development/compilers/gcc/12/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/gcc/12/default.nix b/pkgs/development/compilers/gcc/12/default.nix index cb3b0ba5ca2d..375c098eec63 100644 --- a/pkgs/development/compilers/gcc/12/default.nix +++ b/pkgs/development/compilers/gcc/12/default.nix @@ -64,7 +64,10 @@ let majorVersion = "12"; ../gnat-cflags-11.patch ../gcc-12-gfortran-driving.patch ../ppc-musl.patch - ] ++ optional (stdenv.isDarwin && stdenv.isAarch64) (fetchpatch { + ] + # We only apply this patch when building a native toolchain for aarch64-darwin, as it breaks building + # a foreign one: https://github.com/iains/gcc-12-branch/issues/18 + ++ optional (stdenv.isDarwin && stdenv.isAarch64 && buildPlatform == hostPlatform && hostPlatform == targetPlatform) (fetchpatch { name = "gcc-12-darwin-aarch64-support.patch"; url = "https://github.com/Homebrew/formula-patches/raw/1d184289/gcc/gcc-12.2.0-arm.diff"; sha256 = "sha256-omclLslGi/2yCV4pNBMaIpPDMW3tcz/RXdupbNbeOHA=";