summary refs log tree commit diff
path: root/pkgs/stdenv/linux
diff options
context:
space:
mode:
authorRick van Schijndel <Mindavi@users.noreply.github.com>2022-06-30 07:44:05 +0200
committerGitHub <noreply@github.com>2022-06-30 07:44:05 +0200
commit2fcdf54568c719af09fe254fa7f3de372e38b682 (patch)
treeddb7b3e95b6de7f4c664043c3e0e4d82de2f7863 /pkgs/stdenv/linux
parent965570c2ea6185686815f3b79078601b5e4f0cb5 (diff)
parent02630180fad510ee877fa51112b7c7b230ef2f13 (diff)
downloadnixpkgs-2fcdf54568c719af09fe254fa7f3de372e38b682.tar
nixpkgs-2fcdf54568c719af09fe254fa7f3de372e38b682.tar.gz
nixpkgs-2fcdf54568c719af09fe254fa7f3de372e38b682.tar.bz2
nixpkgs-2fcdf54568c719af09fe254fa7f3de372e38b682.tar.lz
nixpkgs-2fcdf54568c719af09fe254fa7f3de372e38b682.tar.xz
nixpkgs-2fcdf54568c719af09fe254fa7f3de372e38b682.tar.zst
nixpkgs-2fcdf54568c719af09fe254fa7f3de372e38b682.zip
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
Diffstat (limited to 'pkgs/stdenv/linux')
-rw-r--r--pkgs/stdenv/linux/default.nix33
1 files changed, 22 insertions, 11 deletions
diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix
index 6475d7f2ca1..880286bbcd2 100644
--- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -304,15 +304,18 @@ in
         binutils coreutils gnugrep
         perl patchelf linuxHeaders gnum4 bison libidn2 libunistring;
       ${localSystem.libc} = getLibc prevStage;
-      # 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.
-      gmp = super.gmp.override { stdenv = self.makeStaticLibraries self.stdenv; };
-      mpfr = super.mpfr.override { stdenv = self.makeStaticLibraries self.stdenv; };
-      libmpc = super.libmpc.override { stdenv = self.makeStaticLibraries self.stdenv; };
-      isl_0_20 = super.isl_0_20.override { stdenv = self.makeStaticLibraries self.stdenv; };
-      gcc-unwrapped = super.gcc-unwrapped.override {
-        isl = isl_0_20;
+      gcc-unwrapped =
+        let makeStaticLibrariesAndMark = pkg:
+              lib.makeOverridable (pkg.override { stdenv = self.makeStaticLibraries self.stdenv; })
+                .overrideAttrs (a: { pname = "${a.pname}-stage3"; });
+        in super.gcc-unwrapped.override {
+        # 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.
+        gmp = makeStaticLibrariesAndMark super.gmp;
+        mpfr = makeStaticLibrariesAndMark super.mpfr;
+        libmpc = makeStaticLibrariesAndMark super.libmpc;
+        isl = makeStaticLibrariesAndMark super.isl_0_20;
         # Use a deterministically built compiler
         # see https://github.com/NixOS/nixpkgs/issues/108475 for context
         reproducibleBuild = true;
@@ -336,7 +339,7 @@ in
       # because gcc (since JAR support) already depends on zlib, and
       # then if we already have a zlib we want to use that for the
       # 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;
       binutils = super.binutils.override {
         # 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) {
         nativeTools = false;
         nativeLibc = false;
@@ -417,7 +428,7 @@ in
         # Simple executable tools
         concatMap (p: [ (getBin p) (getLib p) ]) [
             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
         ++ map getLib (