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
This commit is contained in:
Maximilian Bosch 2021-08-22 19:39:47 +02:00
parent 97acaf6d65
commit 7459a4021c
No known key found for this signature in database
GPG Key ID: 091DBF4D1FC46B8E

View File

@ -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