From 5d70abeacac94725bdaae5be8d32c9a50096571e Mon Sep 17 00:00:00 2001 From: silvanshade Date: Thu, 11 Apr 2024 15:06:25 -0600 Subject: [PATCH] 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 // {