summary refs log tree commit diff
path: root/pkgs/stdenv
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2021-08-22 19:39:47 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2022-02-27 10:25:33 +0100
commit7459a4021cb33d71598f0cbf8c798f9168638d3f (patch)
tree25b7df599db76f068d6a7126cc48896130ba2859 /pkgs/stdenv
parent97acaf6d65e869abf7dc9e6825aef4c0e7b98432 (diff)
downloadnixpkgs-7459a4021cb33d71598f0cbf8c798f9168638d3f.tar
nixpkgs-7459a4021cb33d71598f0cbf8c798f9168638d3f.tar.gz
nixpkgs-7459a4021cb33d71598f0cbf8c798f9168638d3f.tar.bz2
nixpkgs-7459a4021cb33d71598f0cbf8c798f9168638d3f.tar.lz
nixpkgs-7459a4021cb33d71598f0cbf8c798f9168638d3f.tar.xz
nixpkgs-7459a4021cb33d71598f0cbf8c798f9168638d3f.tar.zst
nixpkgs-7459a4021cb33d71598f0cbf8c798f9168638d3f.zip
stdenv-bootstrap: force using new libc from stage2
This fix is needed to work around linker-errors such as

    undefined reference to `__libc_csu_fini'

which I got in almost every derivation which is part of stage2. The
reasoning behind this is that the startup-code was simplified[1] and
thus `__libc_csu_fini` doesn't exist anymore.

A workable solution is to use a newer libc which properly links in
stage3. And actually this seems expected given the rationale for stage3:

    # 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.

So this patch basically overrides the libraries inside `gcc-unwrapped` -
which is basically the bootstrap tools and thus also contains the libc
used in stage3 - with the shared objects from the freshly built libc
from stage2.

[1] https://sourceware.org/pipermail/libc-alpha/2021-March/123079.html
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r--pkgs/stdenv/linux/default.nix15
1 files changed, 14 insertions, 1 deletions
diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix
index d2c28b97ff9..e20ea9e1686 100644
--- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -230,7 +230,7 @@ in
     overrides = self: super: {
       inherit (prevStage)
         ccWrapperStdenv
-        gcc-unwrapped coreutils gnugrep
+        coreutils gnugrep
         perl gnum4 bison;
       dejagnu = super.dejagnu.overrideAttrs (a: { doCheck = false; } );
 
@@ -254,6 +254,19 @@ in
         '';
       });
 
+      gcc-unwrapped = self.stdenvNoCC.mkDerivation {
+        inherit (prevStage.gcc-unwrapped) name;
+        dontUnpack = true;
+        dontBuild = true;
+        installPhase = ''
+          mkdir -p $out
+          cp -ar ${prevStage.gcc-unwrapped}/* $out/
+          chmod -R a+w $out/
+          cp -a ${getLibc self}/lib/* $out/lib/
+          chmod -R a-w $out/
+        '';
+      };
+
       # This also contains the full, dynamically linked, final Glibc.
       binutils = prevStage.binutils.override {
         # Rewrap the binutils with the new glibc, so both the next