https://gcc.gnu.org/g:240b502bb2ca89ab4e1ad9478e669edd0b59b9fa
commit r16-5448-g240b502bb2ca89ab4e1ad9478e669edd0b59b9fa Author: Rainer Orth <[email protected]> Date: Thu Nov 20 10:34:13 2025 +0100 Switch from USE_GAS/GLD to HAVE_GNU_AS/LD 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: * gcc/config/ia64/hpux.h has one macro guarded by !USE_GAS. This wasn't defined before since the configuration for this target doesn't include usegas.h. However, the code is still needed, so the HAVE_GNU_AS form is now used. * Uses of usegas.h in various powerpc*-*-* configurations in gcc/config.gcc. Those make no difference since USE_GAS isn't used in any of the affected files. Bootstrapped without regressions on i386-pc-solaris2.11 and sparc-sun-solaris2.11 (as/ld, gas/ld, and gas/gld configurations). 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: Likewise. * 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. Diff: --- gcc/config.gcc | 18 ++++++------------ gcc/config/i386/i386.cc | 2 +- gcc/config/i386/sol2.h | 16 ++++++++-------- gcc/config/ia64/hpux.h | 2 +- gcc/config/sol2.h | 18 +++++++++--------- gcc/config/sparc/sol2.h | 12 ++++++------ gcc/config/usegas.h | 20 -------------------- gcc/config/usegld.h | 1 - gcc/go/gospec.cc | 2 +- 9 files changed, 32 insertions(+), 59 deletions(-) diff --git a/gcc/config.gcc b/gcc/config.gcc index eeecbd8463a7..20c974e8e052 100644 --- 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" c_target_objs="${c_target_objs} sol2-c.o" @@ -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 index 8aac0820bc22..722c1713a6d3 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -25103,7 +25103,7 @@ i386_solaris_elf_named_section (const char *name, unsigned int flags, 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 index 90355e853eed..3720424899d6 100644 --- a/gcc/config/i386/sol2.h +++ b/gcc/config/i386/sol2.h @@ -60,7 +60,7 @@ along with GCC; see the file COPYING3. If not see /* 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. If not see #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. If not see } \ } 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. If not see 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. If not see /* 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. If not see /* 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 index 13c7900e1413..a1e05f6fd31e 100644 --- a/gcc/config/ia64/hpux.h +++ b/gcc/config/ia64/hpux.h @@ -62,7 +62,7 @@ do { \ #undef ASM_EXTRA_SPEC #define ASM_EXTRA_SPEC "%{milp32:-milp32} %{mlp64:-mlp64}" -#ifndef USE_GAS +#ifndef HAVE_GNU_AS #define AS_NEEDS_DASH_FOR_PIPED_INPUT #endif diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h index 7c3cb82933bf..4e3199d2c8c8 100644 --- a/gcc/config/sol2.h +++ b/gcc/config/sol2.h @@ -224,7 +224,7 @@ along with GCC; see the file COPYING3. If not see 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 @@ -276,14 +276,14 @@ along with GCC; see the file COPYING3. If not see %{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 @@ -321,7 +321,7 @@ along with GCC; see the file COPYING3. If not see { "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 @@ -329,12 +329,12 @@ along with GCC; see the file COPYING3. If not see #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}" @@ -367,12 +367,12 @@ along with GCC; see the file COPYING3. If not see #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 @@ -423,7 +423,7 @@ along with GCC; see the file COPYING3. If not see } \ 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 index 71ac0664e36b..8db85c235429 100644 --- a/gcc/config/sparc/sol2.h +++ b/gcc/config/sparc/sol2.h @@ -64,7 +64,7 @@ along with GCC; see the file COPYING3. If not see #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 (int argc, const char **argv); %{!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 (int argc, const char **argv); /* 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 (int argc, const char **argv); } \ 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 (int argc, const char **argv); /* 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 index f099ae8335c3..000000000000 --- 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 index 06677327099a..000000000000 --- a/gcc/config/usegld.h +++ /dev/null @@ -1 +0,0 @@ -#define USE_GLD 1 diff --git a/gcc/go/gospec.cc b/gcc/go/gospec.cc index 2943499edcdc..74177c2662b1 100644 --- a/gcc/go/gospec.cc +++ b/gcc/go/gospec.cc @@ -438,7 +438,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, 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
