-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bootstrap linux mixes crt1 from bootstrap libc and libc.so.6 from new libc, sometimes fails linking #158042
Comments
I think it happens mechanically because
|
|
How I understand the breakage:
The problem is that initial My understanding of the bootstrap sequence:
I think if we were to unconflate all 3 paths early by splitting Otherwise we can try to fix and maintain
|
Fixed ordering with proposed #158047. It does not fix glibc-2.35 yet, but I think it's an improvement. |
In NixOS#158042 I noticed order mismatch as a bootstrap build failure when building x86_64-linux against glibc-2.35 in nixpkgs (bootstrap libs has glibc-2.27): expand-response-params> ld: /nix/store/p4s4jf7aq6v6z9iazll1aiqwb34aqxq9-bootstrap-tools/lib/crt1.o: in function `_start': expand-response-params> /build/glibc-2.27/csu/../sysdeps/x86_64/start.S:101: undefined reference to `__libc_csu_fini' expand-response-params> ld: /build/glibc-2.27/csu/../sysdeps/x86_64/start.S:102: undefined reference to `__libc_csu_init' expand-response-params> collect2: error: ld returned 1 exit status Here crt1.o from glibc-2.27 links against libc.so.6 from glibc-2.35. This happens because ordering of `-L` (influences `libc.so` lookup) and `-B` (influences `crt1.o` lookup) flags differs: expand-response-params> -B/...-bootstrap-tools/lib expand-response-params> -B/...-glibc-2.35/lib/ ... expand-response-params> -L/...-glibc-2.35/lib expand-response-params> -L/...-bootstrap-tools/lib The change makes consistent ordering of `-L`/`-B` and allows getting to stage4 for `glibc-2.35` target.
slyfox explains it well in the linked bugs, but the gist is that we mostly got lucky for a while. We would mix system crt*.o with just-built libc_nonshared.a/libc.so which led to issues like: ``` configure:4383: x86_64-pc-linux-gnu-gcc -O2 -pipe -O2 -pipe -L/home/share/gentoo/usr/lib64 -Wl,--dynamic-linker=/home/share/gentoo/lib64/ld-linux-x86-64.so.2 conftest.c >&5 /home/share/gentoo/tmp/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /lib/../lib64/Scrt1.o: in function `_start': (.text+0x16): undefined reference to `__libc_csu_fini' /home/share/gentoo/tmp/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: (.text+0x1d): undefined reference to `__libc_csu_init' ``` We need to force GCC to use the Prefix version of glibc we just built. Bug: NixOS/nixpkgs#158042 Closes: https://bugs.gentoo.org/824482 Thanks-to: Bart Oldeman <[email protected]> Thanks-to: Sergei Trofimovich <[email protected]> Signed-off-by: Sam James <[email protected]>
The best way to show the problem is to try to build current nixpkgs against glibc.2.35, patch:
0001-glibc-2.33-2.35.patch.txtv2-0001-glibc-2.33-2.35.patch.txtIt fails to build simplest program as:
If I add a bit of debugging it becomes more clear where mismatch comes from:
My theory is that it was not visible before because until
glibc-2.35
crt1.o
did not change much. But upstream https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=035c012e32c11e84d64905efaf55e74f704d3668 change made it visible.The text was updated successfully, but these errors were encountered: