From 5af8e1ffe055b8d23e5e23251f59d412c6d1ed9f Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Thu, 30 Apr 2026 21:00:58 +0100 Subject: [PATCH] gcc16, gccgo16, gfortran16, gnat16: init at 16.1.0 Changes: https://gcc.gnu.org/gcc-16/changes.html Porting guide: https://gcc.gnu.org/gcc-16/porting_to.html Added logic to avoid evaluation of gnatprove on gnat16, as it isn't ported to that compiler version yet. Co-authored-by: sempiternal-aurora <78790545+sempiternal-aurora@users.noreply.github.com> --- pkgs/by-name/gf/gfortran16/package.nix | 10 ++++ .../compilers/gcc/patches/default.nix | 10 ++++ pkgs/development/compilers/gcc/versions.nix | 2 + pkgs/top-level/ada-packages.nix | 11 +++-- pkgs/top-level/all-packages.nix | 48 ++++++++++++++++++- 5 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 pkgs/by-name/gf/gfortran16/package.nix diff --git a/pkgs/by-name/gf/gfortran16/package.nix b/pkgs/by-name/gf/gfortran16/package.nix new file mode 100644 index 000000000000..4236e7c7716a --- /dev/null +++ b/pkgs/by-name/gf/gfortran16/package.nix @@ -0,0 +1,10 @@ +{ wrapCC, gcc16 }: +wrapCC ( + gcc16.cc.override { + name = "gfortran"; + langFortran = true; + langCC = false; + langC = false; + profiledCompiler = false; + } +) diff --git a/pkgs/development/compilers/gcc/patches/default.nix b/pkgs/development/compilers/gcc/patches/default.nix index 17d8b9590ead..5be64c16ce84 100644 --- a/pkgs/development/compilers/gcc/patches/default.nix +++ b/pkgs/development/compilers/gcc/patches/default.nix @@ -58,6 +58,16 @@ optionals noSysDirs ( ] ++ ( { + "16" = [ + # Do not try looking for binaries and libraries in /lib and /usr/lib + ./13/no-sys-dirs-riscv.patch + # Mangle the nix store hash in __FILE__ to prevent unneeded runtime references + # + # TODO: Remove these and the `useMacroPrefixMap` conditional + # in `cc-wrapper` once + # is fixed. + ./13/mangle-NIX_STORE-in-__FILE__.patch + ]; "15" = [ # Do not try looking for binaries and libraries in /lib and /usr/lib ./13/no-sys-dirs-riscv.patch diff --git a/pkgs/development/compilers/gcc/versions.nix b/pkgs/development/compilers/gcc/versions.nix index 521d129bbb37..ca6b2c91033d 100644 --- a/pkgs/development/compilers/gcc/versions.nix +++ b/pkgs/development/compilers/gcc/versions.nix @@ -1,5 +1,6 @@ let majorMinorToVersionMap = { + "16" = "16.1.0"; "15" = "15.2.0"; "14" = "14.3.0"; "13" = "13.4.0"; @@ -13,6 +14,7 @@ let { # 3 digits: releases (14.2.0) # 4 digits: snapshots (14.2.1.20250322) + "16.1.0" = "sha256-UO+02Uwzl6/zsNYaWr10i03THZ0/Kre+BbFx02pRD3k="; "15.2.0" = "sha256-Q4/ZloJrDIJIWinaA6ctcdbjVBqD7HAt9Ccfb+Al0k4="; "14.3.0" = "sha256-4Nx3KXYlYxrI5Q+pL//v6Jmk63AlktpcMu8E4ik6yjo="; "13.4.0" = "sha256-nEzm27BAVo/cVFWIrAPFy8lajb8MeqSQFwhDr7WcqPU="; diff --git a/pkgs/top-level/ada-packages.nix b/pkgs/top-level/ada-packages.nix index 729e7045154c..1a4cf5f751c1 100644 --- a/pkgs/top-level/ada-packages.nix +++ b/pkgs/top-level/ada-packages.nix @@ -21,9 +21,14 @@ makeScopeWithSplicing' { xmlada = self.callPackage ../development/ada-modules/xmlada { }; - gnatprove = self.callPackage ../development/ada-modules/gnatprove { - ocamlPackages = pkgs.ocaml-ng.ocamlPackages_4_14; - }; + gnatprove = + # They haven't released a version of gnatprove for gnat16 yet + if lib.versionOlder gnat.version "16" then + self.callPackage ../development/ada-modules/gnatprove { + ocamlPackages = pkgs.ocaml-ng.ocamlPackages_4_14; + } + else + null; gnatcoll-core = self.callPackage ../development/ada-modules/gnatcoll/core.nix { }; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 151683a8a620..8db774fdc8df 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3739,6 +3739,7 @@ with pkgs; gcc13Stdenv = overrideCC gccStdenv buildPackages.gcc13; gcc14Stdenv = overrideCC gccStdenv buildPackages.gcc14; gcc15Stdenv = overrideCC gccStdenv buildPackages.gcc15; + gcc16Stdenv = overrideCC gccStdenv buildPackages.gcc16; # This is not intended for use in nixpkgs but for providing a faster-running # compiler to nixpkgs users by building gcc with reproducibility-breaking @@ -3841,9 +3842,10 @@ with pkgs; gcc13 gcc14 gcc15 + gcc16 ; - gcc_latest = gcc15; + gcc_latest = gcc16; libgccjit = gcc.cc.override { name = "libgccjit"; @@ -3941,6 +3943,34 @@ with pkgs; } ); + gnat16 = wrapCC ( + gcc16.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-bootstrap14 + else + buildPackages.gnat16; + stdenv = + if + stdenv.hostPlatform == stdenv.targetPlatform + && stdenv.buildPlatform == stdenv.hostPlatform + && stdenv.buildPlatform.isDarwin + && stdenv.buildPlatform.isx86_64 + then + overrideCC stdenv gnat-bootstrap14 + else + stdenv; + } + ); + gnat-bootstrap = gnat-bootstrap13; gnat-bootstrap13 = wrapCCWith ( { @@ -3962,6 +3992,7 @@ with pkgs; gnat13Packages = recurseIntoAttrs (callPackage ./ada-packages.nix { gnat = buildPackages.gnat13; }); gnat14Packages = recurseIntoAttrs (callPackage ./ada-packages.nix { gnat = buildPackages.gnat14; }); gnat15Packages = recurseIntoAttrs (callPackage ./ada-packages.nix { gnat = buildPackages.gnat15; }); + gnat16Packages = recurseIntoAttrs (callPackage ./ada-packages.nix { gnat = buildPackages.gnat16; }); gnatPackages = gnat13Packages; inherit (gnatPackages) @@ -4029,6 +4060,21 @@ with pkgs; } ); + gccgo16 = wrapCC ( + gcc16.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-mcode = ghdl.override { backend = "mcode"; }; ghdl-gcc = ghdl.override { backend = "gcc"; };