]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc.c (init_gcc_specs): If HAVE_LD_AS_NEEDED, link with -lgcc --as-needed -lgcc_s...
authorAlan Modra <amodra@bigpond.net.au>
Thu, 1 Apr 2004 16:55:23 +0000 (16:55 +0000)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 1 Apr 2004 16:55:23 +0000 (18:55 +0200)
* gcc.c (init_gcc_specs): If HAVE_LD_AS_NEEDED, link with
-lgcc --as-needed -lgcc_s --no-as-needed by default.
* configure.in (HAVE_LD_AS_NEEDED): Check for ld --as-needed.
* configure: Rebuilt.
* config.in: Rebuilt.
* Makefile.in (stage1-start): Copy also libgcc_s*$(SHLIB_EXT).
(stage2-start, stage3-start, stage4-start): Likewise.
(stageprofile-start, stagefeedback-start): Likewise.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r80304

gcc/ChangeLog
gcc/Makefile.in
gcc/config.in
gcc/configure
gcc/configure.in
gcc/gcc.c

index 08cb57f20adf73636dc125b9c684ebf66d1b4a7d..70da46697eed655e416ea120ee93923799248e6e 100644 (file)
@@ -1,3 +1,15 @@
+2004-04-01  Alan Modra  <amodra@bigpond.net.au>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.c (init_gcc_specs): If HAVE_LD_AS_NEEDED, link with
+       -lgcc --as-needed -lgcc_s --no-as-needed by default.
+       * configure.in (HAVE_LD_AS_NEEDED): Check for ld --as-needed.
+       * configure: Rebuilt.
+       * config.in: Rebuilt.
+       * Makefile.in (stage1-start): Copy also libgcc_s*$(SHLIB_EXT).
+       (stage2-start, stage3-start, stage4-start): Likewise.
+       (stageprofile-start, stagefeedback-start): Likewise.
+
 2004-04-01  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/14755
index e10f243b5baffe0c107da29eed3f15350d7a96c6..4d10ffbd7b557ad53bc94e00167a080262cc0b69 100644 (file)
@@ -3560,7 +3560,7 @@ stage1-start:
        -if [ -f as$(exeext) ] ; then (cd stage1 && $(LN_S) ../as$(exeext) .) ; else true ; fi
        -if [ -f ld$(exeext) ] ; then (cd stage1 && $(LN_S) ../ld$(exeext) .) ; else true ; fi
        -if [ -f collect-ld$(exeext) ] ; then (cd stage1 && $(LN_S) ../collect-ld$(exeext) .) ; else true ; fi
-       -rm -f stage1/libgcc.a stage1/libgcc_eh.a
+       -rm -f stage1/libgcc.a stage1/libgcc_eh.a stage1/libgcc_s*$(SHLIB_EXT)
        -cp libgcc.a stage1
        -if $(RANLIB_TEST_FOR_TARGET) ; then \
          $(RANLIB_FOR_TARGET) stage1/libgcc.a; \
@@ -3569,6 +3569,7 @@ stage1-start:
          if $(RANLIB_TEST_FOR_TARGET) ; then \
           $(RANLIB_FOR_TARGET) stage1/libgcc_eh.a; \
          else true; fi; fi
+       -cp libgcc_s*$(SHLIB_EXT) stage1/
        -for f in .. $(EXTRA_MULTILIB_PARTS); do if [ x$${f} != x.. ]; then \
          cp stage1/$${f} . ; \
        else true; \
@@ -3589,7 +3590,7 @@ stage2-start:
        -if [ -f as$(exeext) ] ; then (cd stage2 && $(LN_S) ../as$(exeext) .) ; else true ; fi
        -if [ -f ld$(exeext) ] ; then (cd stage2 && $(LN_S) ../ld$(exeext) .) ; else true ; fi
        -if [ -f collect-ld$(exeext) ] ; then (cd stage2 && $(LN_S) ../collect-ld$(exeext) .) ; else true ; fi
-       -rm -f stage2/libgcc.a stage2/libgcc_eh.a
+       -rm -f stage2/libgcc.a stage2/libgcc_eh.a stage2/libgcc_s*$(SHLIB_EXT)
        -cp libgcc.a stage2
        -if $(RANLIB_TEST_FOR_TARGET) ; then \
          $(RANLIB_FOR_TARGET) stage2/libgcc.a; \
@@ -3598,6 +3599,7 @@ stage2-start:
          if $(RANLIB_TEST_FOR_TARGET) ; then \
           $(RANLIB_FOR_TARGET) stage2/libgcc_eh.a; \
          else true; fi; fi
+       -cp libgcc_s*$(SHLIB_EXT) stage2/
        -for f in .. $(EXTRA_MULTILIB_PARTS); do if [ x$${f} != x.. ]; then \
          cp stage2/$${f} . ; \
        else true; \
@@ -3618,7 +3620,7 @@ stage3-start:
        -if [ -f as$(exeext) ] ; then (cd stage3 && $(LN_S) ../as$(exeext) .) ; else true ; fi
        -if [ -f ld$(exeext) ] ; then (cd stage3 && $(LN_S) ../ld$(exeext) .) ; else true ; fi
        -if [ -f collect-ld$(exeext) ] ; then (cd stage3 && $(LN_S) ../collect-ld$(exeext) .) ; else true ; fi
-       -rm -f stage3/libgcc.a stage3/libgcc_eh.a
+       -rm -f stage3/libgcc.a stage3/libgcc_eh.a stage3/libgcc_s*$(SHLIB_EXT)
        -cp libgcc.a stage3
        -if $(RANLIB_TEST_FOR_TARGET) ; then \
          $(RANLIB_FOR_TARGET) stage3/libgcc.a; \
@@ -3627,6 +3629,7 @@ stage3-start:
          if $(RANLIB_TEST_FOR_TARGET) ; then \
           $(RANLIB_FOR_TARGET) stage3/libgcc_eh.a; \
          else true; fi; fi
+       -cp libgcc_s*$(SHLIB_EXT) stage3/
        -for f in .. $(EXTRA_MULTILIB_PARTS); do if [ x$${f} != x.. ]; then \
          cp stage3/$${f} . ; \
        else true; \
@@ -3647,7 +3650,7 @@ stage4-start:
        -if [ -f as$(exeext) ] ; then (cd stage4 && $(LN_S) ../as$(exeext) .) ; else true ; fi
        -if [ -f ld$(exeext) ] ; then (cd stage4 && $(LN_S) ../ld$(exeext) .) ; else true ; fi
        -if [ -f collect-ld$(exeext) ] ; then (cd stage4 && $(LN_S) ../collect-ld$(exeext) .) ; else true ; fi
-       -rm -f stage4/libgcc.a stage4/libgcc_eh.a
+       -rm -f stage4/libgcc.a stage4/libgcc_eh.a stage4/libgcc_s*$(SHLIB_EXT)
        -cp libgcc.a stage4
        -if $(RANLIB_TEST_FOR_TARGET) ; then \
          $(RANLIB_FOR_TARGET) stage4/libgcc.a; \
@@ -3656,6 +3659,7 @@ stage4-start:
          if $(RANLIB_TEST_FOR_TARGET) ; then \
           $(RANLIB_FOR_TARGET) stage4/libgcc_eh.a; \
          else true; fi; fi
+       -cp libgcc_s*$(SHLIB_EXT) stage4/
        -for f in .. $(EXTRA_MULTILIB_PARTS); do if [ x$${f} != x.. ]; then \
          cp stage4/$${f} . ; \
        else true; \
index faa2f7828031045787f15e6e848363d6e03edf46..748e7afb1f60dbd83b01d624bf85a70d9da719db 100644 (file)
 /* Define if your linker supports --eh-frame-hdr option. */
 #undef HAVE_LD_EH_FRAME_HDR
 
+/* Define if your linker supports --as-needed and --no-as-needed options. */
+#undef HAVE_LD_AS_NEEDED
+
 /* Define if your MIPS libgloss linker scripts consistently include STARTUP directives. */
 #undef HAVE_MIPS_LIBGLOSS_STARTUP_DIRECTIVES
 
index 4e6d583046743c6030cdbcbde8d0bb0e069c16ae..729e4dbcc6333c4f49d7a2260da2878b9812f954 100755 (executable)
@@ -8119,6 +8119,27 @@ EOF
 fi
 echo "$ac_t""$gcc_cv_ld_eh_frame_hdr" 1>&6
 
+echo $ac_n "checking linker --as-needed support""... $ac_c" 1>&6
+echo "configure:8250: checking linker --as-needed support" >&5
+gcc_cv_ld_as_needed=no
+if test x$gcc_cv_gld_major_version != x -a x$gcc_cv_gld_minor_version != x; then
+  if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2 && grep 'EMUL = elf' ../ld/Makefile > /dev/null; then
+    gcc_cv_ld_as_needed=yes
+  fi
+elif test x$gcc_cv_ld != x; then
+       # Check if linker supports --as-needed and --no-as-needed options
+       if $gcc_cv_ld --help 2>/dev/null | grep as-needed > /dev/null; then
+               gcc_cv_ld_as_needed=yes
+       fi
+fi
+if test x"$gcc_cv_ld_as_needed" = xyes; then
+       cat >> confdefs.h <<\EOF
+#define HAVE_LD_AS_NEEDED 1
+EOF
+
+fi
+echo "$ac_t""$gcc_cv_ld_as_needed" 1>&6
+
 # Miscellaneous target-specific checks.
 case "$target" in
   mips*-*-*)
index 3858dc0901e48d3d116f9fb35e9e4b7e17904252..d3f0484020b0d3a1e3ed1cf25a659da424b32ebc 100644 (file)
@@ -2438,6 +2438,24 @@ if test x"$gcc_cv_ld_eh_frame_hdr" = xyes; then
 fi
 AC_MSG_RESULT($gcc_cv_ld_eh_frame_hdr)
 
+AC_MSG_CHECKING(linker --as-needed support)
+gcc_cv_ld_as_needed=no
+if test x$gcc_cv_gld_major_version != x -a x$gcc_cv_gld_minor_version != x; then
+  if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2 && grep 'EMUL = elf' ../ld/Makefile > /dev/null; then
+    gcc_cv_ld_as_needed=yes
+  fi
+elif test x$gcc_cv_ld != x; then
+       # Check if linker supports --as-needed and --no-as-needed options
+       if $gcc_cv_ld --help 2>/dev/null | grep as-needed > /dev/null; then
+               gcc_cv_ld_as_needed=yes
+       fi
+fi
+if test x"$gcc_cv_ld_as_needed" = xyes; then
+       AC_DEFINE(HAVE_LD_AS_NEEDED, 1,
+[Define if your linker supports --as-needed and --no-as-needed options.])
+fi
+AC_MSG_RESULT($gcc_cv_ld_as_needed)
+
 # Miscellaneous target-specific checks.
 case "$target" in
   mips*-*-*)
index 1de6e4264ff07bbc452eda28b4706232b42eed76..8753cd6c3c0beca83b20e6bb6ce2d8fcb89a648d 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1468,6 +1468,12 @@ init_gcc_specs (obstack, shared_name, static_name, eh_name)
 
   buf = concat ("%{static|static-libgcc:", static_name, " ", eh_name,
                "}%{!static:%{!static-libgcc:",
+#ifdef HAVE_LD_AS_NEEDED
+               "%{!shared-libgcc:", static_name,
+               " --as-needed ", shared_name, " --no-as-needed}"
+               "%{shared-libgcc:", shared_name, "%{!shared: ", static_name,
+               "}",
+#else
                "%{!shared:%{!shared-libgcc:", static_name, " ",
                eh_name, "}%{shared-libgcc:", shared_name, " ",
                static_name, "}}%{shared:",
@@ -1476,6 +1482,7 @@ init_gcc_specs (obstack, shared_name, static_name, eh_name)
                "}%{!shared-libgcc:", static_name, "}",
 #else
                shared_name,
+#endif
 #endif
                "}}}", NULL);