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=";