summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2023-02-22 22:30:29 -0800
committerAdam Joseph <adam@westernsemico.com>2023-04-02 13:49:53 -0700
commit5f57c2e0f97a83bf5691ac3a29da6ef9b44535c4 (patch)
tree0299bc9c124cdddbb1fb3c937f7d9aa3ad5e841b
parent96588eb3de55931e8b92a4f78f44342598f7ed5c (diff)
downloadnixpkgs-5f57c2e0f97a83bf5691ac3a29da6ef9b44535c4.tar
nixpkgs-5f57c2e0f97a83bf5691ac3a29da6ef9b44535c4.tar.gz
nixpkgs-5f57c2e0f97a83bf5691ac3a29da6ef9b44535c4.tar.bz2
nixpkgs-5f57c2e0f97a83bf5691ac3a29da6ef9b44535c4.tar.lz
nixpkgs-5f57c2e0f97a83bf5691ac3a29da6ef9b44535c4.tar.xz
nixpkgs-5f57c2e0f97a83bf5691ac3a29da6ef9b44535c4.tar.zst
nixpkgs-5f57c2e0f97a83bf5691ac3a29da6ef9b44535c4.zip
pkgs/test/stdenv/default.nix: add gcc-stageCompare
This commit adds a derivation `gcc-stageCompare` to
`pkgs/test/stdenv/default.nix`.

It is important to always build this derivation whenever building
`stdenv`!  Because we are using a Nix-driven bootstrap instead of
gcc's built-in `--enable-bootstrap`, the `gcc` derivation no longer
performs the post-self-compilation sanity check.  You must build
this derivation in order to perform that sanity check.

The major benefit of this new approach is that the sanity check
(which involves a third compilation of gcc) can be performed
*concurrently* with all packages that depend on `stdenv`, rather
than serially.  Since `stdenv` has very little derivation-level
parallelism it cannot take advantage of more than one or perhaps two
builders.  If you have three or more builders this commit will
reduce the time-to-rebuild-stdenv by around 20% (one of three gcc
rebuilds is removed from the critical path, and stdenv's build time
is dominated by roughly 3*gcc + 1*binutils + 1*bison-test-suite).

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
-rw-r--r--nixos/release-small.nix4
-rw-r--r--pkgs/development/compilers/gcc/common/checksum.nix1
-rw-r--r--pkgs/test/stdenv/gcc-stageCompare.nix32
-rw-r--r--pkgs/top-level/all-packages.nix2
-rw-r--r--pkgs/top-level/release-small.nix2
5 files changed, 39 insertions, 2 deletions
diff --git a/nixos/release-small.nix b/nixos/release-small.nix
index 7be300bbcf3..7659d61709a 100644
--- a/nixos/release-small.nix
+++ b/nixos/release-small.nix
@@ -81,7 +81,8 @@ in rec {
       stdenv
       subversion
       tarball
-      vim;
+      vim
+      tests-stdenv-gcc-stageCompare;
   };
 
   tested = let
@@ -131,6 +132,7 @@ in rec {
         "nixos.tests.proxy"
         "nixos.tests.simple"
         "nixpkgs.jdk"
+        "nixpkgs.tests-stdenv-gcc-stageCompare"
       ])
     ];
   };
diff --git a/pkgs/development/compilers/gcc/common/checksum.nix b/pkgs/development/compilers/gcc/common/checksum.nix
index 5251f40105c..b3e387b107b 100644
--- a/pkgs/development/compilers/gcc/common/checksum.nix
+++ b/pkgs/development/compilers/gcc/common/checksum.nix
@@ -3,6 +3,7 @@
 , nukeReferences
 , langC
 , langCC
+, runtimeShell
 }:
 
 let
diff --git a/pkgs/test/stdenv/gcc-stageCompare.nix b/pkgs/test/stdenv/gcc-stageCompare.nix
new file mode 100644
index 00000000000..e5c2ed5921b
--- /dev/null
+++ b/pkgs/test/stdenv/gcc-stageCompare.nix
@@ -0,0 +1,32 @@
+# This test *must* be run prior to releasing any build of either stdenv or the
+# gcc that it exports!  This check should also be part of CI for any PR that
+# causes a rebuild of `stdenv.cc`.
+#
+# When we used gcc's internal bootstrap it did this check as part of (and
+# serially with) the gcc derivation.  Now that we bootstrap externally this
+# check can be done in parallel with any/all of stdenv's referrers.  But we
+# must remember to do the check.
+#
+
+{ stdenv
+, pkgs
+, lib
+}:
+
+assert stdenv.cc.isGNU;
+with pkgs;
+# rebuild gcc using the "final" stdenv
+let gcc-stageCompare = (gcc-unwrapped.override {
+      reproducibleBuild = true;
+      profiledCompiler = false;
+      stdenv = overrideCC stdenv (wrapCCWith {
+        cc = stdenv.cc;
+      });
+    }).overrideAttrs(_: {
+      NIX_OUTPATH_USED_AS_RANDOM_SEED = stdenv.cc.cc.out;
+    });
+in (runCommand "gcc-stageCompare" {} ''
+  diff -sr ${pkgs.gcc-unwrapped.checksum}/checksums ${gcc-stageCompare.checksum}/checksums && touch $out
+'').overrideAttrs (a: {
+  meta = (a.meta or { }) // { platforms = lib.platforms.linux; };
+})
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 43e63c61191..c5749c18f55 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -33898,6 +33898,8 @@ with pkgs;
 
   testssl = callPackage ../applications/networking/testssl { };
 
+  tests-stdenv-gcc-stageCompare = callPackage ../test/stdenv/gcc-stageCompare.nix { };
+
   lavalauncher = callPackage ../applications/misc/lavalauncher { };
 
   t-rec = callPackage ../misc/t-rec {
diff --git a/pkgs/top-level/release-small.nix b/pkgs/top-level/release-small.nix
index 7bf4a234bb6..333e285cef0 100644
--- a/pkgs/top-level/release-small.nix
+++ b/pkgs/top-level/release-small.nix
@@ -150,5 +150,5 @@ with import ./release-lib.nix { inherit supportedSystems nixpkgsArgs; };
   xfsprogs = linux;
   xkeyboard_config = linux;
   zip = all;
-
+  tests-stdenv-gcc-stageCompare = all;
 } ))