From 5cba57c8166efc47b05f12f616ec7ab89291ef2f Mon Sep 17 00:00:00 2001 From: silvanshade Date: Thu, 11 Apr 2024 14:44:14 -0600 Subject: [PATCH 1/2] Add initial support for GCC 14 --- pkgs/development/compilers/gcc/common/dependencies.nix | 2 +- pkgs/development/compilers/gcc/default.nix | 4 ++++ pkgs/development/compilers/gcc/patches/default.nix | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/gcc/common/dependencies.nix b/pkgs/development/compilers/gcc/common/dependencies.nix index a38cdcb9e20f5..57d87d29d649d 100644 --- a/pkgs/development/compilers/gcc/common/dependencies.nix +++ b/pkgs/development/compilers/gcc/common/dependencies.nix @@ -50,7 +50,7 @@ in ] ++ optionals (perl != null) [ perl ] ++ optionals javaAwtGtk [ pkg-config ] - ++ optionals (with stdenv.targetPlatform; isVc4 || isRedox && flex != null) [ flex ] + ++ optionals (lib.versionAtLeast version "14" || (with stdenv.targetPlatform; isVc4 || isRedox && flex != null)) [ flex ] ++ optionals langAda [ gnat-bootstrap ] # The builder relies on GNU sed (for instance, Darwin's `sed' fails with # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it. diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index 0144ab4cfff9b..cad5006ccff2d 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -52,6 +52,7 @@ let version = versions.fromMajorMinor majorMinorVersion; majorVersion = lib.versions.major version; + atLeast14 = lib.versionAtLeast version "14"; atLeast13 = lib.versionAtLeast version "13"; atLeast12 = lib.versionAtLeast version "12"; atLeast11 = lib.versionAtLeast version "11"; @@ -61,6 +62,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"; @@ -221,6 +223,8 @@ let inherit version; url = "https://www.antlr.org/download/antlr-4.4-complete.jar"; sha256 = "02lda2imivsvsis8rnzmbrbp8rh1kb8vmq4i67pqhkwz7lf8y6dz"; }; + } // lib.optionalAttrs atLeast14 { + inherit flex; }); in diff --git a/pkgs/development/compilers/gcc/patches/default.nix b/pkgs/development/compilers/gcc/patches/default.nix index 8f0c8f6d288c8..9d260cb81e9b6 100644 --- a/pkgs/development/compilers/gcc/patches/default.nix +++ b/pkgs/development/compilers/gcc/patches/default.nix @@ -63,6 +63,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 ]; From 5d70abeacac94725bdaae5be8d32c9a50096571e Mon Sep 17 00:00:00 2001 From: silvanshade Date: Thu, 11 Apr 2024 15:06:25 -0600 Subject: [PATCH 2/2] Define gccFromSrc to allow building gcc from sources --- pkgs/development/compilers/gcc/default.nix | 12 +++++++--- pkgs/top-level/all-packages.nix | 28 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index cad5006ccff2d..0e0b7dcef3f37 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs +{ lib, stdenv, targetPackages, fetchFromGitHub, fetchurl, fetchpatch, noSysDirs , langC ? true, langCC ? true, langFortran ? false , langAda ? false , langObjC ? stdenv.targetPlatform.isDarwin @@ -45,11 +45,15 @@ , libXrender ? null, xorgproto ? null , libXrandr ? null, libXi ? null , x11Support ? langJava + +, gccSrc ? null }: let versions = import ./versions.nix; - version = versions.fromMajorMinor majorMinorVersion; + version = if gccSrc != null + then majorMinorVersion + else versions.fromMajorMinor majorMinorVersion; majorVersion = lib.versions.major version; atLeast14 = lib.versionAtLeast version "14"; @@ -236,7 +240,9 @@ lib.pipe ((callFile ./common/builder.nix {}) ({ pname = "${crossNameAddon}${name}"; inherit version; - src = if is6 && stdenv.targetPlatform.isVc4 then fetchFromGitHub { + src = if gccSrc != null + then gccSrc + else if is6 && stdenv.targetPlatform.isVc4 then fetchFromGitHub { owner = "itszor"; repo = "gcc-vc4"; rev = "e90ff43f9671c760cf0d1dd62f569a0fb9bf8918"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index cdaa063bcdd3e..5e5a03ec238c1 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15631,6 +15631,34 @@ with pkgs; gccFun = callPackage ../development/compilers/gcc; gcc-unwrapped = gcc.cc; + gccFromSrc = + let + noSysDirs' = noSysDirs; + in + lib.makeOverridable + ({ stdenv ? pkgs.stdenv + , src + , majorMinorVersion ? lib.fileContents "${src}/gcc/BASE-VER" + , noSysDirs ? noSysDirs' + , profiledCompiler ? false + , reproducibleBuild ? true + , libcCross ? if stdenv.targetPlatform != stdenv.buildPlatform then pkgs.libcCross else null + , threadsCross ? if stdenv.targetPlatform != stdenv.buildPlatform then pkgs.threadsCrossFor majorMinorVersion else { } + , cloog ? if stdenv.isDarwin + then null + else if lib.versionAtLeast majorMinorVersion "4.9" then cloog_0_18_0 + else pkgs.cloog + , isl ? if stdenv.isDarwin then null + else if lib.versionAtLeast majorMinorVersion "9" then isl_0_20 + else if lib.versionAtLeast majorMinorVersion "7" then isl_0_17 + else if lib.versionAtLeast majorMinorVersion "6" then (if stdenv.targetPlatform.isRedox then isl_0_17 else isl_0_14) + else if lib.versionAtLeast majorMinorVersion "4.9" then isl_0_11 + else /* "4.8" */ isl_0_14 + }: wrapCC (gccFun { + inherit stdenv majorMinorVersion noSysDirs profiledCompiler reproducibleBuild libcCross threadsCross cloog isl; + gccSrc = src; + })); + wrapNonDeterministicGcc = stdenv: ccWrapper: if ccWrapper.isGNU then ccWrapper.overrideAttrs(old: { env = old.env // {