From be4e8b82f1d4e57cfc87759900e949ce9b4bb93a Mon Sep 17 00:00:00 2001
From: amodra <amodra@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 23 Apr 2004 02:16:26 +0000
Subject: [PATCH] 	* gcc.c (init_gcc_specs): Test USE_LD_AS_NEEDED, not
 HAVE_LD_AS_NEEDED. 	* config/linux.h (USE_LD_AS_NEEDED): Define. 	*
 gcc/config/alpha/linux.h (USE_LD_AS_NEEDED): Define. 	*
 gcc/config/arm/linux-elf.h (USE_LD_AS_NEEDED): Define. 	*
 gcc/config/rs6000/linux.h (USE_LD_AS_NEEDED): Define. 	*
 gcc/config/rs6000/linux64.h (USE_LD_AS_NEEDED): Define. 	*
 gcc/config/sh/linux.h (USE_LD_AS_NEEDED): Define. 	*
 gcc/config/sparc/linux.h (USE_LD_AS_NEEDED): Define. 	*
 gcc/config/sparc/linux64.h (USE_LD_AS_NEEDED): Define.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@81072 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog               | 12 ++++++++++++
 gcc/config/alpha/linux.h    |  8 +++++++-
 gcc/config/arm/linux-elf.h  |  5 +++++
 gcc/config/linux.h          |  7 ++++++-
 gcc/config/rs6000/linux.h   |  5 +++++
 gcc/config/rs6000/linux64.h |  5 +++++
 gcc/config/sh/linux.h       |  5 +++++
 gcc/config/sparc/linux.h    |  5 +++++
 gcc/config/sparc/linux64.h  |  5 +++++
 gcc/gcc.c                   |  7 ++++++-
 10 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e75c903e5df8..6c3d32791114 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+2004-04-23  Alan Modra  <amodra@bigpond.net.au>
+
+	* gcc.c (init_gcc_specs): Test USE_LD_AS_NEEDED, not HAVE_LD_AS_NEEDED.
+	* config/linux.h (USE_LD_AS_NEEDED): Define.
+	* gcc/config/alpha/linux.h (USE_LD_AS_NEEDED): Define.
+	* gcc/config/arm/linux-elf.h (USE_LD_AS_NEEDED): Define.
+	* gcc/config/rs6000/linux.h (USE_LD_AS_NEEDED): Define.
+	* gcc/config/rs6000/linux64.h (USE_LD_AS_NEEDED): Define.
+	* gcc/config/sh/linux.h (USE_LD_AS_NEEDED): Define.
+	* gcc/config/sparc/linux.h (USE_LD_AS_NEEDED): Define.
+	* gcc/config/sparc/linux64.h (USE_LD_AS_NEEDED): Define.
+
 2004-04-22  Per Bothner  <per@bothner.com>
 
 	* cppinit.c (cpp_read_main_file):  Return NULL rather than false.
diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h
index a4bc3d3e4a4b..e2a16dff3dba 100644
--- a/gcc/config/alpha/linux.h
+++ b/gcc/config/alpha/linux.h
@@ -1,6 +1,7 @@
 /* Definitions of target machine for GNU compiler,
    for Alpha Linux-based GNU systems.
-   Copyright (C) 1996, 1997, 1998, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 2002, 2003, 2004
+   Free Software Foundation, Inc.
    Contributed by Richard Henderson.
 
 This file is part of GCC.
@@ -70,6 +71,11 @@ Boston, MA 02111-1307, USA.  */
 #define LINK_GCC_C_SEQUENCE_SPEC \
   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
 
+/* Use --as-needed -lgcc_s for eh support.  */
+#ifdef HAVE_LD_AS_NEEDED
+#define USE_LD_AS_NEEDED 1
+#endif
+
 /* Do code reading to identify a signal frame, and set the frame
    state data appropriately.  See unwind-dw2.c for the structs.  */
 
diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h
index bbfcbeb33608..b4b389c1b7cd 100644
--- a/gcc/config/arm/linux-elf.h
+++ b/gcc/config/arm/linux-elf.h
@@ -126,3 +126,8 @@
 
 #define LINK_GCC_C_SEQUENCE_SPEC \
   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
+
+/* Use --as-needed -lgcc_s for eh support.  */
+#ifdef HAVE_LD_AS_NEEDED
+#define USE_LD_AS_NEEDED 1
+#endif
diff --git a/gcc/config/linux.h b/gcc/config/linux.h
index 0f7ba1777e8b..af7bf257ec4d 100644
--- a/gcc/config/linux.h
+++ b/gcc/config/linux.h
@@ -1,5 +1,5 @@
 /* Definitions for Linux-based GNU systems with ELF format
-   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2003
+   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2003, 2004
    Free Software Foundation, Inc.
    Contributed by Eric Youngdale.
    Modified for stabs-in-ELF by H.J. Lu (hjl@lucon.org).
@@ -117,6 +117,11 @@ Boston, MA 02111-1307, USA.  */
 #define LINK_GCC_C_SEQUENCE_SPEC \
   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
 
+/* Use --as-needed -lgcc_s for eh support.  */
+#ifdef HAVE_LD_AS_NEEDED
+#define USE_LD_AS_NEEDED 1
+#endif
+
 /* Determine whether the the entire c99 runtime
    is present in the runtime library.  */
 #ifndef USE_GNULIBC_1
diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h
index 892785d666dc..83aef83a387b 100644
--- a/gcc/config/rs6000/linux.h
+++ b/gcc/config/rs6000/linux.h
@@ -66,6 +66,11 @@
 #define LINK_GCC_C_SEQUENCE_SPEC \
   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
 
+/* Use --as-needed -lgcc_s for eh support.  */
+#ifdef HAVE_LD_AS_NEEDED
+#define USE_LD_AS_NEEDED 1
+#endif
+
 #undef  TARGET_VERSION
 #define TARGET_VERSION fprintf (stderr, " (PowerPC GNU/Linux)");
 
diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index 4fe419911c8c..a63cb5fcff17 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -548,6 +548,11 @@ while (0)
 #define LINK_GCC_C_SEQUENCE_SPEC \
   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
 
+/* Use --as-needed -lgcc_s for eh support.  */
+#ifdef HAVE_LD_AS_NEEDED
+#define USE_LD_AS_NEEDED 1
+#endif
+
 /* Do code reading to identify a signal frame, and set the frame
    state data appropriately.  See unwind-dw2.c for the structs.  */
 
diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h
index b2ad064f8b4b..b01b52d28db9 100644
--- a/gcc/config/sh/linux.h
+++ b/gcc/config/sh/linux.h
@@ -112,6 +112,11 @@ do { \
 #define LINK_GCC_C_SEQUENCE_SPEC \
   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
 
+/* Use --as-needed -lgcc_s for eh support.  */
+#ifdef HAVE_LD_AS_NEEDED
+#define USE_LD_AS_NEEDED 1
+#endif
+
 /* Output assembler code to STREAM to call the profiler.  */
 
 #undef FUNCTION_PROFILER
diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
index ecb473152ae7..107880f401d0 100644
--- a/gcc/config/sparc/linux.h
+++ b/gcc/config/sparc/linux.h
@@ -256,6 +256,11 @@ do {									\
 #define LINK_GCC_C_SEQUENCE_SPEC \
   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
 
+/* Use --as-needed -lgcc_s for eh support.  */
+#ifdef HAVE_LD_AS_NEEDED
+#define USE_LD_AS_NEEDED 1
+#endif
+
 /* Do code reading to identify a signal frame, and set the frame
    state data appropriately.  See unwind-dw2.c for the structs.  */
 
diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
index 9820156fd07d..09d14ae537a5 100644
--- a/gcc/config/sparc/linux64.h
+++ b/gcc/config/sparc/linux64.h
@@ -334,6 +334,11 @@ do {									\
 #define LINK_GCC_C_SEQUENCE_SPEC \
   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
 
+/* Use --as-needed -lgcc_s for eh support.  */
+#ifdef HAVE_LD_AS_NEEDED
+#define USE_LD_AS_NEEDED 1
+#endif
+
 /* Do code reading to identify a signal frame, and set the frame
    state data appropriately.  See unwind-dw2.c for the structs.  */
 
diff --git a/gcc/gcc.c b/gcc/gcc.c
index f9a4e1db3cd6..4e4f93b9ccd7 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1543,6 +1543,11 @@ static int processing_spec_function;
    various permutations of -shared-libgcc, -shared, and such.  */
 
 #if defined(ENABLE_SHARED_LIBGCC) && !defined(REAL_LIBGCC_SPEC)
+
+#ifndef USE_LD_AS_NEEDED
+#define USE_LD_AS_NEEDED 0
+#endif
+
 static void
 init_gcc_specs (struct obstack *obstack, const char *shared_name,
 		const char *static_name, const char *eh_name)
@@ -1551,7 +1556,7 @@ init_gcc_specs (struct obstack *obstack, const char *shared_name,
 
   buf = concat ("%{static|static-libgcc:", static_name, " ", eh_name,
 		"}%{!static:%{!static-libgcc:",
-#ifdef HAVE_LD_AS_NEEDED
+#if USE_LD_AS_NEEDED
 		"%{!shared-libgcc:", static_name,
 		" --as-needed ", shared_name, " --no-as-needed}"
 		"%{shared-libgcc:", shared_name, "%{!shared: ", static_name,
-- 
GitLab