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
This commit is contained in:
Rick van Schijndel 2022-06-30 07:44:05 +02:00 committed by GitHub
commit 2fcdf54568
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -304,15 +304,18 @@ in
binutils coreutils gnugrep binutils coreutils gnugrep
perl patchelf linuxHeaders gnum4 bison libidn2 libunistring; perl patchelf linuxHeaders gnum4 bison libidn2 libunistring;
${localSystem.libc} = getLibc prevStage; ${localSystem.libc} = getLibc prevStage;
# Link GCC statically against GMP etc. This makes sense because gcc-unwrapped =
# these builds of the libraries are only used by GCC, so it let makeStaticLibrariesAndMark = pkg:
# reduces the size of the stdenv closure. lib.makeOverridable (pkg.override { stdenv = self.makeStaticLibraries self.stdenv; })
gmp = super.gmp.override { stdenv = self.makeStaticLibraries self.stdenv; }; .overrideAttrs (a: { pname = "${a.pname}-stage3"; });
mpfr = super.mpfr.override { stdenv = self.makeStaticLibraries self.stdenv; }; in super.gcc-unwrapped.override {
libmpc = super.libmpc.override { stdenv = self.makeStaticLibraries self.stdenv; }; # Link GCC statically against GMP etc. This makes sense because
isl_0_20 = super.isl_0_20.override { stdenv = self.makeStaticLibraries self.stdenv; }; # these builds of the libraries are only used by GCC, so it
gcc-unwrapped = super.gcc-unwrapped.override { # reduces the size of the stdenv closure.
isl = isl_0_20; gmp = makeStaticLibrariesAndMark super.gmp;
mpfr = makeStaticLibrariesAndMark super.mpfr;
libmpc = makeStaticLibrariesAndMark super.libmpc;
isl = makeStaticLibrariesAndMark super.isl_0_20;
# Use a deterministically built compiler # Use a deterministically built compiler
# see https://github.com/NixOS/nixpkgs/issues/108475 for context # see https://github.com/NixOS/nixpkgs/issues/108475 for context
reproducibleBuild = true; reproducibleBuild = true;
@ -336,7 +339,7 @@ in
# because gcc (since JAR support) already depends on zlib, and # because gcc (since JAR support) already depends on zlib, and
# then if we already have a zlib we want to use that for the # then if we already have a zlib we want to use that for the
# other purposes (binutils and top-level pkgs) too. # other purposes (binutils and top-level pkgs) too.
inherit (prevStage) gettext gnum4 bison gmp perl texinfo zlib linuxHeaders libidn2 libunistring; inherit (prevStage) gettext gnum4 bison perl texinfo zlib linuxHeaders libidn2 libunistring;
${localSystem.libc} = getLibc prevStage; ${localSystem.libc} = getLibc prevStage;
binutils = super.binutils.override { binutils = super.binutils.override {
# Don't use stdenv's shell but our own # Don't use stdenv's shell but our own
@ -347,6 +350,14 @@ in
}; };
}; };
# force gmp to rebuild so we have the option of dynamically linking
# libgmp without creating a reference path from:
# stage5.gcc -> stage4.coreutils -> stage3.glibc -> bootstrap
gmp = lib.makeOverridable (super.gmp.override { stdenv = self.stdenv; }).overrideAttrs (a: { pname = "${a.pname}-stage4"; });
# coreutils gets rebuilt both here and also in the final stage; we rename this one to avoid confusion
coreutils = super.coreutils.overrideAttrs (a: { pname = "${a.pname}-stage4"; });
gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) { gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) {
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
@ -417,7 +428,7 @@ in
# Simple executable tools # Simple executable tools
concatMap (p: [ (getBin p) (getLib p) ]) [ concatMap (p: [ (getBin p) (getLib p) ]) [
gzip bzip2 xz bash binutils.bintools coreutils diffutils findutils gzip bzip2 xz bash binutils.bintools coreutils diffutils findutils
gawk gnumake gnused gnutar gnugrep gnupatch patchelf ed file gawk gmp gnumake gnused gnutar gnugrep gnupatch patchelf ed file
] ]
# Library dependencies # Library dependencies
++ map getLib ( ++ map getLib (