Merge #115235: gcc: native aarch64-darwin support

+18 -6
+4 -2
pkgs/build-support/cc-wrapper/default.nix
··· 432 432 # Always add -march based on cpu in triple. Sometimes there is a 433 433 # discrepency (x86_64 vs. x86-64), so we provide an "arch" arg in 434 434 # that case. 435 - + optionalString ((targetPlatform ? gcc.arch) && 435 + # TODO: aarch64-darwin has mcpu incompatible with gcc 436 + + optionalString ((targetPlatform ? gcc.arch) && (isClang || !(stdenv.isDarwin && stdenv.isAarch64)) && 436 437 isGccArchSupported targetPlatform.gcc.arch) '' 437 438 echo "-march=${targetPlatform.gcc.arch}" >> $out/nix-support/cc-cflags-before 438 439 '' 439 440 440 441 # -mcpu is not very useful. You should use mtune and march 441 442 # instead. It’s provided here for backwards compatibility. 442 - + optionalString (targetPlatform ? gcc.cpu) '' 443 + # TODO: aarch64-darwin has mcpu incompatible with gcc 444 + + optionalString ((targetPlatform ? gcc.cpu) && (isClang || !(stdenv.isDarwin && stdenv.isAarch64))) '' 443 445 echo "-mcpu=${targetPlatform.gcc.cpu}" >> $out/nix-support/cc-cflags-before 444 446 '' 445 447
+5
pkgs/development/compilers/gcc/11/default.nix
··· 72 72 ++ optional langFortran ../gfortran-driving.patch 73 73 ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch 74 74 75 + ++ optional (stdenv.isDarwin && stdenv.isAarch64) (fetchpatch { 76 + url = "https://github.com/fxcoudert/gcc/compare/releases/gcc-11.1.0...gcc-11.1.0-arm-20210504.diff"; 77 + sha256 = "sha256-JqCGJAfbOxSmkNyq49aFHteK/RFsCSLQrL9mzUCnaD0="; 78 + }) 79 + 75 80 # Obtain latest patch with ../update-mcfgthread-patches.sh 76 81 ++ optional (!crossStageStatic && targetPlatform.isMinGW) ./Added-mcf-thread-model-support-from-mcfgthread.patch; 77 82
+2 -1
pkgs/development/compilers/gcc/common/configure-flags.nix
··· 185 185 ++ lib.optional javaAwtGtk "--enable-java-awt=gtk" 186 186 ++ lib.optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" 187 187 188 - ++ (import ../common/platform-flags.nix { inherit (stdenv) targetPlatform; inherit lib; }) 188 + # TODO: aarch64-darwin has clang stdenv and its arch and cpu flag values are incompatible with gcc 189 + ++ lib.optional (!(stdenv.isDarwin && stdenv.isAarch64)) (import ../common/platform-flags.nix { inherit (stdenv) targetPlatform; inherit lib; }) 189 190 ++ lib.optionals (targetPlatform != hostPlatform) crossConfigureFlags 190 191 ++ lib.optional (targetPlatform != hostPlatform) "--disable-bootstrap" 191 192
+7 -3
pkgs/top-level/all-packages.nix
··· 10344 10344 else ../development/compilers/gcc/10); 10345 10345 gcc = if (with stdenv.targetPlatform; isVc4 || libc == "relibc") 10346 10346 then gcc6 else 10347 - if stdenv.targetPlatform.isAarch64 then gcc9 else gcc10; 10347 + # aarch64-darwin doesn't support earlier gcc 10348 + if (stdenv.targetPlatform.isAarch64 && stdenv.isDarwin) then gcc11 10349 + else if stdenv.targetPlatform.isAarch64 then gcc9 else gcc10; 10348 10350 gcc-unwrapped = gcc.cc; 10349 10351 10350 10352 wrapNonDeterministicGcc = stdenv: ccWrapper: ··· 10572 10574 10573 10575 gcc_latest = gcc11; 10574 10576 10575 - gfortran = gfortran9; 10577 + # aarch64-darwin doesn't support earlier gcc 10578 + gfortran = if (stdenv.isDarwin && stdenv.isAarch64) then gfortran11 else gfortran9; 10576 10579 10577 10580 gfortran48 = wrapCC (gcc48.cc.override { 10578 10581 name = "gfortran"; ··· 10660 10663 inherit (gnome2) libart_lgpl; 10661 10664 }); 10662 10665 10663 - gnat = gnat9; 10666 + # aarch64-darwin doesn't support earlier gcc 10667 + gnat = if (stdenv.isDarwin && stdenv.isAarch64) then gnat11 else gnat9; 10664 10668 10665 10669 gnat6 = wrapCC (gcc6.cc.override { 10666 10670 name = "gnat";