diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 3d424c904ba48..fe46d2a1c26d7 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -82,20 +82,29 @@ rec { # This function builds the various standard environments used during # the bootstrap. stdenvBootFun = - {gcc, extraAttrs ? {}, overrides ? (pkgs: {}), extraPath ? [], fetchurl}: + {gcc, extraAttrs ? {}, overrides ? (pkgs: {}), extraPath ? [], fetchurl, + deterministic ? false, bootnum ? "", binutils}: import ../generic { inherit system config; - name = "stdenv-linux-boot"; + name = "stdenv-linux-boot" + bootnum; preHook = '' # Don't patch #!/interpreter because it leads to retained # dependencies on the bootstrapTools in the final stdenv. dontPatchShebangs=1 ${commonPreHook} + '' + + lib.optionalString deterministic '' + # Make "strip" produce deterministic output, by setting + # timestamps etc. to a fixed value. + commonStripFlags="--enable-deterministic-archives" ''; + shell = "${bootstrapTools}/bin/sh"; - initialPath = [bootstrapTools] ++ extraPath; + # We put binutils before bootstrapTools so that we gradually use less from bootstrapTools. + # Also, deterministic builds require a fresh binutils (strip). + initialPath = [binutils] ++ [bootstrapTools] ++ extraPath; fetchurlBoot = fetchurl; inherit gcc; # Having the proper 'platform' in all the stdenvs allows getting proper @@ -110,7 +119,9 @@ rec { # because we need a stdenv to build the GCC wrapper and fetchurl. stdenvLinuxBoot0 = stdenvBootFun { gcc = "/no-such-path"; + bootnum = "0"; fetchurl = null; + binutils = null; }; @@ -155,6 +166,10 @@ rec { binutils = bootstrapTools; coreutils = bootstrapTools; }; + bootnum = "1"; + # The bootstrap tools might not support a deterministic strip + deterministic = false; + binutils = bootstrapTools; inherit fetchurl; }; @@ -181,6 +196,9 @@ rec { overrides = pkgs: { inherit (stdenvLinuxBoot1Pkgs) perl; }; + bootnum = "2"; + deterministic = true; + binutils = binutils1; inherit fetchurl; }; @@ -223,6 +241,9 @@ rec { extraAttrs = { glibc = stdenvLinuxGlibc; # Required by gcc47 build }; + bootnum = "3"; + deterministic = true; + binutils = binutils1; inherit fetchurl; }; @@ -250,6 +271,9 @@ rec { inherit (stdenvLinuxBoot1Pkgs) perl; inherit (stdenvLinuxBoot3Pkgs) gettext gnum4 gmp; }; + bootnum = "4"; + deterministic = true; + binutils = binutils1; inherit fetchurl; };