anchor.diff:        nativeTools = false;
         nativeLibc = false;
         inherit gcc binutils coreutils libc name;
  -      stdenv = stdenvLinuxBoot0;
  +      stdenv = stage0.stdenv;
       };
   
   
     # Create the first "real" standard environment.  This one consists
     # of bootstrap tools only, and a minimal Glibc to keep the GCC
     # configure script happy.
  -  stdenvLinuxBoot1 = stdenvBootFun {
  +  stage1 = stageFun {
       gcc = wrapGCC {
         gcc = bootstrapTools;
  -      libc = bootstrapGlibc;
  +      libc = stage0.pkgs.glibc;
         binutils = bootstrapTools;
         coreutils = bootstrapTools;
         name = "bootstrap-gcc-wrapper";
       };
  -  };
  -
  -
  -  # 2) These are the packages that we can build with the first
  -  #    stdenv.  We only need binutils, because recent Glibcs
  -  #    require recent Binutils, and those in bootstrap-tools may
  -  #    be too old.
  -  stdenvLinuxBoot1Pkgs = allPackages {
  -    inherit system platform;
  -    bootStdenv = stdenvLinuxBoot1;
  -  };
  -
  -  binutils1 = stdenvLinuxBoot1Pkgs.binutils.override { gold = false; };
  -
  -
  -  # 3) 2nd stdenv that we will use to build only Glibc.
  -  stdenvLinuxBoot2 = stdenvBootFun {
  +    # Rebuild binutils to use from stage2 onwards.
  +    overrides = pkgs: {
  +      binutils = pkgs.binutils.override { gold = false; };
  +    };
  +  };
  +
  +
  +  # 2nd stdenv that contains our own rebuilt binutils and is used for
  +  # compiling our own Glibc.
  +  stage2 = stageFun {
       gcc = wrapGCC {
         gcc = bootstrapTools;
  -      libc = bootstrapGlibc;
  -      binutils = binutils1;
  +      libc = stage0.pkgs.glibc;
  +      binutils = stage1.pkgs.binutils;
         coreutils = bootstrapTools;
         name = "bootstrap-gcc-wrapper";
       };
       overrides = pkgs: {
  -      inherit (stdenvLinuxBoot1Pkgs) perl;
  -    };
  -  };
  -
  -
  -  # 4) These are the packages that we can build with the 2nd
  -  #    stdenv.
  -  stdenvLinuxBoot2Pkgs = allPackages {
  -    inherit system platform;
  -    bootStdenv = stdenvLinuxBoot2;
  -  };
  -
  -
  -  # 5) Build Glibc with the bootstrap tools.  The result is the full,
  -  #    dynamically linked, final Glibc.
  -  stdenvLinuxGlibc = stdenvLinuxBoot2Pkgs.glibc;
  -
  -
  -  # 6) Construct a third stdenv identical to the 2nd, except that this
  -  #    one uses the Glibc built in step 5.  It still uses the recent
  -  #    binutils and rest of the bootstrap tools, including GCC.
  -  stdenvLinuxBoot3 = stdenvBootFun {
  +      inherit (stage1.pkgs) perl;
  +      # This also contains the full, dynamically linked, final Glibc.
  +    };
  +  };
  +
  +
  +  # Construct a third stdenv identical to the 2nd, except that this
  +  # one uses the rebuilt Glibc from stage2.  It still uses the recent
  +  # binutils and rest of the bootstrap tools, including GCC.
  +  stage3 = stageFun {
       gcc = wrapGCC {
         gcc = bootstrapTools;
  -      libc = stdenvLinuxGlibc;
  -      binutils = binutils1;
  +      libc = stage2.pkgs.glibc;
  +      binutils = stage1.pkgs.binutils;
         coreutils = bootstrapTools;
         name = "bootstrap-gcc-wrapper";
       };
       overrides = pkgs: {
  -      glibc = stdenvLinuxGlibc;
  -      inherit (stdenvLinuxBoot1Pkgs) perl;
  +      inherit (stage2.pkgs) glibc perl;
         # Link GCC statically against GMP etc.  This makes sense because
         # these builds of the libraries are only used by GCC, so it
         # reduces the size of the stdenv closure.
  
positive.code:       '';
  
      initialPath =
        ((import ../common-path.nix) {pkgs = stdenvLinuxBoot4Pkgs;})
        ++ [stdenvLinuxBoot4Pkgs.patchelf stdenvLinuxBoot4Pkgs.paxctl ];
  
      shell = stdenvLinuxBoot4Pkgs.bash + "/bin/bash";
  
      gcc = (wrapGCC rec {
        gcc = stdenvLinuxBoot4.gcc.gcc;
        libc = stdenvLinuxGlibc;
        inherit (stdenvLinuxBoot4Pkgs) binutils coreutils;
        name = "";
      }).override { inherit shell; };
  
      fetchurlBoot = stdenvLinuxBoot0.fetchurlBoot;
  
      extraAttrs = {
        inherit (stdenvLinuxBoot3Pkgs) glibc;
        inherit platform bootstrapTools;
        shellPackage = stdenvLinuxBoot4Pkgs.bash;
      };
  
      overrides = pkgs: {
        inherit gcc;
        inherit (stdenvLinuxBoot3Pkgs) glibc;
        inherit (stdenvLinuxBoot4Pkgs) binutils;
        inherit (stdenvLinuxBoot4Pkgs)
          gzip bzip2 xz bash coreutils diffutils findutils gawk
          gnumake gnused gnutar gnugrep gnupatch patchelf
          attr acl paxctl;
  
negative.code:       ppl = pkgs.ppl.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
      };
      extraAttrs = {
        glibc = stage2.pkgs.glibc;  # Required by gcc47 build
      };
      extraPath = [ stage1.pkgs.paxctl ];
    };
  
  
    # Construct a fourth stdenv that uses the new GCC.  But coreutils is
    # still from the bootstrap tools.
    stage4 = stageFun {
      gcc = wrapGCC {
        gcc = stage3.pkgs.gcc.gcc;
        libc = stage2.pkgs.glibc;
        binutils = stage1.pkgs.binutils;
        coreutils = bootstrapTools;
        name = "";
      };
      extraPath = [ stage3.pkgs.xz ];
      overrides = pkgs: {
        inherit (stage1.pkgs) perl;
        inherit (stage3.pkgs) gettext gnum4 gmp glibc;
      };
    };
  
  
    # Construct the final stdenv.  It uses the Glibc and GCC, and adds
    # in a new binutils that doesn't depend on bootstrap-tools, as well
    # as dynamically linked versions of all other tools.
    #
    # When updating stdenvLinux, make sure that the result has no
    # dependency (`nix-store -qR') on bootstrapTools or the first
    # binutils built.
    stdenvLinux = import ../generic rec {
      inherit system config;
  
  