stdenv-bootstrap-tools: Fix lib*_asneeded problem on gcc16

GCC 16 added and starts using -latomic_asneeded and -lgcc_s_asneeded to
pull in the corresponding libraries as if --as-needed. Add these linker
scripts.

After fixing this, gcc in turn wants libatomic, so reuse the existing
line copying it for riscv, and use it for all platforms.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123650 for why this was
added.
This commit is contained in:
dramforever
2026-07-26 00:00:30 +08:00
parent a06d109d48
commit cd01953447

View File

@@ -135,6 +135,9 @@ stdenv.mkDerivation (finalAttrs: {
cp -d ${bootGCC.lib}/lib/libstdc++.so* $out/lib
cp -d ${bootGCC.out}/lib/libssp.a* $out/lib
cp -d ${bootGCC.out}/lib/libssp_nonshared.a $out/lib
cp -d ${bootGCC.lib}/lib/libgcc_s_asneeded.so $out/lib
cp -d ${bootGCC.lib}/lib/libatomic_asneeded.so $out/lib
cp -d ${bootGCC.out}/lib/libatomic.a* $out/lib
cp -rd ${bootGCC.out}/lib/gcc $out/lib
chmod -R u+w $out/lib
rm -f $out/lib/gcc/*/*/include*/linux
@@ -156,15 +159,6 @@ stdenv.mkDerivation (finalAttrs: {
cp -d ${mpfr.out}/lib/libmpfr*.so* $out/lib
cp -d ${libmpc.out}/lib/libmpc*.so* $out/lib
cp -d ${zlib.out}/lib/libz.so* $out/lib
''
+ lib.optionalString (stdenv.hostPlatform.isRiscV) ''
# libatomic is required on RiscV platform for C/C++ atomics and pthread
# even though they may be translated into native instructions.
cp -d ${bootGCC.out}/lib/libatomic.a* $out/lib
''
+ ''
cp -d ${bzip2.out}/lib/libbz2.so* $out/lib
# Copy binutils.