Merge pull request #169378 from amjoseph-nixpkgs/stdenv-makeStaticLibraries-do-what-comment-says

stdenv: make stage3.{gmp,mpfr,mpc,isl} do what the comment says

authored by Rick van Schijndel and committed by GitHub 2fcdf545 965570c2

+22 -11
+22 -11
pkgs/stdenv/linux/default.nix
··· 304 304 binutils coreutils gnugrep 305 305 perl patchelf linuxHeaders gnum4 bison libidn2 libunistring; 306 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; 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; 316 319 # Use a deterministically built compiler 317 320 # see https://github.com/NixOS/nixpkgs/issues/108475 for context 318 321 reproducibleBuild = true; ··· 336 339 # because gcc (since JAR support) already depends on zlib, and 337 340 # then if we already have a zlib we want to use that for the 338 341 # other purposes (binutils and top-level pkgs) too. 339 - inherit (prevStage) gettext gnum4 bison gmp perl texinfo zlib linuxHeaders libidn2 libunistring; 342 + inherit (prevStage) gettext gnum4 bison perl texinfo zlib linuxHeaders libidn2 libunistring; 340 343 ${localSystem.libc} = getLibc prevStage; 341 344 binutils = super.binutils.override { 342 345 # Don't use stdenv's shell but our own ··· 346 349 inherit (prevStage) stdenv; 347 350 }; 348 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"; }); 349 360 350 361 gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) { 351 362 nativeTools = false; ··· 417 428 # Simple executable tools 418 429 concatMap (p: [ (getBin p) (getLib p) ]) [ 419 430 gzip bzip2 xz bash binutils.bintools coreutils diffutils findutils 420 - gawk gnumake gnused gnutar gnugrep gnupatch patchelf ed file 431 + gawk gmp gnumake gnused gnutar gnugrep gnupatch patchelf ed file 421 432 ] 422 433 # Library dependencies 423 434 ++ map getLib (