stdenv: provide a deterministically built gcc

Signed-off-by: Arthur Gautier <baloo@superbaloo.net>
This commit is contained in:
Arthur Gautier 2021-02-12 17:18:43 +00:00
parent 0d421066dd
commit a961aeadae
9 changed files with 67 additions and 17 deletions

View File

@ -4,6 +4,7 @@
, langObjC ? stdenv.targetPlatform.isDarwin
, langObjCpp ? stdenv.targetPlatform.isDarwin
, langGo ? false
, reproducibleBuild ? true
, profiledCompiler ? false
, langJit ? false
, staticCompiler ? false
@ -48,6 +49,10 @@ assert langAda -> gnatboot != null;
# threadsCross is just for MinGW
assert threadsCross != null -> stdenv.targetPlatform.isWindows;
# profiledCompiler builds inject non-determinism in one of the compilation stages.
# If turned on, we can't provide reproducible builds anymore
assert reproducibleBuild -> profiledCompiler == false;
with lib;
with builtins;

View File

@ -4,6 +4,7 @@
, langObjCpp ? stdenv.targetPlatform.isDarwin
, langJava ? false
, langGo ? false
, reproducibleBuild ? true
, profiledCompiler ? false
, langJit ? false
, staticCompiler ? false
@ -58,6 +59,10 @@ assert langGo -> langCC;
# threadsCross is just for MinGW
assert threadsCross != null -> stdenv.targetPlatform.isWindows;
# profiledCompiler builds inject non-determinism in one of the compilation stages.
# If turned on, we can't provide reproducible builds anymore
assert reproducibleBuild -> profiledCompiler == false;
with lib;
with builtins;

View File

@ -4,6 +4,7 @@
, langObjCpp ? stdenv.targetPlatform.isDarwin
, langJava ? false
, langGo ? false
, reproducibleBuild ? true
, profiledCompiler ? false
, langJit ? false
, staticCompiler ? false
@ -58,6 +59,10 @@ assert langGo -> langCC;
# threadsCross is just for MinGW
assert threadsCross != null -> stdenv.targetPlatform.isWindows;
# profiledCompiler builds inject non-determinism in one of the compilation stages.
# If turned on, we can't provide reproducible builds anymore
assert reproducibleBuild -> profiledCompiler == false;
with lib;
with builtins;

View File

@ -5,6 +5,7 @@
, langObjCpp ? stdenv.targetPlatform.isDarwin
, langJava ? false
, langGo ? false
, reproducibleBuild ? true
, profiledCompiler ? false
, langJit ? false
, staticCompiler ? false
@ -61,6 +62,10 @@ assert langAda -> gnatboot != null;
# threadsCross is just for MinGW
assert threadsCross != null -> stdenv.targetPlatform.isWindows;
# profiledCompiler builds inject non-determinism in one of the compilation stages.
# If turned on, we can't provide reproducible builds anymore
assert reproducibleBuild -> profiledCompiler == false;
with lib;
with builtins;

View File

@ -3,6 +3,7 @@
, langObjC ? stdenv.targetPlatform.isDarwin
, langObjCpp ? stdenv.targetPlatform.isDarwin
, langGo ? false
, reproducibleBuild ? true
, profiledCompiler ? false
, langJit ? false
, staticCompiler ? false
@ -45,6 +46,10 @@ assert langGo -> langCC;
# threadsCross is just for MinGW
assert threadsCross != null -> stdenv.targetPlatform.isWindows;
# profiledCompiler builds inject non-determinism in one of the compilation stages.
# If turned on, we can't provide reproducible builds anymore
assert reproducibleBuild -> profiledCompiler == false;
with lib;
with builtins;

View File

@ -3,6 +3,7 @@
, langObjC ? stdenv.targetPlatform.isDarwin
, langObjCpp ? stdenv.targetPlatform.isDarwin
, langGo ? false
, reproducibleBuild ? true
, profiledCompiler ? false
, langJit ? false
, staticCompiler ? false
@ -45,6 +46,10 @@ assert langGo -> langCC;
# threadsCross is just for MinGW
assert threadsCross != null -> stdenv.targetPlatform.isWindows;
# profiledCompiler builds inject non-determinism in one of the compilation stages.
# If turned on, we can't provide reproducible builds anymore
assert reproducibleBuild -> profiledCompiler == false;
with lib;
with builtins;

View File

@ -5,6 +5,7 @@
, langObjCpp ? stdenv.targetPlatform.isDarwin
, langD ? false
, langGo ? false
, reproducibleBuild ? true
, profiledCompiler ? false
, langJit ? false
, staticCompiler ? false
@ -54,6 +55,10 @@ assert langAda -> gnatboot != null;
# threadsCross is just for MinGW
assert threadsCross != null -> stdenv.targetPlatform.isWindows;
# profiledCompiler builds inject non-determinism in one of the compilation stages.
# If turned on, we can't provide reproducible builds anymore
assert reproducibleBuild -> profiledCompiler == false;
with lib;
with builtins;

View File

@ -274,6 +274,10 @@ in
isl_0_20 = super.isl_0_20.override { stdenv = self.makeStaticLibraries self.stdenv; };
gcc-unwrapped = super.gcc-unwrapped.override {
isl = isl_0_20;
# Use a deterministically built compiler
# see https://github.com/NixOS/nixpkgs/issues/108475 for context
reproducibleBuild = true;
profiledCompiler = false;
};
};
extraNativeBuildInputs = [ prevStage.patchelf ] ++

View File

@ -9799,9 +9799,16 @@ in
if stdenv.targetPlatform.isAarch64 then gcc9 else gcc10;
gcc-unwrapped = gcc.cc;
wrapNonDeterministicGcc = stdenv: ccWrapper:
if ccWrapper.isGNU then ccWrapper.overrideAttrs(old: {
cc = old.cc.override {
reproducibleBuild = false;
profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
};
}) else ccWrapper;
gccStdenv = if stdenv.cc.isGNU then stdenv else stdenv.override {
allowedRequisites = null;
cc = gcc;
# Remove libcxx/libcxxabi, and add clang for AS if on darwin (it uses
# clang's internal assembler).
extraBuildInputs = lib.optional stdenv.hostPlatform.isDarwin clang.cc;
@ -9814,6 +9821,8 @@ in
gcc9Stdenv = overrideCC gccStdenv buildPackages.gcc9;
gcc10Stdenv = overrideCC gccStdenv buildPackages.gcc10;
fastStdenv = overrideCC gccStdenv (wrapNonDeterministicGcc gccStdenv buildPackages.gcc10);
wrapCCMulti = cc:
if stdenv.targetPlatform.system == "x86_64-linux" then let
# Binutils with glibc multi
@ -9878,8 +9887,10 @@ in
cc = gccFun {
# copy-pasted
inherit noSysDirs;
# PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
reproducibleBuild = true;
profiledCompiler = false;
isl = if !stdenv.isDarwin then isl_0_20 else null;
# just for stage static
@ -9897,8 +9908,8 @@ in
gcc48 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/4.8 {
inherit noSysDirs;
# PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
profiledCompiler = with stdenv; (!isSunOS && !isDarwin && (isi686 || isx86_64));
reproducibleBuild = true;
profiledCompiler = false;
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else null;
@ -9911,8 +9922,8 @@ in
gcc49 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/4.9 {
inherit noSysDirs;
# PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
reproducibleBuild = true;
profiledCompiler = false;
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else null;
@ -9925,8 +9936,8 @@ in
gcc6 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/6 {
inherit noSysDirs;
# PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
reproducibleBuild = true;
profiledCompiler = false;
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else null;
@ -9944,8 +9955,8 @@ in
gcc7 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/7 {
inherit noSysDirs;
# PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
reproducibleBuild = true;
profiledCompiler = false;
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else null;
@ -9959,8 +9970,8 @@ in
gcc8 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/8 {
inherit noSysDirs;
# PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
reproducibleBuild = true;
profiledCompiler = false;
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else null;
@ -9974,8 +9985,8 @@ in
gcc9 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/9 {
inherit noSysDirs;
# PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
reproducibleBuild = true;
profiledCompiler = false;
enableLTO = !stdenv.isi686;
@ -9988,8 +9999,8 @@ in
gcc10 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/10 {
inherit noSysDirs;
# PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
reproducibleBuild = true;
profiledCompiler = false;
enableLTO = !stdenv.isi686;