From 75104490c0f1734308cd91ab7cb7a92d89588dbd Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Tue, 7 May 2024 09:34:35 +0100 Subject: [PATCH 1/4] gcc14, gfortran14, gnat14, gccgo14: init at 14.1.0 Changes: https://gcc.gnu.org/gcc-14/changes.html --- pkgs/development/compilers/gcc/default.nix | 2 + .../compilers/gcc/patches/default.nix | 3 ++ pkgs/development/compilers/gcc/versions.nix | 2 + pkgs/top-level/all-packages.nix | 48 ++++++++++++++++++- 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index c3a0efe6aaa1..cb2a40dfe1c6 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -70,6 +70,7 @@ let version = gccVersions.fromMajorMinor majorMinorVersion; majorVersion = versions.major version; + atLeast14 = versionAtLeast version "14"; atLeast13 = versionAtLeast version "13"; atLeast12 = versionAtLeast version "12"; atLeast11 = versionAtLeast version "11"; @@ -79,6 +80,7 @@ let atLeast7 = versionAtLeast version "7"; atLeast6 = versionAtLeast version "6"; atLeast49 = versionAtLeast version "4.9"; + is14 = majorVersion == "14"; is13 = majorVersion == "13"; is12 = majorVersion == "12"; is11 = majorVersion == "11"; diff --git a/pkgs/development/compilers/gcc/patches/default.nix b/pkgs/development/compilers/gcc/patches/default.nix index 8f0c8f6d288c..801640e9411f 100644 --- a/pkgs/development/compilers/gcc/patches/default.nix +++ b/pkgs/development/compilers/gcc/patches/default.nix @@ -25,6 +25,7 @@ }: let + atLeast14 = lib.versionAtLeast version "14"; atLeast13 = lib.versionAtLeast version "13"; atLeast12 = lib.versionAtLeast version "12"; atLeast11 = lib.versionAtLeast version "11"; @@ -34,6 +35,7 @@ let atLeast7 = lib.versionAtLeast version "7"; atLeast6 = lib.versionAtLeast version "6"; atLeast49 = lib.versionAtLeast version "4.9"; + is14 = majorVersion == "14"; is13 = majorVersion == "13"; is12 = majorVersion == "12"; is11 = majorVersion == "11"; @@ -63,6 +65,7 @@ in ++ optionals (noSysDirs) ( [(if atLeast12 then ./gcc-12-no-sys-dirs.patch else ./no-sys-dirs.patch)] ++ ({ + "14" = [ ./13/no-sys-dirs-riscv.patch ./13/mangle-NIX_STORE-in-__FILE__.patch ]; "13" = [ ./13/no-sys-dirs-riscv.patch ./13/mangle-NIX_STORE-in-__FILE__.patch ]; "12" = [ ./no-sys-dirs-riscv.patch ./12/mangle-NIX_STORE-in-__FILE__.patch ]; "11" = [ ./no-sys-dirs-riscv.patch ]; diff --git a/pkgs/development/compilers/gcc/versions.nix b/pkgs/development/compilers/gcc/versions.nix index 261ffc634544..90c4949b19ea 100644 --- a/pkgs/development/compilers/gcc/versions.nix +++ b/pkgs/development/compilers/gcc/versions.nix @@ -1,5 +1,6 @@ let majorMinorToVersionMap = { + "14" = "14.1.0"; "13" = "13.2.0"; "12" = "12.3.0"; "11" = "11.4.0"; @@ -19,6 +20,7 @@ let srcHashForVersion = version: { # NOTE: there is no need to remove hashes of obsolete minor # versions when adding a new minor version. + "14.1.0" = "sha256-4oPGVJh6/j3p2AgLwL15U0tcoNaBpzoR/ytdN2dCaEA="; "13.2.0" = "sha256-4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o="; "12.3.0" = "sha256-lJpdT5nnhkIak7Uysi/6tVeN5zITaZdbka7Jet/ajDs="; "11.4.0" = "sha256-Py2yIrAH6KSiPNW6VnJu8I6LHx6yBV7nLBQCzqc6jdk="; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ff98b76a698b..110fc178d0e1 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15491,6 +15491,7 @@ with pkgs; gcc11Stdenv = overrideCC gccStdenv buildPackages.gcc11; gcc12Stdenv = overrideCC gccStdenv buildPackages.gcc12; gcc13Stdenv = overrideCC gccStdenv buildPackages.gcc13; + gcc14Stdenv = overrideCC gccStdenv buildPackages.gcc14; # This is not intended for use in nixpkgs but for providing a faster-running # compiler to nixpkgs users by building gcc with reproducibility-breaking @@ -15581,9 +15582,9 @@ with pkgs; }; inherit (callPackage ../development/compilers/gcc/all.nix { inherit noSysDirs; }) - gcc48 gcc49 gcc6 gcc7 gcc8 gcc9 gcc10 gcc11 gcc12 gcc13; + gcc48 gcc49 gcc6 gcc7 gcc8 gcc9 gcc10 gcc11 gcc12 gcc13 gcc14; - gcc_latest = gcc13; + gcc_latest = gcc14; # Use the same GCC version as the one from stdenv by default gfortran = wrapCC (gcc.cc.override { @@ -15674,6 +15675,14 @@ with pkgs; profiledCompiler = false; }); + gfortran14 = wrapCC (gcc14.cc.override { + name = "gfortran"; + langFortran = true; + langCC = false; + langC = false; + profiledCompiler = false; + }); + libgccjit = gcc.cc.override { name = "libgccjit"; langFortran = false; @@ -15767,6 +15776,29 @@ with pkgs; else stdenv; }); + gnat14 = wrapCC (gcc14.cc.override { + name = "gnat"; + langC = true; + langCC = false; + langAda = true; + profiledCompiler = false; + # As per upstream instructions building a cross compiler + # should be done with a (native) compiler of the same version. + # If we are cross-compiling GNAT, we may as well do the same. + gnat-bootstrap = + if stdenv.hostPlatform == stdenv.targetPlatform + && stdenv.buildPlatform == stdenv.hostPlatform + then buildPackages.gnat-bootstrap12 + else buildPackages.gnat13; + stdenv = + if stdenv.hostPlatform == stdenv.targetPlatform + && stdenv.buildPlatform == stdenv.hostPlatform + && stdenv.buildPlatform.isDarwin + && stdenv.buildPlatform.isx86_64 + then overrideCC stdenv gnat-bootstrap12 + else stdenv; + }); + gnat-bootstrap = gnat-bootstrap12; gnat-bootstrap11 = wrapCC (callPackage ../development/compilers/gnat-bootstrap { majorVersion = "11"; }); gnat-bootstrap12 = wrapCCWith ({ @@ -15821,6 +15853,18 @@ with pkgs; meta.broken = stdenv.hostPlatform.isDarwin; }); + gccgo14 = wrapCC (gcc14.cc.override { + name = "gccgo"; + langCC = true; #required for go. + langC = true; + langGo = true; + langJit = true; + profiledCompiler = false; + } // { + # not supported on darwin: https://github.com/golang/go/issues/463 + meta.broken = stdenv.hostPlatform.isDarwin; + }); + ghdl = ghdl-mcode; ghdl-mcode = callPackage ../development/compilers/ghdl { From d851de26472337b53532caffcd5f22d7daf504f5 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Tue, 7 May 2024 15:17:42 +0200 Subject: [PATCH 2/4] gcc14: add aarch64-darwin support --- pkgs/development/compilers/gcc/common/dependencies.nix | 2 ++ pkgs/development/compilers/gcc/default.nix | 1 + pkgs/development/compilers/gcc/patches/default.nix | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/pkgs/development/compilers/gcc/common/dependencies.nix b/pkgs/development/compilers/gcc/common/dependencies.nix index a38cdcb9e20f..fd9036c23ac6 100644 --- a/pkgs/development/compilers/gcc/common/dependencies.nix +++ b/pkgs/development/compilers/gcc/common/dependencies.nix @@ -15,6 +15,7 @@ , libucontext ? null , libxcrypt ? null , cloog ? null +, darwin ? null , isl ? null , zlib ? null , gnat-bootstrap ? null @@ -85,6 +86,7 @@ in ++ optionals langJava [ boehmgc zip unzip ] ++ optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs) ++ optionals (langGo && stdenv.hostPlatform.isMusl) [ libucontext ] + ++ optionals (lib.versionAtLeast version "14" && stdenv.hostPlatform.isDarwin) [ darwin.apple_sdk.frameworks.CoreServices ] ; # threadsCross.package after gcc6 so i assume its okay for 4.8 and 4.9 too diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index cb2a40dfe1c6..5e017a21fa1f 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -129,6 +129,7 @@ let buildPackages cloog withoutTargetLibc + darwin disableBootstrap disableGdbPlugin enableLTO diff --git a/pkgs/development/compilers/gcc/patches/default.nix b/pkgs/development/compilers/gcc/patches/default.nix index 801640e9411f..ab6798af835e 100644 --- a/pkgs/development/compilers/gcc/patches/default.nix +++ b/pkgs/development/compilers/gcc/patches/default.nix @@ -139,6 +139,11 @@ in # 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 ++ optionals (stdenv.isDarwin && stdenv.isAarch64 && buildPlatform == hostPlatform && hostPlatform == targetPlatform) ({ + "14" = [ (fetchpatch { + name = "gcc-14-darwin-aarch64-support.patch"; + url = "https://raw.githubusercontent.com/Homebrew/formula-patches/82b5c1cd38826ab67ac7fc498a8fe74376a40f4a/gcc/gcc-14.1.0.diff"; + sha256 = "sha256-jCY65l1DGdESNyzEmD8FFC/xMmqeqBIQF+BhT4uTBBU="; + }) ]; "13" = [ (fetchpatch { name = "gcc-13-darwin-aarch64-support.patch"; url = "https://raw.githubusercontent.com/Homebrew/formula-patches/3c5cbc8e9cf444a1967786af48e430588e1eb481/gcc/gcc-13.2.0.diff"; From 44e55797bef61b6f339ae906ecd430327caef80b Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Tue, 14 May 2024 11:30:19 +0200 Subject: [PATCH 3/4] gcc14: add x86_64-darwin support --- .../gcc/patches/14/libgcc-darwin-detection.patch | 12 ++++++++++++ pkgs/development/compilers/gcc/patches/default.nix | 3 +++ 2 files changed, 15 insertions(+) create mode 100644 pkgs/development/compilers/gcc/patches/14/libgcc-darwin-detection.patch diff --git a/pkgs/development/compilers/gcc/patches/14/libgcc-darwin-detection.patch b/pkgs/development/compilers/gcc/patches/14/libgcc-darwin-detection.patch new file mode 100644 index 000000000000..27d455aa58b6 --- /dev/null +++ b/pkgs/development/compilers/gcc/patches/14/libgcc-darwin-detection.patch @@ -0,0 +1,12 @@ +diff -u a/libgcc/config.host b/libgcc/config.host +--- a/libgcc/config.host 2023-11-05 11:01:55.778638446 -0500 ++++ b/libgcc/config.host 2023-11-05 11:07:29.405103979 -0500 +@@ -227,7 +227,7 @@ + tmake_file="$tmake_file t-slibgcc-darwin" + # newer toolsets produce warnings when building for unsupported versions. + case ${host} in +- *-*-darwin1[89]* | *-*-darwin2* ) ++ *-*-darwin1[89]* | *-*-darwin2* | *-*-darwin) + tmake_file="t-darwin-min-8 $tmake_file" + ;; + *-*-darwin9* | *-*-darwin1[0-7]*) diff --git a/pkgs/development/compilers/gcc/patches/default.nix b/pkgs/development/compilers/gcc/patches/default.nix index ab6798af835e..eb38c3a1fe88 100644 --- a/pkgs/development/compilers/gcc/patches/default.nix +++ b/pkgs/development/compilers/gcc/patches/default.nix @@ -127,6 +127,9 @@ in ## Darwin +# Fixes detection of Darwin on x86_64-darwin. Otherwise, GCC uses a deployment target of 10.5, which crashes ld64. +++ optional (atLeast14 && stdenv.isDarwin && stdenv.isx86_64) ../patches/14/libgcc-darwin-detection.patch + # Fix detection of bootstrap compiler Ada support (cctools as) on Nix Darwin ++ optional (atLeast12 && stdenv.isDarwin && langAda) ./ada-cctools-as-detection-configure.patch From 10a5379763d2137cdbeea1a1bcbebba4594c113a Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Tue, 21 May 2024 17:52:45 +0200 Subject: [PATCH 4/4] gnat14: fix build on x86_64-darwin --- .../14/gcc-darwin-remove-coreservices.patch | 39 +++++++++++++++++++ .../gnat-darwin-dylib-install-name-14.patch | 21 ++++++++++ .../compilers/gcc/patches/default.nix | 4 ++ 3 files changed, 64 insertions(+) create mode 100644 pkgs/development/compilers/gcc/patches/14/gcc-darwin-remove-coreservices.patch create mode 100644 pkgs/development/compilers/gcc/patches/14/gnat-darwin-dylib-install-name-14.patch diff --git a/pkgs/development/compilers/gcc/patches/14/gcc-darwin-remove-coreservices.patch b/pkgs/development/compilers/gcc/patches/14/gcc-darwin-remove-coreservices.patch new file mode 100644 index 000000000000..9d21a3c4c438 --- /dev/null +++ b/pkgs/development/compilers/gcc/patches/14/gcc-darwin-remove-coreservices.patch @@ -0,0 +1,39 @@ +diff --git a/config/intlmacosx.m4 b/config/intlmacosx.m4 +index 3141bf8c5..7a31862b9 100644 +--- a/config/intlmacosx.m4 ++++ b/config/intlmacosx.m4 +@@ -63,7 +63,7 @@ AC_DEFUN([gt_INTL_MACOSX], + dnl and we have to link it in explicitly, otherwise an exception + dnl NSInvalidArgumentException "unrecognized selector sent to instance" + dnl occurs. +- INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation -Wl,-framework -Wl,CoreServices" ++ INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" + fi + AC_SUBST([INTL_MACOSX_LIBS]) + ]) +diff --git a/gcc/configure b/gcc/configure +index 23da7d55d..8bd09364d 100755 +--- a/gcc/configure ++++ b/gcc/configure +@@ -13932,7 +13932,7 @@ $as_echo "#define HAVE_CFLOCALECOPYPREFERREDLANGUAGES 1" >>confdefs.h + INTL_MACOSX_LIBS= + if test $gt_cv_func_CFPreferencesCopyAppValue = yes \ + || test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then +- INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation -Wl,-framework -Wl,CoreServices" ++ INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" + fi + + +diff --git a/libcpp/configure b/libcpp/configure +index 32d6aaa30..592c33881 100755 +--- a/libcpp/configure ++++ b/libcpp/configure +@@ -7570,7 +7570,7 @@ $as_echo "#define HAVE_CFLOCALECOPYPREFERREDLANGUAGES 1" >>confdefs.h + INTL_MACOSX_LIBS= + if test $gt_cv_func_CFPreferencesCopyAppValue = yes \ + || test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then +- INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation -Wl,-framework -Wl,CoreServices" ++ INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" + fi + + diff --git a/pkgs/development/compilers/gcc/patches/14/gnat-darwin-dylib-install-name-14.patch b/pkgs/development/compilers/gcc/patches/14/gnat-darwin-dylib-install-name-14.patch new file mode 100644 index 000000000000..195f7b10c348 --- /dev/null +++ b/pkgs/development/compilers/gcc/patches/14/gnat-darwin-dylib-install-name-14.patch @@ -0,0 +1,21 @@ +diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in +index 0666fc00b..0e2d53eb8 100644 +--- a/gcc/ada/gcc-interface/Makefile.in ++++ b/gcc/ada/gcc-interface/Makefile.in +@@ -793,14 +793,14 @@ gnatlib-shared-darwin: + -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ + $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \ + $(SO_OPTS) \ +- -Wl,-install_name,@rpath/libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ ++ -Wl,-install_name,$(ADA_RTL_DSO_DIR)/libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ + -nodefaultrpaths -Wl,-rpath,@loader_path/,-rpath,@loader_path/.. \ + -Wl,-rpath,@loader_path/../../../../ $(MISCLIB) + cd $(RTSDIR); $(GCC_FOR_ADA_RTS) -dynamiclib $(PICFLAG_FOR_TARGET) \ + -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ + $(GNATRTL_TASKING_OBJS) \ + $(SO_OPTS) \ +- -Wl,-install_name,@rpath/libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ ++ -Wl,-install_name,$(ADA_RTL_DSO_DIR)/libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ + -nodefaultrpaths -Wl,-rpath,@loader_path/,-rpath,@loader_path/.. \ + -Wl,-rpath,@loader_path/../../../../ \ + $(THREADSLIB) -Wl,libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) diff --git a/pkgs/development/compilers/gcc/patches/default.nix b/pkgs/development/compilers/gcc/patches/default.nix index eb38c3a1fe88..13b4bcbf6f8c 100644 --- a/pkgs/development/compilers/gcc/patches/default.nix +++ b/pkgs/development/compilers/gcc/patches/default.nix @@ -133,8 +133,12 @@ in # Fix detection of bootstrap compiler Ada support (cctools as) on Nix Darwin ++ optional (atLeast12 && stdenv.isDarwin && langAda) ./ada-cctools-as-detection-configure.patch +# Remove CoreServices on Darwin, as it is only needed for macOS SDK 14+ +++ optional (atLeast14 && stdenv.isDarwin && langAda) ../patches/14/gcc-darwin-remove-coreservices.patch + # Use absolute path in GNAT dylib install names on Darwin ++ optionals (stdenv.isDarwin && langAda) ({ + "14" = [ ../patches/14/gnat-darwin-dylib-install-name-14.patch ]; "13" = [ ./gnat-darwin-dylib-install-name-13.patch ]; "12" = [ ./gnat-darwin-dylib-install-name.patch ]; }.${majorVersion} or [])