···304 binutils coreutils gnugrep
305 perl patchelf linuxHeaders gnum4 bison libidn2 libunistring;
306 ${localSystem.libc} = getLibc prevStage;
307- # Link GCC statically against GMP etc. This makes sense because
308- # these builds of the libraries are only used by GCC, so it
309- # reduces the size of the stdenv closure.
310- gmp = super.gmp.override { stdenv = self.makeStaticLibraries self.stdenv; };
311- mpfr = super.mpfr.override { stdenv = self.makeStaticLibraries self.stdenv; };
312- libmpc = super.libmpc.override { stdenv = self.makeStaticLibraries self.stdenv; };
313- isl_0_20 = super.isl_0_20.override { stdenv = self.makeStaticLibraries self.stdenv; };
314- gcc-unwrapped = super.gcc-unwrapped.override {
315- isl = isl_0_20;
000316 # Use a deterministically built compiler
317 # see https://github.com/NixOS/nixpkgs/issues/108475 for context
318 reproducibleBuild = true;
···336 # because gcc (since JAR support) already depends on zlib, and
337 # then if we already have a zlib we want to use that for the
338 # other purposes (binutils and top-level pkgs) too.
339- inherit (prevStage) gettext gnum4 bison gmp perl texinfo zlib linuxHeaders libidn2 libunistring;
340 ${localSystem.libc} = getLibc prevStage;
341 binutils = super.binutils.override {
342 # Don't use stdenv's shell but our own
···346 inherit (prevStage) stdenv;
347 };
348 };
00000000349350 gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) {
351 nativeTools = false;
···417 # Simple executable tools
418 concatMap (p: [ (getBin p) (getLib p) ]) [
419 gzip bzip2 xz bash binutils.bintools coreutils diffutils findutils
420- gawk gnumake gnused gnutar gnugrep gnupatch patchelf ed file
421 ]
422 # Library dependencies
423 ++ map getLib (
···304 binutils coreutils gnugrep
305 perl patchelf linuxHeaders gnum4 bison libidn2 libunistring;
306 ${localSystem.libc} = getLibc prevStage;
307+ gcc-unwrapped =
308+ let makeStaticLibrariesAndMark = pkg:
309+ lib.makeOverridable (pkg.override { stdenv = self.makeStaticLibraries self.stdenv; })
310+ .overrideAttrs (a: { pname = "${a.pname}-stage3"; });
311+ in super.gcc-unwrapped.override {
312+ # Link GCC statically against GMP etc. This makes sense because
313+ # these builds of the libraries are only used by GCC, so it
314+ # reduces the size of the stdenv closure.
315+ gmp = makeStaticLibrariesAndMark super.gmp;
316+ mpfr = makeStaticLibrariesAndMark super.mpfr;
317+ libmpc = makeStaticLibrariesAndMark super.libmpc;
318+ isl = makeStaticLibrariesAndMark super.isl_0_20;
319 # Use a deterministically built compiler
320 # see https://github.com/NixOS/nixpkgs/issues/108475 for context
321 reproducibleBuild = true;
···339 # because gcc (since JAR support) already depends on zlib, and
340 # then if we already have a zlib we want to use that for the
341 # other purposes (binutils and top-level pkgs) too.
342+ inherit (prevStage) gettext gnum4 bison perl texinfo zlib linuxHeaders libidn2 libunistring;
343 ${localSystem.libc} = getLibc prevStage;
344 binutils = super.binutils.override {
345 # Don't use stdenv's shell but our own
···349 inherit (prevStage) stdenv;
350 };
351 };
352+353+ # force gmp to rebuild so we have the option of dynamically linking
354+ # libgmp without creating a reference path from:
355+ # stage5.gcc -> stage4.coreutils -> stage3.glibc -> bootstrap
356+ gmp = lib.makeOverridable (super.gmp.override { stdenv = self.stdenv; }).overrideAttrs (a: { pname = "${a.pname}-stage4"; });
357+358+ # coreutils gets rebuilt both here and also in the final stage; we rename this one to avoid confusion
359+ coreutils = super.coreutils.overrideAttrs (a: { pname = "${a.pname}-stage4"; });
360361 gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) {
362 nativeTools = false;
···428 # Simple executable tools
429 concatMap (p: [ (getBin p) (getLib p) ]) [
430 gzip bzip2 xz bash binutils.bintools coreutils diffutils findutils
431+ gawk gmp gnumake gnused gnutar gnugrep gnupatch patchelf ed file
432 ]
433 # Library dependencies
434 ++ map getLib (