We currently have two ways to distinguish GNU and non-GNU assemblers and
linkers:

* USE_GAS and USE_GLD, defined via gcc/config/usegas.h and usegld.h
  which are included via config.gcc

* HAVE_GNU_AS and HAVE_GNU_LD, determined from gcc/configure.ac

This is confusing and leads to weird mistakes like combining both into
an undefined USE_GNU_LD.  Since both are based on the same info ($gas
resp. $gnu_ld in gcc/configure.ac), it seems best to standardise on one
of them.  Since the USE_* form is almost exclusively used in
Solaris-specific contexts, it's clearer to use the HAVE_GNU_* forms
instead.

This is what this patch does.

Most of the changes are either Solaris-specific or border on obvious.

Outside of Solaris code, there are only two cases:

* Uses of usegas.h in various powerpc*-*-* configurations in
  gcc/config.gcc.  Those changes make no difference since USE_GAS isn't
  used in any of the affected files.

* gcc/config/ia64/hpux.h has one macro guarded by !USE_GAS.  However,
  judging from gcc/config.gcc ia64*-*-hpux* is gas-only, so this
  instance can simply be removed.

Bootstrapped without regressions on i386-pc-solaris2.11 and
sparc-sun-solaris2.11 (as/ld, gas/ld, and gas/gld configurations).

Ok for trunk?

        Rainer

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


2025-11-18  Rainer Orth  <[email protected]>

        gcc:
        * config/i386/sol2.h: Replace USE_GAS by HAVE_GNU_AS.
        Replace USE_GLD by HAVE_GNU_LD.
        * config/sol2.h: Likewise.
        * config/sparc/sol2.h: Likewise.
        * config/i386/i386.cc (i386_solaris_elf_named_section)
        [TARGET_SOLARIS]: Replace USE_GAS by HAVE_GNU_AS.

        * config/ia64/hpux.h [!USE_GAS] (AS_NEEDS_DASH_FOR_PIPED_INPUT):
        Remove.

        * config.gcc: Remove usegas.h, usegld.h.
        * config/usegas.h: Remove.
        * config/usegld.h: Remove

        gcc/go:
        * gospec.cc (lang_specific_driver) [TARGET_SOLARIS]: Replace
        USE_GLD by HAVE_GNU_LD.

# HG changeset patch
# Parent  1e089777974c7a01ea7cf4d178a9444d3ddf1609
Switch from USE_GAS/GLD to HAVE_GNU_AS/LD

diff --git a/gcc/config.gcc b/gcc/config.gcc
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1066,12 +1066,6 @@ case ${target} in
   # __cxa_atexit was introduced in Solaris 11.4.
   default_use_cxa_atexit=yes
   use_gcc_stdint=wrap
-  if test x$gnu_ld = xyes; then
-    tm_file="usegld.h ${tm_file}"
-  fi
-  if test x$gas = xyes; then
-    tm_file="usegas.h ${tm_file}"
-  fi
   tm_p_file="${tm_p_file} sol2-protos.h"
   tmake_file="${tmake_file} t-sol2 t-slibgcc"
   target_gtfiles="$target_gtfiles \$(srcdir)/config/sol2.cc"
@@ -3067,13 +3061,13 @@ powerpc-*-eabisimaltivec*)
 	use_gcc_stdint=wrap
 	;;
 powerpc-*-eabisim*)
-	tm_file="${tm_file} elfos.h gnu-user.h usegas.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/eabi.h rs6000/eabisim.h"
+	tm_file="${tm_file} elfos.h gnu-user.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/eabi.h rs6000/eabisim.h"
 	extra_options="${extra_options} rs6000/sysv4.opt"
 	tmake_file="rs6000/t-fprules rs6000/t-ppcgas rs6000/t-ppccomm"
 	use_gcc_stdint=wrap
 	;;
 powerpc-*-elf*)
-	tm_file="${tm_file} elfos.h gnu-user.h usegas.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h"
+	tm_file="${tm_file} elfos.h gnu-user.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h"
 	extra_options="${extra_options} rs6000/sysv4.opt"
 	tmake_file="rs6000/t-fprules rs6000/t-ppcgas rs6000/t-ppccomm"
 	;;
@@ -3084,7 +3078,7 @@ powerpc-*-eabialtivec*)
 	use_gcc_stdint=wrap
 	;;
 powerpc-*-eabi*)
-	tm_file="${tm_file} elfos.h gnu-user.h usegas.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/eabi.h"
+	tm_file="${tm_file} elfos.h gnu-user.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/eabi.h"
 	extra_options="${extra_options} rs6000/sysv4.opt"
 	tmake_file="rs6000/t-fprules rs6000/t-ppcgas rs6000/t-ppccomm"
 	use_gcc_stdint=wrap
@@ -3212,18 +3206,18 @@ powerpc-*-lynxos*)
 	gas=yes
 	;;
 powerpcle-*-elf*)
-	tm_file="${tm_file} elfos.h gnu-user.h usegas.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/sysv4le.h"
+	tm_file="${tm_file} elfos.h gnu-user.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/sysv4le.h"
 	tmake_file="rs6000/t-fprules rs6000/t-ppcgas rs6000/t-ppccomm"
 	extra_options="${extra_options} rs6000/sysv4.opt"
 	;;
 powerpcle-*-eabisim*)
-	tm_file="${tm_file} elfos.h gnu-user.h usegas.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/sysv4le.h rs6000/eabi.h rs6000/eabisim.h"
+	tm_file="${tm_file} elfos.h gnu-user.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/sysv4le.h rs6000/eabi.h rs6000/eabisim.h"
 	tmake_file="rs6000/t-fprules rs6000/t-ppcgas rs6000/t-ppccomm"
 	extra_options="${extra_options} rs6000/sysv4.opt"
 	use_gcc_stdint=wrap
 	;;
 powerpcle-*-eabi*)
-	tm_file="${tm_file} elfos.h gnu-user.h usegas.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/sysv4le.h rs6000/eabi.h"
+	tm_file="${tm_file} elfos.h gnu-user.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/sysv4le.h rs6000/eabi.h"
 	tmake_file="rs6000/t-fprules rs6000/t-ppcgas rs6000/t-ppccomm"
 	extra_options="${extra_options} rs6000/sysv4.opt"
 	use_gcc_stdint=wrap
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -25194,7 +25194,7 @@ i386_solaris_elf_named_section (const ch
       return;
     }
 
-#ifndef USE_GAS
+#if !HAVE_GNU_AS
   if (HAVE_COMDAT_GROUP && flags & SECTION_LINKONCE)
     {
       solaris_elf_asm_comdat_section (name, flags, decl);
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
@@ -60,7 +60,7 @@ along with GCC; see the file COPYING3.  
 
 /* GNU as understands --32 and --64, but the native Solaris
    assembler requires -xarch=generic or -xarch=generic64 instead.  */
-#ifdef USE_GAS
+#if HAVE_GNU_AS
 #define ASM_CPU32_DEFAULT_SPEC "--32"
 #define ASM_CPU64_DEFAULT_SPEC "--64"
 #else
@@ -90,7 +90,7 @@ along with GCC; see the file COPYING3.  
 
 #define ARCH64_SUBDIR "amd64"
 
-#ifdef USE_GLD
+#if HAVE_GNU_LD
 #define ARCH32_EMULATION "elf_i386_sol2"
 #define ARCH64_EMULATION "elf_x86_64_sol2"
 #endif
@@ -149,7 +149,7 @@ along with GCC; see the file COPYING3.  
       }							\
   } while (0)
 
-#ifndef USE_GAS
+#if !HAVE_GNU_AS
 /* The Sun assembler uses .tcomm for TLS common sections.  */
 #define TLS_COMMON_ASM_OP ".tcomm"
 
@@ -179,7 +179,7 @@ along with GCC; see the file COPYING3.  
       ASM_OUTPUT_LABEL (FILE, NAME);				\
     }								\
   while (0)
-#endif /* !USE_GAS */
+#endif /* !HAVE_GNU_AS */
 
 /* As in sparc/sol2.h, override the default from i386/x86-64.h to work
    around Sun as TLS bug.  */
@@ -210,13 +210,13 @@ along with GCC; see the file COPYING3.  
 
 /* Sun as requires "h" flag for large sections, GNU as can do without, but
    accepts "l".  */
-#ifdef USE_GAS
+#if HAVE_GNU_AS
 #define MACH_DEP_SECTION_ASM_FLAG 'l'
 #else
 #define MACH_DEP_SECTION_ASM_FLAG 'h'
 #endif
 
-#ifndef USE_GAS
+#if !HAVE_GNU_AS
 /* Emit COMDAT group signature symbols for Sun as.  */
 #undef TARGET_ASM_FILE_END
 #define TARGET_ASM_FILE_END solaris_file_end
@@ -224,12 +224,12 @@ 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.  */
-#ifndef USE_GLD
+#if !HAVE_GNU_LD
 #define CTORS_SECTION_ASM_OP	"\t.section\t.ctors, \"aw\""
 #define DTORS_SECTION_ASM_OP	"\t.section\t.dtors, \"aw\""
 #endif
 
-#ifndef USE_GAS
+#if !HAVE_GNU_AS
 #define LARGECOMM_SECTION_ASM_OP "\t.lbcomm\t"
 #endif
 
diff --git a/gcc/config/ia64/hpux.h b/gcc/config/ia64/hpux.h
--- a/gcc/config/ia64/hpux.h
+++ b/gcc/config/ia64/hpux.h
@@ -62,10 +62,6 @@ do {							\
 #undef  ASM_EXTRA_SPEC
 #define ASM_EXTRA_SPEC "%{milp32:-milp32} %{mlp64:-mlp64}"
 
-#ifndef USE_GAS
-#define AS_NEEDS_DASH_FOR_PIPED_INPUT
-#endif
-
 #ifndef CROSS_DIRECTORY_STRUCTURE
 #undef MD_EXEC_PREFIX
 #define MD_EXEC_PREFIX "/usr/ccs/bin/"
diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -235,7 +235,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.  */
 
-#ifndef USE_GLD
+#if !HAVE_GNU_LD
 #define LD_WHOLE_ARCHIVE_OPTION "-z allextract"
 #define LD_NO_WHOLE_ARCHIVE_OPTION "-z defaultextract"
 #else
@@ -287,14 +287,14 @@ along with GCC; see the file COPYING3.  
    %{YP,*} \
    %{R*}"
 
-#ifndef USE_GLD
+#if !HAVE_GNU_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
 
-#ifdef USE_GLD
+#if HAVE_GNU_LD
 #if DEFAULT_ARCH32_P
 #define ARCH_DEFAULT_EMULATION ARCH32_EMULATION
 #else
@@ -332,7 +332,7 @@ along with GCC; see the file COPYING3.  
   { "endfile_vtv",		ENDFILE_VTV_SPEC },		\
   SUBTARGET_CPU_EXTRA_SPECS
 
-#ifndef USE_GLD
+#if !HAVE_GNU_LD
 /* With Sun ld, -rdynamic is a no-op.  */
 #define RDYNAMIC_SPEC ""
 #else
@@ -340,12 +340,12 @@ along with GCC; see the file COPYING3.  
 #define RDYNAMIC_SPEC "--export-dynamic"
 #endif
 
-#ifndef USE_GLD
+#if !HAVE_GNU_LD
 /* Prefer native form with Solaris ld.  */
 #define SYSROOT_SPEC "-z sysroot=%R"
 #endif
 
-#if !defined(USE_GLD) && defined(ENABLE_SHARED_LIBGCC)
+#if !HAVE_GNU_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}"
@@ -378,12 +378,12 @@ along with GCC; see the file COPYING3.  
 #define USE_LD_AS_NEEDED 1
 #endif
 
-#ifdef USE_GLD
+#if HAVE_GNU_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
 
-#ifdef USE_GLD
+#if HAVE_GNU_LD
 /* Assert -z text by default to match Solaris ld.  */
 #define LD_PIE_SPEC "-pie %{!mimpure-text:-z text}"
 #else
@@ -434,7 +434,7 @@ along with GCC; see the file COPYING3.  
     }								\
   while (0)
 
-#ifndef USE_GAS
+#if !HAVE_GNU_AS
 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
 #define TARGET_ASM_ASSEMBLE_VISIBILITY solaris_assemble_visibility
 
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
@@ -64,7 +64,7 @@ along with GCC; see the file COPYING3.  
 #define AS_SPARC32_FLAG ""
 #define AS_SPARC64_FLAG ""
 
-#ifndef USE_GAS
+#if !HAVE_GNU_AS
 #undef ASM_ARCH32_SPEC
 #define ASM_ARCH32_SPEC "-m32"
 #undef ASM_ARCH64_SPEC
@@ -307,7 +307,7 @@ extern const char *host_detect_local_cpu
 %{!mcpu*:%(asm_cpu_default)} \
 "
 
-#ifdef USE_GLD
+#if HAVE_GNU_LD
 #define ARCH32_EMULATION "elf32_sparc_sol2"
 #define ARCH64_EMULATION "elf64_sparc_sol2"
 #endif
@@ -326,7 +326,7 @@ extern const char *host_detect_local_cpu
 /* Register the Solaris-specific #pragma directives.  */
 #define REGISTER_TARGET_PRAGMAS() solaris_register_pragmas ()
 
-#if defined(USE_GAS) && defined(HAVE_AS_TLS)
+#if HAVE_GNU_AS && defined(HAVE_AS_TLS)
 /* Use GNU extensions to TLS support.  */
 #undef TARGET_SUN_TLS
 #undef TARGET_GNU_TLS
@@ -405,7 +405,7 @@ extern const char *host_detect_local_cpu
     }									\
   while (0)
 
-#ifndef USE_GAS
+#if !HAVE_GNU_AS
 /* This is how to output an assembler line that says to advance
    the location counter to a multiple of 2**LOG bytes using the
    NOP instruction as padding.  The filler pattern doesn't work
@@ -421,10 +421,10 @@ extern const char *host_detect_local_cpu
 /* Sun as requires doublequoted section names on SPARC.  While GNU as
    supports that, too, we prefer the standard variant.  */
 #define SECTION_NAME_FORMAT	"\"%s\""
-#endif /* !USE_GAS */
+#endif /* !HAVE_GNU_AS */
 
 /* Undefine this so that attribute((init_priority)) works with GNU ld.  */
-#ifdef USE_GLD
+#if HAVE_GNU_LD
 #undef CTORS_SECTION_ASM_OP
 #undef DTORS_SECTION_ASM_OP
 #endif
diff --git a/gcc/config/usegas.h b/gcc/config/usegas.h
deleted file mode 100644
--- a/gcc/config/usegas.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 2001-2025 Free Software Foundation, Inc.
-
-   This file is part of GCC.
-
-   GCC is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3, or (at your option)
-   any later version.
-
-   GCC is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with GCC; see the file COPYING3.  If not see
-   <http://www.gnu.org/licenses/>.  */
-
-/* Just set a single flag we can test for it inside other files.  */
-#define USE_GAS 1
diff --git a/gcc/config/usegld.h b/gcc/config/usegld.h
deleted file mode 100644
--- a/gcc/config/usegld.h
+++ /dev/null
@@ -1,1 +0,0 @@
-#define USE_GLD 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) && !defined(USE_GLD)
+#if defined(TARGET_SOLARIS) && !HAVE_GNU_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