https://gcc.gnu.org/g:c807ac4d96dbb2e612fa2e8ebf7485b2fc3db117
commit r16-7831-gc807ac4d96dbb2e612fa2e8ebf7485b2fc3db117 Author: Rainer Orth <[email protected]> Date: Sun Mar 1 18:04:03 2026 +0100 Switch to HAVE_SOLARIS_AS The vast majority of the remaining uses of HAVE_GNU_AS are in Solaris-specific code to distinguish uses of GNU as from Solaris as. It's simpler to turn the check around, checking for Solaris as directly instead. The following patch does just that. Bootstrapped without regressions on sparcv9-sun-solaris2.11, amd64-pc-solaris2.11, sparc64-unknown-linux-gnu, and x86_64-pc-linux-gnu. 2026-02-08 Rainer Orth <[email protected]> gcc: * configure.ac (solaris_as): New check. * configure: Regenerate. * config.in: Regenerate. * config/i386/i386.cc: Switch to HAVE_SOLARIS_AS. * config/i386/sol2.h: Likewise. * config/sol2.h: Likewise. * config/sparc/sol2.h: Likewise. * config/sparc/sparc.cc: Likewise. * config/sparc/sparc.md: Likewise. Diff: --- gcc/config.in | 6 ++++++ gcc/config/i386/i386.cc | 2 +- gcc/config/i386/sol2.h | 26 ++++++++++++-------------- gcc/config/sol2.h | 2 +- gcc/config/sparc/sol2.h | 6 +++--- gcc/config/sparc/sparc.cc | 6 +++--- gcc/config/sparc/sparc.md | 4 ++-- gcc/configure | 24 ++++++++++++++++++++++++ gcc/configure.ac | 19 +++++++++++++++++++ 9 files changed, 71 insertions(+), 24 deletions(-) diff --git a/gcc/config.in b/gcc/config.in index faf382875dcd..6decd21a86fe 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -2037,6 +2037,12 @@ #endif +/* Define to 1 if using the Solaris assembler. */ +#ifndef USED_FOR_TARGET +#undef HAVE_SOLARIS_AS +#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/i386.cc b/gcc/config/i386/i386.cc index acedc73b8252..dec8ae97bf3e 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -25161,7 +25161,7 @@ i386_solaris_elf_named_section (const char *name, unsigned int flags, return; } -#if !HAVE_GNU_AS +#if HAVE_SOLARIS_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 1fb07750b0a6..3d271a7f5388 100644 --- a/gcc/config/i386/sol2.h +++ b/gcc/config/i386/sol2.h @@ -55,17 +55,15 @@ along with GCC; see the file COPYING3. If not see #define CC1_SPEC "%(cc1_cpu) " ASAN_CC1_SPEC SCTF_CC1_SPEC \ " %{mx32:%e-mx32 is not supported on Solaris}" -/* GNU as understands --32 and --64, but the native Solaris - assembler requires -m32 or -m64 instead. */ -#if HAVE_GNU_AS -#define ASM_CPU32_DEFAULT_SPEC "--32" -#define ASM_CPU64_DEFAULT_SPEC "--64" -#else +#if HAVE_SOLARIS_AS #define ASM_CPU32_DEFAULT_SPEC "-m32" #define ASM_CPU64_DEFAULT_SPEC "-m64" +#else +#define ASM_CPU32_DEFAULT_SPEC "--32" +#define ASM_CPU64_DEFAULT_SPEC "--64" #endif -#if !HAVE_GNU_AS +#if HAVE_SOLARIS_AS /* Since Studio 12.6, as needs -xbrace_comment=no so its AVX512 syntax is fully compatible with gas. */ #define ASM_XBRACE_COMMENT_SPEC "-xbrace_comment=no" @@ -145,7 +143,7 @@ along with GCC; see the file COPYING3. If not see } \ } while (0) -#if !HAVE_GNU_AS +#if HAVE_SOLARIS_AS /* The Sun assembler uses .tcomm for TLS common sections. */ #define TLS_COMMON_ASM_OP ".tcomm" @@ -175,7 +173,7 @@ along with GCC; see the file COPYING3. If not see ASM_OUTPUT_LABEL (FILE, NAME); \ } \ while (0) -#endif /* !HAVE_GNU_AS */ +#endif /* HAVE_SOLARIS_AS */ /* As in sparc/sol2.h, override the default from i386/x86-64.h to work around Sun as TLS bug. */ @@ -206,13 +204,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". */ -#if HAVE_GNU_AS -#define MACH_DEP_SECTION_ASM_FLAG 'l' -#else +#if HAVE_SOLARIS_AS #define MACH_DEP_SECTION_ASM_FLAG 'h' +#else +#define MACH_DEP_SECTION_ASM_FLAG 'l' #endif -#if !HAVE_GNU_AS +#if HAVE_SOLARIS_AS /* Emit COMDAT group signature symbols for Sun as. */ #undef TARGET_ASM_FILE_END #define TARGET_ASM_FILE_END solaris_file_end @@ -225,7 +223,7 @@ along with GCC; see the file COPYING3. If not see #define DTORS_SECTION_ASM_OP "\t.section\t.dtors, \"aw\"" #endif -#if !HAVE_GNU_AS +#if HAVE_SOLARIS_AS #define LARGECOMM_SECTION_ASM_OP "\t.lbcomm\t" #endif diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h index 398aa383505a..01d0a669618b 100644 --- a/gcc/config/sol2.h +++ b/gcc/config/sol2.h @@ -443,7 +443,7 @@ along with GCC; see the file COPYING3. If not see } \ while (0) -#if !HAVE_GNU_AS +#if HAVE_SOLARIS_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 d964c3ea727b..48f0308ee086 100644 --- a/gcc/config/sparc/sol2.h +++ b/gcc/config/sparc/sol2.h @@ -48,7 +48,7 @@ along with GCC; see the file COPYING3. If not see /* We switch to the explicit word size selection mechanism available both in GNU as and Sun as, for the Niagara4 and above configurations. */ -#if !HAVE_GNU_AS +#if HAVE_SOLARIS_AS #undef ASM_ARCH32_SPEC #define ASM_ARCH32_SPEC "-m32" #undef ASM_ARCH64_SPEC @@ -337,7 +337,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); } \ while (0) -#if !HAVE_GNU_AS +#if HAVE_SOLARIS_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 @@ -353,7 +353,7 @@ 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 /* !HAVE_GNU_AS */ +#endif /* HAVE_SOLARIS_AS */ /* Undefine this so that attribute((init_priority)) works with GNU ld. */ #if HAVE_GNU_LD diff --git a/gcc/config/sparc/sparc.cc b/gcc/config/sparc/sparc.cc index 47559dbe2cd1..47783fdeed96 100644 --- a/gcc/config/sparc/sparc.cc +++ b/gcc/config/sparc/sparc.cc @@ -877,7 +877,7 @@ char sparc_hard_reg_printed[8]; #define TARGET_STACK_PROTECT_GUARD hook_tree_void_null #endif -#if HAVE_GNU_AS +#if !HAVE_SOLARIS_AS #undef TARGET_ASM_OUTPUT_DWARF_DTPREL #define TARGET_ASM_OUTPUT_DWARF_DTPREL sparc_output_dwarf_dtprel #endif @@ -4689,7 +4689,7 @@ sparc_tls_got (void) /* In non-PIC mode, Sun as (unlike GNU as) emits PC-relative relocations for the GOT symbol with the 32-bit ABI, so we reload the GOT register. */ - if (!HAVE_GNU_AS && TARGET_ARCH32) + if (HAVE_SOLARIS_AS && TARGET_ARCH32) { load_got_register (); return got_register_rtx; @@ -4793,7 +4793,7 @@ sparc_legitimize_tls_address (rtx addr) emit_insn (gen_tie_ld32 (temp3, got, temp2, addr)); else emit_insn (gen_tie_ld64 (temp3, got, temp2, addr)); - if (!HAVE_GNU_AS) + if (HAVE_SOLARIS_AS) { ret = gen_reg_rtx (Pmode); emit_insn (gen_tie_add (Pmode, ret, gen_rtx_REG (Pmode, 7), diff --git a/gcc/config/sparc/sparc.md b/gcc/config/sparc/sparc.md index 608f96100a05..4740e255c295 100644 --- 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_GNU_AS && HAVE_GNU_LD) != 0 + (symbol_ref "((!HAVE_SOLARIS_AS && HAVE_GNU_LD) != 0 ? TLS_DELAY_SLOT_TRUE : TLS_DELAY_SLOT_FALSE)")) (define_attr "in_sibcall_delay" "false,true" @@ -8046,7 +8046,7 @@ (unspec:P [(match_operand:P 2 "register_operand" "r") (match_operand 3 "tie_symbolic_operand" "")] UNSPEC_TLSIE)))] - "!HAVE_GNU_AS" + "HAVE_SOLARIS_AS" "add\\t%1, %2, %0, %%tie_add(%a3)") (define_insn "@tle_hix22<P:mode>" diff --git a/gcc/configure b/gcc/configure index 7dc17f4cc205..3d9521f8d754 100755 --- a/gcc/configure +++ b/gcc/configure @@ -25490,6 +25490,30 @@ fi fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Solaris assembler" >&5 +$as_echo_n "checking Solaris assembler... " >&6; } +case $target in + *-*-solaris2*) + if $gcc_cv_as -V 2>&1 | grep 'Compiler Common.*SunOS' > /dev/null; then + solaris_as=yes + gas_flag=no + elif $gcc_cv_as --version 2>/dev/null | grep GNU > /dev/null; then + gas_flag=yes + fi + ;; + *) + solaris_as=no + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $solaris_as" >&5 +$as_echo "$solaris_as" >&6; } +solaris_as_bool=`if test $solaris_as = yes; then echo 1; else echo 0; fi` + +cat >>confdefs.h <<_ACEOF +#define HAVE_SOLARIS_AS $solaris_as_bool +_ACEOF + + ORIGINAL_AS_FOR_TARGET=$gcc_cv_as case "$ORIGINAL_AS_FOR_TARGET" in diff --git a/gcc/configure.ac b/gcc/configure.ac index a10d714a3c9c..466fc388f254 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2736,6 +2736,25 @@ gas_flag="$with_gnu_as", gas_flag=no fi]) +AC_MSG_CHECKING(Solaris assembler) +case $target in + *-*-solaris2*) + if $gcc_cv_as -V 2>&1 | grep 'Compiler Common.*SunOS' > /dev/null; then + solaris_as=yes + gas_flag=no + elif $gcc_cv_as --version 2>/dev/null | grep GNU > /dev/null; then + gas_flag=yes + fi + ;; + *) + solaris_as=no + ;; +esac +AC_MSG_RESULT($solaris_as) +solaris_as_bool=`if test $solaris_as = yes; then echo 1; else echo 0; fi` +AC_DEFINE_UNQUOTED(HAVE_SOLARIS_AS, $solaris_as_bool, + [Define to 1 if using the Solaris assembler.]) + ORIGINAL_AS_FOR_TARGET=$gcc_cv_as AC_SUBST(ORIGINAL_AS_FOR_TARGET) case "$ORIGINAL_AS_FOR_TARGET" in
