Several effective targets use a complicated dance to determine their
values from auto-host.h.  This prompted the et-static framework, which
is now used to replace their implementations.

Bootstrapped without regressions on i386-pc-solaris2.11 and
x86_64-pc-linux-gnu.

To be committed to trunk after et-static soak time.

        Rainer

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


2026-05-21  Rainer Orth  <[email protected]>

        gcc/testsuite:
        * lib/et-static.def (code_6_gottpoff_reloc): New effective target.
        (fentry): Likewise.
        (got32x_reloc): Likewise.
        (pie_copyreloc): Likewise.
        (powerpc_as_p10_htm): Likewise.
        (tls_get_addr_via_got): Likewise.

        * lib/target-supports.exp (check_effective_target_pie_copyreloc):
        Remove.
        (check_effective_target_code_6_gottpoff_reloc): Likewise.
        (check_effective_target_got32x_reloc): Likwise.
        (check_effective_target_tls_get_addr_via_got): Likewise.
        (check_effective_target_powerpc_as_p10_htm): Likewise.
        (check_effective_target_fentry): Likewise.

        * gcc.target/i386/pr120881-2a.c: Restrict to 64-bit x86.

# HG changeset patch
# Parent  6ce80125d13da19b4f19c9a17a8d0e9c925f965a
testsuite: Don't use auto-host.h in target-supports.exp

diff --git a/gcc/testsuite/gcc.target/i386/pr120881-2a.c b/gcc/testsuite/gcc.target/i386/pr120881-2a.c
--- a/gcc/testsuite/gcc.target/i386/pr120881-2a.c
+++ b/gcc/testsuite/gcc.target/i386/pr120881-2a.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target fentry } } */
+/* { dg-do compile { target { fentry && { x86 && lp64 } } } } */
 /* { dg-options "-O2 -pg -fno-pie" } */
 /* Keep labels and directives ('.cfi_startproc', '.cfi_endproc').  */
 /* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.} } } */
diff --git a/gcc/testsuite/lib/et-static.def b/gcc/testsuite/lib/et-static.def
--- a/gcc/testsuite/lib/et-static.def
+++ b/gcc/testsuite/lib/et-static.def
@@ -24,10 +24,30 @@
 
 # Keep this sorted alphabetically by effective-target name.  */
 
+code_6_gottpoff_reloc
+HAVE_AS_R_X86_64_CODE_6_GOTTPOFF
+assembler and linker support R_X86_64_CODE_6_GOTTPOFF
+
+fentry
+ENABLE_X86_64_MFENTRY
+-mfentry is enabled by default
+
+got32x_reloc
+HAVE_AS_IX86_GOT32X
+your assembler and linker support @GOT
+
 ld_at_file
 HAVE_LD_AT_FILE
 your linker supports GNU style response files
 
+pie_copyreloc
+HAVE_LD_PIE_COPYRELOC
+your linker supports -pie option with copy reloc
+
+powerpc_as_p10_htm
+HAVE_AS_POWER10_HTM
+your assembler supports htm insns on power10
+
 solaris_as
 HAVE_SOLARIS_AS
 using the Solaris assembler
@@ -35,3 +55,7 @@ using the Solaris assembler
 solaris_ld
 HAVE_SOLARIS_LD
 using the Solaris linker
+
+tls_get_addr_via_got
+HAVE_AS_IX86_TLS_GET_ADDR_GOT
+your assembler and linker support calling ___tls_get_addr via GOT
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -13162,195 +13162,6 @@ proc scan-ltrans-tree-dump-dem-not_requi
     return "-flto-partition=one"
 }
 
-# Return 1 if the x86-64 target supports PIE with copy reloc, 0
-# otherwise.  Cache the result.
-
-proc check_effective_target_pie_copyreloc { } {
-    global tool
-    global GCC_UNDER_TEST
-
-    if { ![check_effective_target_x86] } {
-	return 0
-    }
-
-    # Need auto-host.h to check linker support.
-    if { ![file exists ../../auto-host.h ] } {
-	return 0
-    }
-
-    return [check_cached_effective_target pie_copyreloc {
-	# Set up and compile to see if linker supports PIE with copy
-	# reloc.  Include the current process ID in the file names to
-	# prevent conflicts with invocations for multiple testsuites.
-
-	set src pie[pid].c
-	set obj pie[pid].o
-
-	set f [open $src "w"]
-	puts $f "#include \"../../auto-host.h\""
-	puts $f "#if HAVE_LD_PIE_COPYRELOC == 0"
-	puts $f "# error Linker does not support PIE with copy reloc."
-	puts $f "#endif"
-	close $f
-
-	verbose "check_effective_target_pie_copyreloc compiling testfile $src" 2
-	set lines [${tool}_target_compile $src $obj object ""]
-
-	file delete $src
-	file delete $obj
-
-	if [string match "" $lines] then {
-	    verbose "check_effective_target_pie_copyreloc testfile compilation passed" 2
-	    return 1
-	} else {
-	    verbose "check_effective_target_pie_copyreloc testfile compilation failed" 2
-	    return 0
-	}
-    }]
-}
-
-# Return 1 if the x86-64 target supports R_X86_64_CODE_6_GOTTPOFF
-# relocation, 0 otherwise.  Cache the result.
-
-proc check_effective_target_code_6_gottpoff_reloc { } {
-    global tool
-    global GCC_UNDER_TEST
-
-    if { ![check_effective_target_x86] } {
-	return 0
-    }
-
-    # Need auto-host.h to check linker support.
-    if { ![file exists ../../auto-host.h ] } {
-	return 0
-    }
-
-    return [check_cached_effective_target code_6_gottpoff_reloc {
-	# Include the current process ID in the file names to prevent
-	# conflicts with invocations for multiple testsuites.
-
-	set src code_6_gottpoff[pid].c
-	set obj code_6_gottpoff[pid].o
-
-	set f [open $src "w"]
-	puts $f "#include \"../../auto-host.h\""
-	puts $f "#if HAVE_AS_R_X86_64_CODE_6_GOTTPOFF == 0"
-	puts $f "# error Assembler does not support R_X86_64_CODE_6_GOTTPOFF."
-	puts $f "#endif"
-	close $f
-
-	verbose "check_effective_target_code_6_gottpoff_reloc compiling testfile $src" 2
-	set lines [${tool}_target_compile $src $obj object ""]
-
-	file delete $src
-	file delete $obj
-
-	if [string match "" $lines] then {
-	    verbose "check_effective_target_code_6_gottpoff_reloc testfile compilation passed" 2
-	    return 1
-	} else {
-	    verbose "check_effective_target_code_6_gottpoff_reloc testfile compilation failed" 2
-	    return 0
-	}
-    }]
-
-    return $code_6_gottpoff_reloc_available_saved
-}
-
-# Return 1 if the x86 target supports R_386_GOT32X relocation, 0
-# otherwise.  Cache the result.
-
-proc check_effective_target_got32x_reloc { } {
-    global tool
-    global GCC_UNDER_TEST
-
-    if { ![check_effective_target_x86] } {
-	return 0
-    }
-
-    # Need auto-host.h to check linker support.
-    if { ![file exists ../../auto-host.h ] } {
-	return 0
-    }
-
-    return [check_cached_effective_target got32x_reloc {
-	# Include the current process ID in the file names to prevent
-	# conflicts with invocations for multiple testsuites.
-
-	set src got32x[pid].c
-	set obj got32x[pid].o
-
-	set f [open $src "w"]
-	puts $f "#include \"../../auto-host.h\""
-	puts $f "#if HAVE_AS_IX86_GOT32X == 0"
-	puts $f "# error Assembler does not support R_386_GOT32X."
-	puts $f "#endif"
-	close $f
-
-	verbose "check_effective_target_got32x_reloc compiling testfile $src" 2
-	set lines [${tool}_target_compile $src $obj object ""]
-
-	file delete $src
-	file delete $obj
-
-	if [string match "" $lines] then {
-	    verbose "check_effective_target_got32x_reloc testfile compilation passed" 2
-	    return 1
-	} else {
-	    verbose "check_effective_target_got32x_reloc testfile compilation failed" 2
-	    return 0
-	}
-    }]
-
-    return $got32x_reloc_available_saved
-}
-
-# Return 1 if the x86 target supports calling ___tls_get_addr via GOT,
-# 0 otherwise.  Cache the result.
-
-proc check_effective_target_tls_get_addr_via_got { } {
-    global tool
-    global GCC_UNDER_TEST
-
-    if { ![check_effective_target_x86] } {
-	return 0
-    }
-
-    # Need auto-host.h to check linker support.
-    if { ![file exists ../../auto-host.h ] } {
-	return 0
-    }
-
-    return [check_cached_effective_target tls_get_addr_via_got {
-	# Include the current process ID in the file names to prevent
-	# conflicts with invocations for multiple testsuites.
-
-	set src tls_get_addr_via_got[pid].c
-	set obj tls_get_addr_via_got[pid].o
-
-	set f [open $src "w"]
-	puts $f "#include \"../../auto-host.h\""
-	puts $f "#if HAVE_AS_IX86_TLS_GET_ADDR_GOT == 0"
-	puts $f "# error Assembler/linker do not support calling ___tls_get_addr via GOT."
-	puts $f "#endif"
-	close $f
-
-	verbose "check_effective_target_tls_get_addr_via_got compiling testfile $src" 2
-	set lines [${tool}_target_compile $src $obj object ""]
-
-	file delete $src
-	file delete $obj
-
-	if [string match "" $lines] then {
-	    verbose "check_effective_target_tls_get_addr_via_got testfile compilation passed" 2
-	    return 1
-	} else {
-	    verbose "check_effective_target_tls_get_addr_via_got testfile compilation failed" 2
-	    return 0
-	}
-    }]
-}
-
 # Return 1 if the target uses comdat groups.
 
 proc check_effective_target_comdat_group {} {
@@ -14282,46 +14093,6 @@ proc check_effective_target_o_flag_in_se
     }]
 }
 
-# Return 1 if the given assembler supports hardware transactional memory
-# instructions with machine type Power10, 0 otherwise.  Cache the result.
-
-proc check_effective_target_powerpc_as_p10_htm { } {
-    global tool
-    global GCC_UNDER_TEST
-
-    # Need auto-host.h to check linker support.
-    if { ![file exists ../../auto-host.h ] } {
-	return 0
-    }
-
-    return [check_cached_effective_target powerpc_as_p10_htm {
-
-	set src pie[pid].c
-	set obj pie[pid].o
-
-	set f [open $src "w"]
-	puts $f "#include \"../../auto-host.h\""
-	puts $f "#if HAVE_AS_POWER10_HTM == 0"
-	puts $f "# error Assembler does not support htm insns with power10."
-	puts $f "#endif"
-	close $f
-
-	verbose "check_effective_target_powerpc_as_p10_htm compiling testfile $src" 2
-	set lines [${tool}_target_compile $src $obj object ""]
-
-	file delete $src
-	file delete $obj
-
-	if [string match "" $lines] then {
-	    verbose "check_effective_target_powerpc_as_p10_htm testfile compilation passed" 2
-	    return 1
-	} else {
-	    verbose "check_effective_target_powerpc_as_p10_htm testfile compilation failed" 2
-	    return 0
-	}
-    }]
-}
-
 # Return 1 if LRA is supported.  This must not be called (results in ERROR) for
 # targets that don't do register allocation, and therefore neither use nor
 # don't use LRA.
@@ -14898,54 +14669,6 @@ proc check_effective_target_foldable_pi_
 	}
     }]
 }
-#
-# Return 1 if the x86-64 target enables -mfentry by default, 0
-# otherwise.  Cache the result.
-
-proc check_effective_target_fentry { } {
-    global tool
-    global GCC_UNDER_TEST
-
-    if { ![check_effective_target_x86] } {
-	return 0
-    }
-
-    # Need auto-host.h to check linker support.
-    if { ![file exists ../../auto-host.h ] } {
-	return 0
-    }
-
-    return [check_cached_effective_target fentry {
-	# Set up and compile to see if ENABLE_X86_64_MFENTRY is
-	# non-zero.  Include the current process ID in the file
-	# names to prevent conflicts with invocations for multiple
-	# testsuites.
-
-	set src pie[pid].c
-	set obj pie[pid].o
-
-	set f [open $src "w"]
-	puts $f "#include \"../../auto-host.h\""
-	puts $f "#if ENABLE_X86_64_MFENTRY == 0 || !defined __x86_64__"
-	puts $f "# error -mfentry is not enabled by default."
-	puts $f "#endif"
-	close $f
-
-	verbose "check_effective_target_fentry compiling testfile $src" 2
-	set lines [${tool}_target_compile $src $obj object ""]
-
-	file delete $src
-	file delete $obj
-
-	if [string match "" $lines] then {
-	    verbose "check_effective_target_fentry testfile compilation passed" 2
-	    return 1
-	} else {
-	    verbose "check_effective_target_fentry testfile compilation failed" 2
-	    return 0
-	}
-    }]
-}
 
 # Check if valgrind executable exists in PATH on host
 proc check_effective_target_valgrind { } {

Reply via email to