Just like the HAVE_GNU_AS case, the majority of HAVE_GNU_LD uses are in
Solaris-specific code to distinguish GNU ld from Solaris ld.  Again,
it's easier to turn the check around, checking for Solaris ld directly,
which this patch does.

Tested on sparcv9-sun-solaris2.11, amd64-pc-solaris2.11,
sparc64-unknown-linux-gnu, and x86_64-pc-linux-gnu.

Ok for trunk.

Also, like in the HAVE_GNU_AS case, only 3 (or 4) uses of HAVE_GNU_LD
remain, which I'll follow up on soon.

        Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2026-02-08  Rainer Orth  <[email protected]>

        gcc:
        * configure.ac (solaris_ld): New check.
        Test solaris_ld instead of gnu_ld_flag.
        * acinclude.m4: Likewise.
        * configure: Regenerate.
        * config.in: Regenerate.
        * config/i386/sol2.h: Switch to HAVE_SOLARIS_LD.
        * config/sol2.h: Likewise.
        * config/sparc/sol2.h: Likewise.
        * config/sparc/sparc.md: Likewise.

        gcc/go:
        * gospec.cc (lang_specific_driver): Switch to HAVE_SOLARIS_LD.

# HG changeset patch
# Parent  059d551e22b757365193f34c9c70c6dd2ca66221
Switch to HAVE_SOLARIS_LD

diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4
--- a/gcc/acinclude.m4
+++ b/gcc/acinclude.m4
@@ -323,8 +323,42 @@ int (*fp) (void) __attribute__ ((section
 	      sh_type='%progbits'
 	      ;;
 	  esac
-	  case "$target:$gnu_ld_flag" in
-	    *:yes)
+	  case "$target:$solaris_ld" in
+	    *-*-solaris2*:yes)
+	      # When Solaris ld added constructor priority support, it was
+	      # decided to only handle .init_array.N/.fini_array.N since
+	      # there was no need for backwards compatibility with
+	      # .ctors.N/.dtors.N.  .ctors/.dtors remain as separate
+	      # sections with correct execution order resp. to
+	      # .init_array/.fini_array, while gld merges them into
+	      # .init_array/.fini_array.
+	      cat > conftest.s <<EOF
+.section $sh_quote.fini_array.65530$sh_quote,$sh_flags,$sh_type
+.align 4
+.byte 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C'
+.section $sh_quote.init_array.65530$sh_quote,$sh_flags,$sh_type
+.align 4
+.byte 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D'
+.section $sh_quote.fini_array.01005$sh_quote,$sh_flags,$sh_type
+.align 4
+.byte 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G'
+.section $sh_quote.init_array.01005$sh_quote,$sh_flags,$sh_type
+.align 4
+.byte 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H'
+.text
+.globl _start
+_start:
+EOF
+	      if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
+	         && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
+	         && $gcc_cv_objdump -s -j .init_array conftest \
+		    | grep HHHHHHHHDDDDDDDD > /dev/null 2>&1 \
+	         && $gcc_cv_objdump -s -j .fini_array conftest \
+		    | grep GGGGGGGGCCCCCCCC > /dev/null 2>&1; then
+	        gcc_cv_initfini_array=yes
+	      fi
+	      ;;
+	    *:*)
 	      cat > conftest.s <<EOF
 .section .dtors,$sh_flags,$sh_type
 .balign 4
@@ -363,40 +397,6 @@ EOF
 	        gcc_cv_initfini_array=yes
 	      fi
 	      ;;
-	    *-*-solaris2*:no)
-	      # When Solaris ld added constructor priority support, it was
-	      # decided to only handle .init_array.N/.fini_array.N since
-	      # there was no need for backwards compatibility with
-	      # .ctors.N/.dtors.N.  .ctors/.dtors remain as separate
-	      # sections with correct execution order resp. to
-	      # .init_array/.fini_array, while gld merges them into
-	      # .init_array/.fini_array.
-	      cat > conftest.s <<EOF
-.section $sh_quote.fini_array.65530$sh_quote,$sh_flags,$sh_type
-.align 4
-.byte 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C'
-.section $sh_quote.init_array.65530$sh_quote,$sh_flags,$sh_type
-.align 4
-.byte 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D'
-.section $sh_quote.fini_array.01005$sh_quote,$sh_flags,$sh_type
-.align 4
-.byte 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G'
-.section $sh_quote.init_array.01005$sh_quote,$sh_flags,$sh_type
-.align 4
-.byte 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H'
-.text
-.globl _start
-_start:
-EOF
-	      if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
-	         && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
-	         && $gcc_cv_objdump -s -j .init_array conftest \
-		    | grep HHHHHHHHDDDDDDDD > /dev/null 2>&1 \
-	         && $gcc_cv_objdump -s -j .fini_array conftest \
-		    | grep GGGGGGGGCCCCCCCC > /dev/null 2>&1; then
-	        gcc_cv_initfini_array=yes
-	      fi
-	      ;;
 	    esac
 changequote(,)dnl
 	  rm -f conftest conftest.*
diff --git a/gcc/config.in b/gcc/config.in
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -2073,6 +2073,12 @@
 #endif
 
 
+/* Define to 1 if using the Solaris linker. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_SOLARIS_LD
+#endif
+
+
 /* Define to 1 if you have the <stddef.h> header file. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_STDDEF_H
diff --git a/gcc/config/i386/sol2.h b/gcc/config/i386/sol2.h
--- a/gcc/config/i386/sol2.h
+++ b/gcc/config/i386/sol2.h
@@ -85,7 +85,7 @@ along with GCC; see the file COPYING3.  
 
 #define ARCH64_SUBDIR "amd64"
 
-#if HAVE_GNU_LD
+#if !HAVE_SOLARIS_LD
 #define ARCH32_EMULATION "elf_i386_sol2"
 #define ARCH64_EMULATION "elf_x86_64_sol2"
 #endif
@@ -218,7 +218,7 @@ along with GCC; see the file COPYING3.  
 
 /* Unlike GNU ld, Sun ld doesn't coalesce .ctors.N/.dtors.N sections, so
    inhibit their creation.  Also cf. sparc/sysv4.h.  */
-#if !HAVE_GNU_LD
+#if HAVE_SOLARIS_LD
 #define CTORS_SECTION_ASM_OP	"\t.section\t.ctors, \"aw\""
 #define DTORS_SECTION_ASM_OP	"\t.section\t.dtors, \"aw\""
 #endif
diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -226,7 +226,7 @@ along with GCC; see the file COPYING3.  
    in that case, and for executable link with --{,no-}whole-archive around
    it to force everything into the executable.  */
 
-#if !HAVE_GNU_LD
+#if HAVE_SOLARIS_LD
 #define LD_WHOLE_ARCHIVE_OPTION "-z allextract"
 #define LD_NO_WHOLE_ARCHIVE_OPTION "-z defaultextract"
 #else
@@ -278,14 +278,14 @@ along with GCC; see the file COPYING3.  
    %{YP,*} \
    %{R*}"
 
-#if !HAVE_GNU_LD
+#if HAVE_SOLARIS_LD
 #define LINK_ARCH_SPEC_1 \
   "%{mcmodel=medlow:-M /usr/lib/ld/map.below4G} " LINK_ARCH_SPEC_BASE
 #else
 #define LINK_ARCH_SPEC_1 LINK_ARCH_SPEC_BASE
 #endif
 
-#if HAVE_GNU_LD
+#if !HAVE_SOLARIS_LD
 #if DEFAULT_ARCH32_P
 #define ARCH_DEFAULT_EMULATION ARCH32_EMULATION
 #else
@@ -323,7 +323,7 @@ along with GCC; see the file COPYING3.  
   { "endfile_vtv",		ENDFILE_VTV_SPEC },		\
   SUBTARGET_CPU_EXTRA_SPECS
 
-#if !HAVE_GNU_LD
+#if HAVE_SOLARIS_LD
 /* With Sun ld, -rdynamic is a no-op.  */
 #define RDYNAMIC_SPEC ""
 #else
@@ -331,12 +331,12 @@ along with GCC; see the file COPYING3.  
 #define RDYNAMIC_SPEC "--export-dynamic"
 #endif
 
-#if !HAVE_GNU_LD
+#if HAVE_SOLARIS_LD
 /* Prefer native form with Solaris ld.  */
 #define SYSROOT_SPEC "-z sysroot=%R"
 #endif
 
-#if !HAVE_GNU_LD && defined(ENABLE_SHARED_LIBGCC)
+#if HAVE_SOLARIS_LD && defined(ENABLE_SHARED_LIBGCC)
 /* With Sun ld, use mapfile to enforce direct binding to libgcc_s unwinder.  */
 #define LINK_LIBGCC_MAPFILE_SPEC \
   "%{shared|shared-libgcc:-M %slibgcc-unwind.map}"
@@ -385,12 +385,12 @@ along with GCC; see the file COPYING3.  
 #define USE_LD_AS_NEEDED 1
 #endif
 
-#if HAVE_GNU_LD
+#if !HAVE_SOLARIS_LD
 /* GNU ld needs --eh-frame-hdr to create the required .eh_frame_hdr sections.  */
 #define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
 #endif
 
-#if HAVE_GNU_LD
+#if !HAVE_SOLARIS_LD
 /* Assert -z text by default to match Solaris ld.  */
 #define LD_PIE_SPEC "-pie %{!mimpure-text:-z text}"
 #else
diff --git a/gcc/config/sparc/sol2.h b/gcc/config/sparc/sol2.h
--- a/gcc/config/sparc/sol2.h
+++ b/gcc/config/sparc/sol2.h
@@ -296,7 +296,7 @@ extern const char *host_detect_local_cpu
 %{!mcpu*:%(asm_cpu_default)} \
 "
 
-#if HAVE_GNU_LD
+#if !HAVE_SOLARIS_LD
 #define ARCH32_EMULATION "elf32_sparc_sol2"
 #define ARCH64_EMULATION "elf64_sparc_sol2"
 #endif
@@ -388,7 +388,7 @@ extern const char *host_detect_local_cpu
 #endif /* HAVE_SOLARIS_AS */
 
 /* Undefine this so that attribute((init_priority)) works with GNU ld.  */
-#if HAVE_GNU_LD
+#if !HAVE_SOLARIS_LD
 #undef CTORS_SECTION_ASM_OP
 #undef DTORS_SECTION_ASM_OP
 #endif
diff --git a/gcc/config/sparc/sparc.md b/gcc/config/sparc/sparc.md
--- a/gcc/config/sparc/sparc.md
+++ b/gcc/config/sparc/sparc.md
@@ -557,7 +557,7 @@
 
 ;; Attributes for branch scheduling
 (define_attr "tls_delay_slot" "false,true"
-  (symbol_ref "((!HAVE_SOLARIS_AS && HAVE_GNU_LD) != 0
+  (symbol_ref "(!HAVE_SOLARIS_AS && !HAVE_SOLARIS_LD
 		? TLS_DELAY_SLOT_TRUE : TLS_DELAY_SLOT_FALSE)"))
 
 (define_attr "in_sibcall_delay" "false,true"
diff --git a/gcc/configure b/gcc/configure
--- a/gcc/configure
+++ b/gcc/configure
@@ -25648,6 +25648,29 @@ else
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Solaris linker" >&5
+$as_echo_n "checking Solaris linker... " >&6; }
+case $target in
+  *-*-solaris2*)
+    if $gcc_cv_ld -V 2>/dev/null | grep 'Solaris Link Editors' > /dev/null; then
+      solaris_ld=yes
+    elif $gcc_cv_ld --version 2>/dev/null | grep GNU > /dev/null; then
+      gnu_ld_flag=yes
+    fi
+    ;;
+  *)
+    solaris_ld=no
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $solaris_ld" >&5
+$as_echo "$solaris_ld" >&6; }
+solaris_ld_bool=`if test $solaris_ld = yes; then echo 1; else echo 0; fi`
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_SOLARIS_LD $solaris_ld_bool
+_ACEOF
+
+
 ORIGINAL_PLUGIN_LD_FOR_TARGET=$gcc_cv_ld
 PLUGIN_LD_SUFFIX=`basename $gcc_cv_ld | sed -e "s,$target_alias-,,"`
 # if the PLUGIN_LD is set ld-new, just have it as ld
@@ -25672,16 +25695,16 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
-case "$target:$gnu_ld_flag" in
-  *-*-solaris2*:no)
+case "$target:$solaris_ld" in
+  *-*-solaris2*:yes)
     # While Solaris ld has -m32/-m64 it usually determines the ELF class
     # from the input objects.
     ;;
-  i?86-*-solaris2*:yes | x86_64-*-solaris2*:yes)
+  i?86-*-solaris2*:no | x86_64-*-solaris2*:no)
     ld_32_opt=-melf_i386_sol2
     ld_64_opt=-melf_x86_64_sol2
     ;;
-  i?86-*-*:yes | x86_64-*-*:yes)
+  i?86-*-*:* | x86_64-*-*:*)
     ld_32_opt=-melf_i386
     ld_64_opt=-melf_x86_64
     ;;
@@ -26892,8 +26915,42 @@ fi
 	      sh_type='%progbits'
 	      ;;
 	  esac
-	  case "$target:$gnu_ld_flag" in
-	    *:yes)
+	  case "$target:$solaris_ld" in
+	    *-*-solaris2*:yes)
+	      # When Solaris ld added constructor priority support, it was
+	      # decided to only handle .init_array.N/.fini_array.N since
+	      # there was no need for backwards compatibility with
+	      # .ctors.N/.dtors.N.  .ctors/.dtors remain as separate
+	      # sections with correct execution order resp. to
+	      # .init_array/.fini_array, while gld merges them into
+	      # .init_array/.fini_array.
+	      cat > conftest.s <<EOF
+.section $sh_quote.fini_array.65530$sh_quote,$sh_flags,$sh_type
+.align 4
+.byte 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C'
+.section $sh_quote.init_array.65530$sh_quote,$sh_flags,$sh_type
+.align 4
+.byte 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D'
+.section $sh_quote.fini_array.01005$sh_quote,$sh_flags,$sh_type
+.align 4
+.byte 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G'
+.section $sh_quote.init_array.01005$sh_quote,$sh_flags,$sh_type
+.align 4
+.byte 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H'
+.text
+.globl _start
+_start:
+EOF
+	      if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
+	         && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
+	         && $gcc_cv_objdump -s -j .init_array conftest \
+		    | grep HHHHHHHHDDDDDDDD > /dev/null 2>&1 \
+	         && $gcc_cv_objdump -s -j .fini_array conftest \
+		    | grep GGGGGGGGCCCCCCCC > /dev/null 2>&1; then
+	        gcc_cv_initfini_array=yes
+	      fi
+	      ;;
+	    *:*)
 	      cat > conftest.s <<EOF
 .section .dtors,$sh_flags,$sh_type
 .balign 4
@@ -26932,40 +26989,6 @@ EOF
 	        gcc_cv_initfini_array=yes
 	      fi
 	      ;;
-	    *-*-solaris2*:no)
-	      # When Solaris ld added constructor priority support, it was
-	      # decided to only handle .init_array.N/.fini_array.N since
-	      # there was no need for backwards compatibility with
-	      # .ctors.N/.dtors.N.  .ctors/.dtors remain as separate
-	      # sections with correct execution order resp. to
-	      # .init_array/.fini_array, while gld merges them into
-	      # .init_array/.fini_array.
-	      cat > conftest.s <<EOF
-.section $sh_quote.fini_array.65530$sh_quote,$sh_flags,$sh_type
-.align 4
-.byte 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C'
-.section $sh_quote.init_array.65530$sh_quote,$sh_flags,$sh_type
-.align 4
-.byte 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D'
-.section $sh_quote.fini_array.01005$sh_quote,$sh_flags,$sh_type
-.align 4
-.byte 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G'
-.section $sh_quote.init_array.01005$sh_quote,$sh_flags,$sh_type
-.align 4
-.byte 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H'
-.text
-.globl _start
-_start:
-EOF
-	      if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
-	         && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
-	         && $gcc_cv_objdump -s -j .init_array conftest \
-		    | grep HHHHHHHHDDDDDDDD > /dev/null 2>&1 \
-	         && $gcc_cv_objdump -s -j .fini_array conftest \
-		    | grep GGGGGGGGCCCCCCCC > /dev/null 2>&1; then
-	        gcc_cv_initfini_array=yes
-	      fi
-	      ;;
 	    esac
 	  rm -f conftest conftest.*
 	fi
@@ -28491,19 +28514,15 @@ fi
 $as_echo_n "checking linker --version-script option... " >&6; }
 gcc_cv_ld_version_script=no
 ld_version_script_option=''
-if test $in_tree_ld = yes || test x"$gnu_ld_flag" = xyes; then
+if test $in_tree_ld = yes || test $solaris_ld = no; then
   gcc_cv_ld_version_script=yes
   ld_version_script_option='--version-script'
-elif test x$gcc_cv_ld != x; then
-  case "$target" in
-    # Solaris 2 ld always supports -M.  It also supports a subset of
-    # --version-script since Solaris 11.4, but requires
-    # -z gnu-version-script-compat to activate.
-    *-*-solaris2*)
-      gcc_cv_ld_version_script=yes
-      ld_version_script_option='-M'
-      ;;
-  esac
+elif test $solaris_ld = yes; then
+  # Solaris 2 ld always supports -M.  It also supports a subset of
+  # --version-script since Solaris 11.4, but requires
+  # -z gnu-version-script-compat to activate.
+  gcc_cv_ld_version_script=yes
+  ld_version_script_option='-M'
 fi
 # Don't AC_DEFINE result, only used in jit/Make-lang.in so far.
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_version_script" >&5
@@ -28513,10 +28532,10 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker soname option" >&5
 $as_echo_n "checking linker soname option... " >&6; }
 gcc_cv_ld_soname=no
-if test $in_tree_ld = yes || test x"$gnu_ld_flag" = xyes; then
+if test $in_tree_ld = yes || test $solaris_ld = no; then
   gcc_cv_ld_soname=yes
   ld_soname_option='-soname'
-elif test x$gcc_cv_ld != x; then
+else
   case "$target" in
     *-*-darwin*)
       gcc_cv_ld_soname=yes
@@ -28543,12 +28562,11 @@ if test x"$demangler_in_ld" = xyes; then
     if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 14 -o "$gcc_cv_gld_major_version" -gt 2; then \
       gcc_cv_ld_demangle=yes
     fi
-  elif test x$gcc_cv_ld != x -a x"$gnu_ld_flag" = xyes; then
-    # Check if the GNU linker supports --demangle option
-    if $gcc_cv_ld --help 2>&1 | grep no-demangle > /dev/null; then
-      gcc_cv_ld_demangle=yes
-    fi
-  fi
+    # Check if the linker supports --demangle option
+  elif test $solaris_ld = no && $gcc_cv_ld --help 2>&1 | grep no-demangle > /dev/null; then
+     gcc_cv_ld_demangle=yes
+  fi
+  # FIXME: Solaris ld has -C instead.
   if test x"$gcc_cv_ld_demangle" = xyes; then
 
 $as_echo "#define HAVE_LD_DEMANGLE 1" >>confdefs.h
@@ -33155,7 +33173,7 @@ gcc_cv_ld_ctf=no
 # Check for Solaris ld 1.3315 introduced in Solaris 11.4 SRU 84.  ld -z ctf
 # already went in in SRU 81, but lacked GNU CTF to Solaris CTF conversion.
 if $gcc_cv_ld --help 2>&1 | grep -- '-z ctf' > /dev/null \
-  && test x$gnu_ld_flag = xno && test "$ld_vers_minor" -ge 3315; then
+  && test $solaris_ld = yes && test "$ld_vers_minor" -ge 3315; then
   gcc_cv_ld_ctf=yes
 
 $as_echo "#define HAVE_LD_CTF 1" >>confdefs.h
@@ -33438,8 +33456,13 @@ elif test x$gcc_cv_ld != x; then
       gcc_cv_ld_no_as_needed_option='--pop-state'
     fi
   fi
-  case "$target:$gnu_ld_flag" in
-    *-*-solaris2*:no)
+  case "$target:$solaris_ld" in
+    i?86-*-solaris2*:no | x86_64-*-solaris2*:no)
+      # Doesn't work with gld on Solaris/x86 due to PR ld/12320.
+      cc_cv_ld_as_needed=no
+      gcc_cv_ld_use_as_needed_ldscript=no
+      ;;
+    *-*-solaris2*:yes)
       # Solaris 2 ld always supports -z ignore/-z record.  Prefer the native
       # forms.
       gcc_cv_ld_as_needed=yes
@@ -33449,15 +33472,6 @@ elif test x$gcc_cv_ld != x; then
       ;;
   esac
 fi
-case "$target" in
-  i?86-*-solaris2* | x86_64-*-solaris2*)
-    if echo "$ld_ver" | grep GNU > /dev/null; then
-      # Doesn't work with gld on Solaris/x86 due to PR ld/12320.
-      gcc_cv_ld_as_needed=no
-      gcc_cv_ld_use_as_needed_ldscript=no
-    fi
-    ;;
-esac
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_as_needed" >&5
diff --git a/gcc/configure.ac b/gcc/configure.ac
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -2837,6 +2837,24 @@ gnu_ld_flag="$with_gnu_ld",
    gnu_ld_flag=no
  fi])
 
+AC_MSG_CHECKING(Solaris linker)
+case $target in
+  *-*-solaris2*)
+    if $gcc_cv_ld -V 2>/dev/null | grep 'Solaris Link Editors' > /dev/null; then
+      solaris_ld=yes
+    elif $gcc_cv_ld --version 2>/dev/null | grep GNU > /dev/null; then
+      gnu_ld_flag=yes
+    fi
+    ;;
+  *)
+    solaris_ld=no
+    ;;
+esac
+AC_MSG_RESULT($solaris_ld)
+solaris_ld_bool=`if test $solaris_ld = yes; then echo 1; else echo 0; fi`
+AC_DEFINE_UNQUOTED(HAVE_SOLARIS_LD, $solaris_ld_bool,
+	[Define to 1 if using the Solaris linker.])
+
 ORIGINAL_PLUGIN_LD_FOR_TARGET=$gcc_cv_ld
 PLUGIN_LD_SUFFIX=`basename $gcc_cv_ld | sed -e "s,$target_alias-,,"`
 # if the PLUGIN_LD is set ld-new, just have it as ld
@@ -2854,16 +2872,16 @@ AC_ARG_WITH(plugin-ld,
 AC_SUBST(ORIGINAL_PLUGIN_LD_FOR_TARGET)
 AC_DEFINE_UNQUOTED(PLUGIN_LD_SUFFIX, "$PLUGIN_LD_SUFFIX", [Specify plugin linker])
 
-case "$target:$gnu_ld_flag" in
-  *-*-solaris2*:no)
+case "$target:$solaris_ld" in
+  *-*-solaris2*:yes)
     # While Solaris ld has -m32/-m64 it usually determines the ELF class
     # from the input objects.
     ;;
-  i?86-*-solaris2*:yes | x86_64-*-solaris2*:yes)
+  i?86-*-solaris2*:no | x86_64-*-solaris2*:no)
     ld_32_opt=-melf_i386_sol2
     ld_64_opt=-melf_x86_64_sol2
     ;;
-  i?86-*-*:yes | x86_64-*-*:yes)
+  i?86-*-*:* | x86_64-*-*:*)
     ld_32_opt=-melf_i386
     ld_64_opt=-melf_x86_64
     ;;
@@ -4356,19 +4374,15 @@ AC_MSG_RESULT($gcc_cv_ld_static_dynamic)
 AC_MSG_CHECKING(linker --version-script option)
 gcc_cv_ld_version_script=no
 ld_version_script_option=''
-if test $in_tree_ld = yes || test x"$gnu_ld_flag" = xyes; then
+if test $in_tree_ld = yes || test $solaris_ld = no; then
   gcc_cv_ld_version_script=yes
   ld_version_script_option='--version-script'
-elif test x$gcc_cv_ld != x; then
-  case "$target" in
-    # Solaris 2 ld always supports -M.  It also supports a subset of
-    # --version-script since Solaris 11.4, but requires
-    # -z gnu-version-script-compat to activate.
-    *-*-solaris2*)
-      gcc_cv_ld_version_script=yes
-      ld_version_script_option='-M'
-      ;;
-  esac
+elif test $solaris_ld = yes; then
+  # Solaris 2 ld always supports -M.  It also supports a subset of
+  # --version-script since Solaris 11.4, but requires
+  # -z gnu-version-script-compat to activate.
+  gcc_cv_ld_version_script=yes
+  ld_version_script_option='-M'
 fi
 # Don't AC_DEFINE result, only used in jit/Make-lang.in so far.
 AC_MSG_RESULT($gcc_cv_ld_version_script)
@@ -4376,10 +4390,10 @@ AC_SUBST(ld_version_script_option)
 
 AC_MSG_CHECKING(linker soname option)
 gcc_cv_ld_soname=no
-if test $in_tree_ld = yes || test x"$gnu_ld_flag" = xyes; then
+if test $in_tree_ld = yes || test $solaris_ld = no; then
   gcc_cv_ld_soname=yes
   ld_soname_option='-soname'
-elif test x$gcc_cv_ld != x; then
+else
   case "$target" in
     *-*-darwin*)
       gcc_cv_ld_soname=yes
@@ -4404,12 +4418,11 @@ if test x"$demangler_in_ld" = xyes; then
     if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 14 -o "$gcc_cv_gld_major_version" -gt 2; then \
       gcc_cv_ld_demangle=yes
     fi
-  elif test x$gcc_cv_ld != x -a x"$gnu_ld_flag" = xyes; then
-    # Check if the GNU linker supports --demangle option
-    if $gcc_cv_ld --help 2>&1 | grep no-demangle > /dev/null; then
-      gcc_cv_ld_demangle=yes
-    fi
+    # Check if the linker supports --demangle option
+  elif test $solaris_ld = no && $gcc_cv_ld --help 2>&1 | grep no-demangle > /dev/null; then
+     gcc_cv_ld_demangle=yes
   fi
+  # FIXME: Solaris ld has -C instead.
   if test x"$gcc_cv_ld_demangle" = xyes; then
     AC_DEFINE(HAVE_LD_DEMANGLE, 1,
 [Define if your linker supports --demangle option.])
@@ -6399,7 +6412,7 @@ gcc_cv_ld_ctf=no
 # Check for Solaris ld 1.3315 introduced in Solaris 11.4 SRU 84.  ld -z ctf
 # already went in in SRU 81, but lacked GNU CTF to Solaris CTF conversion.
 if $gcc_cv_ld --help 2>&1 | grep -- '-z ctf' > /dev/null \
-  && test x$gnu_ld_flag = xno && test "$ld_vers_minor" -ge 3315; then
+  && test $solaris_ld = yes && test "$ld_vers_minor" -ge 3315; then
   gcc_cv_ld_ctf=yes
   AC_DEFINE(HAVE_LD_CTF, 1, [Define if your linker supports -z ctf.])
 fi
@@ -6632,8 +6645,13 @@ elif test x$gcc_cv_ld != x; then
       gcc_cv_ld_no_as_needed_option='--pop-state'
     fi
   fi
-  case "$target:$gnu_ld_flag" in
-    *-*-solaris2*:no)
+  case "$target:$solaris_ld" in
+    i?86-*-solaris2*:no | x86_64-*-solaris2*:no)
+      # Doesn't work with gld on Solaris/x86 due to PR ld/12320.
+      cc_cv_ld_as_needed=no
+      gcc_cv_ld_use_as_needed_ldscript=no
+      ;;
+    *-*-solaris2*:yes)
       # Solaris 2 ld always supports -z ignore/-z record.  Prefer the native
       # forms.
       gcc_cv_ld_as_needed=yes
@@ -6643,15 +6661,6 @@ elif test x$gcc_cv_ld != x; then
       ;;
   esac
 fi
-case "$target" in
-  i?86-*-solaris2* | x86_64-*-solaris2*)
-    if echo "$ld_ver" | grep GNU > /dev/null; then
-      # Doesn't work with gld on Solaris/x86 due to PR ld/12320.
-      gcc_cv_ld_as_needed=no
-      gcc_cv_ld_use_as_needed_ldscript=no
-    fi
-    ;;
-esac
 ])
 if test x"$gcc_cv_ld_as_needed" = xyes; then
 	AC_DEFINE(HAVE_LD_AS_NEEDED, 1,
diff --git a/gcc/go/gospec.cc b/gcc/go/gospec.cc
--- a/gcc/go/gospec.cc
+++ b/gcc/go/gospec.cc
@@ -438,7 +438,7 @@ lang_specific_driver (struct cl_decoded_
       j++;
     }
 
-#if defined(TARGET_SOLARIS) && !HAVE_GNU_LD
+#if HAVE_SOLARIS_LD
   /* We use a common symbol for go$zerovalue.  On Solaris, when not
      using the GNU linker, the Solaris linker needs an option to not
      warn about this.  Everything works without this option, but you

Reply via email to