From cd01953447f1d35c6dcbb97451db1bd813c13cda Mon Sep 17 00:00:00 2001 From: dramforever Date: Sun, 26 Jul 2026 00:00:30 +0800 Subject: [PATCH] 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. --- pkgs/stdenv/linux/stdenv-bootstrap-tools.nix | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/pkgs/stdenv/linux/stdenv-bootstrap-tools.nix b/pkgs/stdenv/linux/stdenv-bootstrap-tools.nix index eb052a915ba2..7156fd7dba52 100644 --- a/pkgs/stdenv/linux/stdenv-bootstrap-tools.nix +++ b/pkgs/stdenv/linux/stdenv-bootstrap-tools.nix @@ -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.