When configured to use gld, gcc has disabled the --as-needed option
as a workaround for binutils PR ld/12320:
[build] Fix Solaris --as-needed/-z ignore detection (PR target/57261)
https://gcc.gnu.org/legacy-ml/gcc-patches/2013-05/msg00698.html
gld would add an unnecessary dependency on libgcc_s.so.1 even though
--as-needed was used.
Back then, libgcc_s.so.1 wasn't bundled with Solaris, so even trivial
programs would fail to run unless linked with -R <libdir>.
This workaround is no longer necessary for several reasons:
* In Solaris 11, libgcc_s.so.1 is bundled, so there won't be runtime
failures.
* Although the problem occured more often on x86, Solaris/SPARC is
affected just the same. Nonetheless the workaround isn't used there.
* The gld bug has finally been fixed for binutils 2.47, so the issue is
going to vanish soon.
Therefore this patch removes the workaround, bringing x86 en par with
SPARC.
Bootstrapped without regressions on i386-pc-solaris2.11,
amd64-pc-solaris2.11, and x86_64-pc-linux-gnu.
Committed to trunk.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
2026-02-21 Rainer Orth <[email protected]>
gcc:
PR target/57261
* configure.ac (gcc_cv_ld_as_needed) <i?86-*-solaris2* |
x86_64-*-solaris2*>: Don't disable.
* configure: Regenerate.
# HG changeset patch
# Parent 5064938a39ffe0bbcad6e0c8d1de70c6b143a12a
Remove gld --as-needed workaround on Solaris/x86 [PR57261]
diff --git a/gcc/configure b/gcc/configure
--- a/gcc/configure
+++ b/gcc/configure
@@ -33220,15 +33220,6 @@ elif test x$gcc_cv_ld != x; then
;;
esac
fi
-case "$target" in
- i?86-*-solaris2* | x86_64-*-solaris2*)
- if echo "$ld_ver" | grep GNU > /dev/null; then
- # Doesn't work with gld on Solaris/x86 due to PR ld/12320.
- gcc_cv_ld_as_needed=no
- gcc_cv_ld_use_as_needed_ldscript=no
- fi
- ;;
-esac
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_as_needed" >&5
diff --git a/gcc/configure.ac b/gcc/configure.ac
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -6543,15 +6543,6 @@ elif test x$gcc_cv_ld != x; then
;;
esac
fi
-case "$target" in
- i?86-*-solaris2* | x86_64-*-solaris2*)
- if echo "$ld_ver" | grep GNU > /dev/null; then
- # Doesn't work with gld on Solaris/x86 due to PR ld/12320.
- gcc_cv_ld_as_needed=no
- gcc_cv_ld_use_as_needed_ldscript=no
- fi
- ;;
-esac
])
if test x"$gcc_cv_ld_as_needed" = xyes; then
AC_DEFINE(HAVE_LD_AS_NEEDED, 1,