From 4357a6c3481d4ab2a32cc905480efdfaacec7937 Mon Sep 17 00:00:00 2001
From: Chris Demetriou <cgd@broadcom.com>
Date: Mon, 29 Jul 2002 22:07:27 +0000
Subject: [PATCH] configure.in (mips*-*-*): Add a test to see if MIPS libgloss
 linker scripts use STARTUP directives...

2002-07-29  Chris Demetriou  <cgd@broadcom.com>

        * configure.in (mips*-*-*): Add a test to see if MIPS libgloss
        linker scripts use STARTUP directives consistently.
        * configure: Regenerate.
        * config.in: Regenerate.
        * config/mips/elf.h (STARTFILE_SPEC): Define conditionally, based
        on whether HAVE_MIPS_LIBGLOSS_STARTUP_DIRECTIVES is defined.
        * config/mips/elf64.h (STARTFILE_SPEC): Likewise.
        * config/mips/isa3264.h (STARTFILE_SPEC): Do not redefine if
        HAVE_MIPS_LIBGLOSS_STARTUP_DIRECTIVES is set; the result
        will be the same.

From-SVN: r55851
---
 gcc/ChangeLog             | 13 +++++++++++++
 gcc/config.in             |  3 +++
 gcc/config/mips/elf.h     |  4 ++++
 gcc/config/mips/elf64.h   |  4 ++++
 gcc/config/mips/isa3264.h |  6 +++++-
 gcc/configure             | 35 ++++++++++++++++++++++++++++++++++-
 gcc/configure.in          | 30 ++++++++++++++++++++++++++++++
 7 files changed, 93 insertions(+), 2 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 668337eb8aa3..f1f8c1506c6a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2002-07-29  Chris Demetriou  <cgd@broadcom.com>
+
+	* configure.in (mips*-*-*): Add a test to see if MIPS libgloss
+	linker scripts use STARTUP directives consistently.
+	* configure: Regenerate.
+	* config.in: Regenerate.
+	* config/mips/elf.h (STARTFILE_SPEC): Define conditionally, based
+	on whether HAVE_MIPS_LIBGLOSS_STARTUP_DIRECTIVES is defined.
+	* config/mips/elf64.h (STARTFILE_SPEC): Likewise.
+	* config/mips/isa3264.h (STARTFILE_SPEC): Do not redefine if
+	HAVE_MIPS_LIBGLOSS_STARTUP_DIRECTIVES is set; the result
+	will be the same.
+
 2002-07-29  Aldy Hernandez  <aldyh@redhat.com>
 
 	* config/rs6000/rs6000.md ("cpu"): Add ppc8540 to attribute.
diff --git a/gcc/config.in b/gcc/config.in
index b46403279f76..de68c88b36d1 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -579,6 +579,9 @@
 /* Define if your linker supports --eh-frame-hdr option. */
 #undef HAVE_LD_EH_FRAME_HDR
 
+/* Define if your MIPS libgloss linker scripts consistently include STARTUP directives. */
+#undef HAVE_MIPS_LIBGLOSS_STARTUP_DIRECTIVES
+
 /* Define 0/1 to force the choice for exception handling model. */
 #undef CONFIG_SJLJ_EXCEPTIONS
 
diff --git a/gcc/config/mips/elf.h b/gcc/config/mips/elf.h
index c759f97e5447..b62bf3434097 100644
--- a/gcc/config/mips/elf.h
+++ b/gcc/config/mips/elf.h
@@ -255,7 +255,11 @@ void FN ()                                                            \
 #define LIB_SPEC ""
 
 #undef  STARTFILE_SPEC
+#ifdef HAVE_MIPS_LIBGLOSS_STARTUP_DIRECTIVES
+#define STARTFILE_SPEC "crti%O%s crtbegin%O%s"
+#else
 #define STARTFILE_SPEC "crti%O%s crtbegin%O%s %{!mno-crt0:crt0%O%s}"
+#endif
 
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC "crtend%O%s crtn%O%s"
diff --git a/gcc/config/mips/elf64.h b/gcc/config/mips/elf64.h
index 4fd74313ed0c..32116b7e641c 100644
--- a/gcc/config/mips/elf64.h
+++ b/gcc/config/mips/elf64.h
@@ -225,7 +225,11 @@ void FN ()                                                            \
 #define LIB_SPEC ""
 
 #undef  STARTFILE_SPEC
+#ifdef HAVE_MIPS_LIBGLOSS_STARTUP_DIRECTIVES
+#define STARTFILE_SPEC "crti%O%s crtbegin%O%s"
+#else
 #define STARTFILE_SPEC "crti%O%s crtbegin%O%s %{!mno-crt0:crt0%O%s}"
+#endif
 
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC "crtend%O%s crtn%O%s"
diff --git a/gcc/config/mips/isa3264.h b/gcc/config/mips/isa3264.h
index b7ab601cfec3..90525963a2bb 100644
--- a/gcc/config/mips/isa3264.h
+++ b/gcc/config/mips/isa3264.h
@@ -33,9 +33,13 @@ Boston, MA 02111-1307, USA.  */
 
 #include "mips/elf.h"
 
+#ifndef HAVE_MIPS_LIBGLOSS_STARTUP_DIRECTIVES
+/* Once HAVE_MIPS_LIBGLOSS_STARTUP_DIRECTIVES is always true, this code
+   can be GC'd.  */
 #if MIPS_ABI_DEFAULT == ABI_MEABI
 /* For MEABI, don't link with crt0 files, let the linker start files specify
    the appropriate crt0 file.  */
 #undef  STARTFILE_SPEC
-#define STARTFILE_SPEC "crti%O%s crtbegin%O%s %{!mno-crt0: }"
+#define STARTFILE_SPEC "crti%O%s crtbegin%O%s"
+#endif
 #endif
diff --git a/gcc/configure b/gcc/configure
index e980e137e80f..6c7824d85576 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -7917,6 +7917,39 @@ EOF
 fi
 echo "$ac_t""$gcc_cv_ld_eh_frame_hdr" 1>&6
 
+# Miscellaneous target-specific checks.
+case "$target" in
+  mips*-*-*)
+    echo $ac_n "checking whether libgloss uses STARTUP directives consistently""... $ac_c" 1>&6
+echo "configure:7925: checking whether libgloss uses STARTUP directives consistently" >&5
+    gcc_cv_mips_libgloss_startup=no
+    gcc_cv_libgloss_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/libgloss
+    if test "x$exec_prefix" = xNONE; then
+      if test "x$prefix" = xNONE; then
+        test_prefix=/usr/local
+      else
+        test_prefix=$prefix
+      fi
+    else
+      test_prefix=$exec_prefix
+    fi
+    for f in $gcc_cv_libgloss_srcdir/mips/idt.ld $test_prefix/$target_alias/lib/idt.ld
+    do
+      if grep '^STARTUP' $f > /dev/null 2>&1; then
+        gcc_cv_mips_libgloss_startup=yes
+        break
+      fi
+    done
+    if test x"$gcc_cv_mips_libgloss_startup" = xyes; then
+      cat >> confdefs.h <<\EOF
+#define HAVE_MIPS_LIBGLOSS_STARTUP_DIRECTIVES 1
+EOF
+
+    fi
+    echo "$ac_t""$gcc_cv_mips_libgloss_startup" 1>&6
+    ;;
+esac
+
 if test "$prefix" != "/usr" && test "$prefix" != "/usr/local" ; then
   cat >> confdefs.h <<EOF
 #define PREFIX_INCLUDE_DIR "$prefix/include"
@@ -8092,7 +8125,7 @@ fi
 
 
 echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
-echo "configure:8096: checking whether to enable maintainer-specific portions of Makefiles" >&5
+echo "configure:8129: checking whether to enable maintainer-specific portions of Makefiles" >&5
     # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
 if test "${enable_maintainer_mode+set}" = set; then
   enableval="$enable_maintainer_mode"
diff --git a/gcc/configure.in b/gcc/configure.in
index 74d8757b5ad8..5fbdcbca12f2 100644
--- a/gcc/configure.in
+++ b/gcc/configure.in
@@ -2172,6 +2172,36 @@ if test x"$gcc_cv_ld_eh_frame_hdr" = xyes; then
 fi
 AC_MSG_RESULT($gcc_cv_ld_eh_frame_hdr)
 
+# Miscellaneous target-specific checks.
+case "$target" in
+  mips*-*-*)
+    AC_MSG_CHECKING(whether libgloss uses STARTUP directives consistently)
+    gcc_cv_mips_libgloss_startup=no
+    gcc_cv_libgloss_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/libgloss
+    if test "x$exec_prefix" = xNONE; then
+      if test "x$prefix" = xNONE; then
+        test_prefix=/usr/local
+      else
+        test_prefix=$prefix
+      fi
+    else
+      test_prefix=$exec_prefix
+    fi
+    for f in $gcc_cv_libgloss_srcdir/mips/idt.ld $test_prefix/$target_alias/lib/idt.ld
+    do
+      if grep '^STARTUP' $f > /dev/null 2>&1; then
+        gcc_cv_mips_libgloss_startup=yes
+        break
+      fi
+    done
+    if test x"$gcc_cv_mips_libgloss_startup" = xyes; then
+      AC_DEFINE(HAVE_MIPS_LIBGLOSS_STARTUP_DIRECTIVES, 1,
+        [Define if your MIPS libgloss linker scripts consistently include STARTUP directives.])
+    fi
+    AC_MSG_RESULT($gcc_cv_mips_libgloss_startup)
+    ;;
+esac
+
 if test "$prefix" != "/usr" && test "$prefix" != "/usr/local" ; then
   AC_DEFINE_UNQUOTED(PREFIX_INCLUDE_DIR, "$prefix/include")
 fi
-- 
GitLab