diff --git a/pkgs/development/compilers/gcc/10/default.nix b/pkgs/development/compilers/gcc/10/default.nix index 1502b09cca6a..65535af2d8e1 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 6a2121a82981..3f5687116d3b 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 709288559d1c..09c969fbb893 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 93c9dde61fc3..1100683a8237 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 d9b4c639b5ab..3c8ba292994d 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 6ecf462d54d9..a0d5680147b2 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 7f35f5c7bb99..fbcb1420df5c 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 167f108cddf0..fda927f2ea8b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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;