https://gcc.gnu.org/g:febb0eac64c4a771c9f7260d4c28c5aca707c95e
commit r16-6798-gfebb0eac64c4a771c9f7260d4c28c5aca707c95e Author: Rainer Orth <[email protected]> Date: Thu Jan 15 09:45:06 2026 +0100 sparc: Switch TARGET_SUN_TLS default sparc/sparc.h currently defaults to TARGET_SUN_TLS. All other SPARC targets and Solaris with GNU as have to override this, although this is only needed on Solaris/SPARC with the native assembler. To simplify the code, this patch switches the default to TARGET_SUN_TLS set to 0, removing the need for all the overrides. TARGET_GNU_TLS is only used in two places and can be replaced by !TARGET_SUN_TLS, too. Bootstrapped without regressions on sparc-sun-solaris2.11 (as and gas) and sparc64-unknown-linux-gnu. 2026-01-13 Rainer Orth <[email protected]> gcc: * config/sparc/sparc.h (TARGET_TLS): Define as HAVE_AS_TLS. Update comment. (TARGET_SUN_TLS): Define as 0. (TARGET_GNU_TLS): Remove. * config/sparc/freebsd.h (TARGET_SUN_TLS): Remove. (TARGET_GNU_TLS): Remove. * config/sparc/linux.h: Likewise. * config/sparc/linux64.h: Likewise. * config/sparc/sol2.h (TARGET_SUN_TLS): Redefine as 1. Guard with HAVE_AS_TLS && !HAVE_GNU_AS. (TARGET_GNU_TLS): Remove. * config/sparc/sparc.cc (TARGET_ASM_OUTPUT_DWARF_DTPREL): Use !TARGET_SUN_TLS in guard. with !TARGET_SUN_TLS only. * config/sparc/sparc.md ("tls_delay_slot"): Guard with !TARGET_SUN_TLS. Diff: --- gcc/config/sparc/freebsd.h | 7 ------- gcc/config/sparc/linux.h | 7 ------- gcc/config/sparc/linux64.h | 7 ------- gcc/config/sparc/sol2.h | 9 +++------ gcc/config/sparc/sparc.cc | 2 +- gcc/config/sparc/sparc.h | 14 ++++---------- gcc/config/sparc/sparc.md | 2 +- 7 files changed, 9 insertions(+), 39 deletions(-) diff --git a/gcc/config/sparc/freebsd.h b/gcc/config/sparc/freebsd.h index 209f6618d26f..4820150d1e42 100644 --- a/gcc/config/sparc/freebsd.h +++ b/gcc/config/sparc/freebsd.h @@ -118,13 +118,6 @@ along with GCC; see the file COPYING3. If not see /* #define DWARF_OFFSET_SIZE PTR_SIZE */ -#ifdef HAVE_AS_TLS -#undef TARGET_SUN_TLS -#undef TARGET_GNU_TLS -#define TARGET_SUN_TLS 0 -#define TARGET_GNU_TLS 1 -#endif - #undef ENDFILE_SPEC #define ENDFILE_SPEC \ "%{Ofast|ffast-math|funsafe-math-optimizations:%{!shared:crtfastmath.o%s}} " \ diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h index 4d0c8c1a967b..750ed63ff56f 100644 --- a/gcc/config/sparc/linux.h +++ b/gcc/config/sparc/linux.h @@ -120,13 +120,6 @@ do { \ #undef DITF_CONVERSION_LIBFUNCS #define DITF_CONVERSION_LIBFUNCS 1 -#ifdef HAVE_AS_TLS -#undef TARGET_SUN_TLS -#undef TARGET_GNU_TLS -#define TARGET_SUN_TLS 0 -#define TARGET_GNU_TLS 1 -#endif - /* We use GNU ld so undefine this so that attribute((init_priority)) works. */ #undef CTORS_SECTION_ASM_OP #undef DTORS_SECTION_ASM_OP diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h index 923f2d2944ee..9ece60e65ec2 100644 --- a/gcc/config/sparc/linux64.h +++ b/gcc/config/sparc/linux64.h @@ -264,13 +264,6 @@ do { \ #undef DITF_CONVERSION_LIBFUNCS #define DITF_CONVERSION_LIBFUNCS 1 -#ifdef HAVE_AS_TLS -#undef TARGET_SUN_TLS -#undef TARGET_GNU_TLS -#define TARGET_SUN_TLS 0 -#define TARGET_GNU_TLS 1 -#endif - /* We use GNU ld so undefine this so that attribute((init_priority)) works. */ #undef CTORS_SECTION_ASM_OP #undef DTORS_SECTION_ASM_OP diff --git a/gcc/config/sparc/sol2.h b/gcc/config/sparc/sol2.h index 50eececa3fc4..c04c8f069d02 100644 --- a/gcc/config/sparc/sol2.h +++ b/gcc/config/sparc/sol2.h @@ -326,12 +326,9 @@ 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 HAVE_GNU_AS && defined(HAVE_AS_TLS) -/* Use GNU extensions to TLS support. */ -#undef TARGET_SUN_TLS -#undef TARGET_GNU_TLS -#define TARGET_SUN_TLS 0 -#define TARGET_GNU_TLS 1 +#if HAVE_AS_TLS && !HAVE_GNU_AS +#undef TARGET_SUN_TLS +#define TARGET_SUN_TLS 1 #endif #undef LOCAL_LABEL_PREFIX diff --git a/gcc/config/sparc/sparc.cc b/gcc/config/sparc/sparc.cc index 4ed1c6f96955..7bed27d35699 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 TARGET_GNU_TLS && defined(HAVE_AS_SPARC_UA_PCREL) +#if !TARGET_SUN_TLS && defined(HAVE_AS_SPARC_UA_PCREL) #undef TARGET_ASM_OUTPUT_DWARF_DTPREL #define TARGET_ASM_OUTPUT_DWARF_DTPREL sparc_output_dwarf_dtprel #endif diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h index dcf91553e5d8..32d6a8c3d861 100644 --- a/gcc/config/sparc/sparc.h +++ b/gcc/config/sparc/sparc.h @@ -1640,16 +1640,10 @@ extern int sparc_indent_opcode; } \ } while (0) -/* TLS support defaulting to original Sun flavor. GNU extensions - must be activated in separate configuration files. */ -#ifdef HAVE_AS_TLS -#define TARGET_TLS 1 -#else -#define TARGET_TLS 0 -#endif - -#define TARGET_SUN_TLS TARGET_TLS -#define TARGET_GNU_TLS 0 +/* TLS support defaults to GNU extensions. The original Sun flavor must be + activated in separate configuration files. */ +#define TARGET_TLS HAVE_AS_TLS +#define TARGET_SUN_TLS 0 #ifdef HAVE_AS_FMAF_HPC_VIS3 #define AS_NIAGARA3_FLAG "d" diff --git a/gcc/config/sparc/sparc.md b/gcc/config/sparc/sparc.md index b89ba1a0abf8..f4b9d2f47659 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 "((TARGET_GNU_TLS && HAVE_GNU_LD) != 0 + (symbol_ref "((!TARGET_SUN_TLS && HAVE_GNU_LD) != 0 ? TLS_DELAY_SLOT_TRUE : TLS_DELAY_SLOT_FALSE)")) (define_attr "in_sibcall_delay" "false,true"
