From: H.J. Lu Date: Thu, 16 Dec 2004 00:15:03 +0000 (+0000) Subject: re PR target/18153 (-static-libgcc links in libunwind.so.7) X-Git-Tag: releases/gcc-3.4.4~403 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b653de60f7ae3560694cffb9132f200bad10dc14;p=thirdparty%2Fgcc.git re PR target/18153 (-static-libgcc links in libunwind.so.7) 2004-12-15 H.J. Lu 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. From-SVN: r92234 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2d64e510f8e3..2f3d990a3608 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2004-12-15 H.J. Lu + + 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. + 2004-12-15 Richard Henderson PR target/19010 diff --git a/gcc/config.in b/gcc/config.in index 4d0a2e1220e4..4d47fbea162a 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -319,6 +319,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 header file. */ #undef HAVE_LIMITS_H diff --git a/gcc/configure b/gcc/configure index 33a3877eb906..0232ac075660 100755 --- a/gcc/configure +++ b/gcc/configure @@ -11818,6 +11818,30 @@ fi echo "$as_me:$LINENO: result: $gcc_cv_ld_pie" >&5 echo "${ECHO_T}$gcc_cv_ld_pie" >&6 +echo "$as_me:$LINENO: checking linker -Bstatic/-Bdynamic option" >&5 +echo $ECHO_N "checking linker -Bstatic/-Bdynamic option... $ECHO_C" >&6 +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 + +cat >>confdefs.h <<\_ACEOF +#define HAVE_LD_STATIC_DYNAMIC 1 +_ACEOF + +fi +echo "$as_me:$LINENO: result: $gcc_cv_ld_static_dynamic" >&5 +echo "${ECHO_T}$gcc_cv_ld_static_dynamic" >&6 + case "$target" in *-*-linux*) echo "$as_me:$LINENO: checking linker --as-needed support" >&5 diff --git a/gcc/configure.ac b/gcc/configure.ac index 9b991edf9ccd..ec6942b43ec4 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2617,6 +2617,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_static_dynamic) + case "$target" in *-*-linux*) AC_CACHE_CHECK(linker --as-needed support, diff --git a/gcc/gcc.c b/gcc/gcc.c index dd69b6eb6d04..4e053b81f522 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -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 );