This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: PR target/18153: [3.4/4.0 Regression] -static-libgcc links in libunwind.so.7
- From: "H. J. Lu" <hjl at lucon dot org>
- To: Zack Weinberg <zack at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 26 Oct 2004 10:28:50 -0700
- Subject: Re: PATCH: PR target/18153: [3.4/4.0 Regression] -static-libgcc links in libunwind.so.7
- References: <20041026010623.GA4572@lucon.org> <87lldtdhk0.fsf@codesourcery.com>
On Tue, Oct 26, 2004 at 01:12:15AM -0700, Zack Weinberg wrote:
> "H. J. Lu" <hjl@lucon.org> writes:
>
> > We just pass --as-needed/--no-as-needed to ld for -lunwind if they
> > are available.
>
> Quit trying to hack around the basic bug and MAKE --as-needed THE
> DEFAULT ALREADY, the way it should have ALWAYS BEEN.
I am not totally against it. But that is not my call.
Here is another approach. We can use -Bstatic/-Bdynamic to link against
libunwind.a for -static-libgcc.
H.J.
----
2004-10-26 H.J. Lu <hongjiu.lu@intel.com>
PR target/18153
* configure.ac: Define HAVE_LD_STATIC_DYNAMIC if linker supports
-Bstatic/-Bdynamic option.
* config.in: Regenerated.
* configure: Likewise.
* gcc.c (init_spec): Pass -Bstatic/-Bdynamic to ld for static
-lunwind if possible.
--- gcc/config.in.static 2004-10-25 17:37:13.000000000 -0700
+++ gcc/config.in 2004-10-26 10:06:38.270754696 -0700
@@ -322,6 +322,9 @@
a read-write section. */
#undef HAVE_LD_RO_RW_SECTION_MIXING
+/* Define if your linker supports -Bstatic/-Bdynamic option. */
+#undef HAVE_LD_STATIC_DYNAMIC
+
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
--- gcc/configure.ac.static 2004-10-25 17:37:13.000000000 -0700
+++ gcc/configure.ac 2004-10-26 10:11:49.451512210 -0700
@@ -2645,6 +2645,25 @@ if test x"$gcc_cv_ld_pie" = xyes; then
fi
AC_MSG_RESULT($gcc_cv_ld_pie)
+AC_MSG_CHECKING(linker -Bstatic/-Bdynamic option)
+gcc_cv_ld_static_dynamic=no
+if test $in_tree_ld = yes ; then
+ if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 10; then
+ gcc_cv_ld_static_dynamic=yes
+ fi
+elif test x$gcc_cv_ld != x; then
+ # Check if linker supports -Bstatic/-Bdynamic option
+ if $gcc_cv_ld --help 2>/dev/null | grep -- -Bstatic > /dev/null \
+ && $gcc_cv_ld --help 2>/dev/null | grep -- -Bdynamic > /dev/null; then
+ gcc_cv_ld_static_dynamic=yes
+ fi
+fi
+if test x"$gcc_cv_ld_static_dynamic" = xyes; then
+ AC_DEFINE(HAVE_LD_STATIC_DYNAMIC, 1,
+[Define if your linker supports -Bstatic/-Bdynamic option.])
+fi
+AC_MSG_RESULT($gcc_cv_ld_pie)
+
if test x"$demangler_in_ld" = xyes; then
AC_MSG_CHECKING(linker --demangle support)
gcc_cv_ld_demangle=no
--- gcc/gcc.c.static 2004-09-08 08:17:29.000000000 -0700
+++ gcc/gcc.c 2004-10-26 10:21:48.880992852 -0700
@@ -1647,7 +1647,11 @@ init_spec (void)
"-lgcc",
"-lgcc_eh"
#ifdef USE_LIBUNWIND_EXCEPTIONS
+# ifdef HAVE_LD_STATIC_DYNAMIC
+ " %{!static:-Bstatic} -lunwind %{!static:-Bdynamic}"
+# else
" -lunwind"
+# endif
#endif
);