diff --git a/pkgs/development/compilers/gcc/10/default.nix b/pkgs/development/compilers/gcc/10/default.nix index c265fff2215f..3a3820ff1e77 100644 --- a/pkgs/development/compilers/gcc/10/default.nix +++ b/pkgs/development/compilers/gcc/10/default.nix @@ -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; diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index 957c85cfde56..4ed41ba3ca1c 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -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; diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix index 5d30f80edb2d..0eb0a85eaff5 100644 --- a/pkgs/development/compilers/gcc/4.9/default.nix +++ b/pkgs/development/compilers/gcc/4.9/default.nix @@ -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; diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index 0ac54e093b4f..32a4ad0dd090 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -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; diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 233d022514e0..33edc81ce539 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -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; diff --git a/pkgs/development/compilers/gcc/8/default.nix b/pkgs/development/compilers/gcc/8/default.nix index e90e6e69de34..dae98afccb90 100644 --- a/pkgs/development/compilers/gcc/8/default.nix +++ b/pkgs/development/compilers/gcc/8/default.nix @@ -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; diff --git a/pkgs/development/compilers/gcc/9/default.nix b/pkgs/development/compilers/gcc/9/default.nix index 188da39e23c7..ebe20e0cba5c 100644 --- a/pkgs/development/compilers/gcc/9/default.nix +++ b/pkgs/development/compilers/gcc/9/default.nix @@ -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; diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index f753af499267..13003a449860 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -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 ] ++ diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1b13d81e17b3..d683256588f3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10280,9 +10280,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; @@ -10295,6 +10302,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 @@ -10359,8 +10368,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 @@ -10378,8 +10389,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; @@ -10392,8 +10403,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; @@ -10406,8 +10417,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; @@ -10425,8 +10436,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; @@ -10440,8 +10451,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; @@ -10455,8 +10466,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; @@ -10469,8 +10480,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;