Skip to content

Commit

Permalink
Define gccFromSrc to allow building gcc from sources
Browse files Browse the repository at this point in the history
  • Loading branch information
silvanshade committed Apr 12, 2024
1 parent 5cba57c commit 5d70abe
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkgs/development/compilers/gcc/default.nix
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
28 changes: 28 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 // {
Expand Down

0 comments on commit 5d70abe

Please sign in to comment.