Several of the testsuite's effective targets are supposed to match the
result of configure tests. However, they often try to redo the tests,
which leads to code duplication and inconsistencies.
Instead, this patch provides a framework to automatically generate
check_effective_target_<effective-target> procs that match an
auto-host.h macro and loads the result into targets.support.exp.
While this patch was prompted by the overly complex implementations of
the o_flag_in_section and R_flag_in_section effective targets, those two
are riddled with so many other problems that fixing them would dwarf
the core of this patch.
Instead, this uses the recently added HAVE_LD_AT_FILE check as a trivial
example. Just as HAVE_LD_AT_FILE was used to replace the current
HAVE_GNU_LD, this patch creates a new ld_at_file effective target,
replacing one use of the gld effective target.
Bootstrapped without regressions on i386-pc-solaris2.11 (as/ld and
gas/gld) and x86_64-pc-linux-gnu.
Ok for trunk?
As follow-ups, I mean to use this framework to either introduce new
effective targets, like solaris_as, solaris_ld or reimplement existing
ones.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
2026-01-13 Rainer Orth <[email protected]>
gcc:
* Makefile.in (distclean): Remove et-static.exp.
(site.exp): Depend on testsuite/et-static.exp.
(testsuite/et-static.exp): New target.
* doc/sourcebuild.texi (Effective-Target Keywords, Other
attributes): Document ld_at_file.
testsuite:
* lib/gen-et-static.awk: New file.
* lib/target-supports.exp: Load et-static.exp.
* gcc.misc-tests/outputs.exp: Use ld_at_file effective target
instead of gld.
Update comment.
# HG changeset patch
# Parent 4d77021e0e4106d191a7f357be1826eb0c3356ab
build: testsuite: Generate effective targets from auto-host.h
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -4080,6 +4080,7 @@ distclean: clean lang.distclean
-rm -f TAGS */TAGS
-rm -f *.asm
-rm -f site.exp site.bak testsuite/site.exp testsuite/site.bak
+ -rm -f testsuite/et-static.exp
-rm -f testsuite/*.log testsuite/*.sum
-cd testsuite && rm -f x *.x *.x? *.exe *.rpo *.o *.s *.S *.cc
-cd testsuite && rm -f *.out *.gcov *$(coverageexts)
@@ -4604,7 +4605,7 @@ uninstall: lang.uninstall
target_subdir = @target_subdir@
-site.exp: ./config.status Makefile
+site.exp: ./config.status Makefile testsuite/et-static.exp
@echo "Making a new config file..."
-@rm -f ./site.tmp
@$(STAMP) site.exp
@@ -4687,6 +4688,10 @@ site.exp: ./config.status Makefile
-e '1,/^## All variables above are.*##/ d' >> site.exp
-@rm -f ./site.tmp
+testsuite/et-static.exp: Makefile auto-host.h \
+ $(srcdir)/testsuite/lib/gen-et-static.awk
+ $(AWK) -f $(srcdir)/testsuite/lib/gen-et-static.awk auto-host.h > $@
+
CHECK_TARGETS = @check_languages@
check: $(CHECK_TARGETS)
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -3085,6 +3085,9 @@ Target uses GNU @command{ld}.
Target keeps null pointer checks, either due to the use of
@option{-fno-delete-null-pointer-checks} or hardwired into the target.
+@item ld_at_file
+Target supports GNU style response files.
+
@item llvm_binutils
Target is using an LLVM assembler and/or linker, instead of GNU Binutils.
diff --git a/gcc/testsuite/gcc.misc-tests/outputs.exp b/gcc/testsuite/gcc.misc-tests/outputs.exp
--- a/gcc/testsuite/gcc.misc-tests/outputs.exp
+++ b/gcc/testsuite/gcc.misc-tests/outputs.exp
@@ -50,9 +50,9 @@ if !$skip_lto {
set ltop [check_linker_plugin_available]
}
-# Check for GNU ld. Some files like .ld1_args depend on this. This
-# should really be testing whether the linker supports GNU style response files.
-set gld [check_effective_target_gld]
+# Check if the linker supports GNU style response files. Some files like
+# .ld1_args depend on this.
+set ld_at_file [check_effective_target_ld_at_file]
# Prepare additional options to be used for linking.
# We do not compile to an executable, because that requires naming an output.
@@ -178,7 +178,7 @@ proc outest { test sources opts dirs out
foreach og $olist {
if { [string index $og 0] == "!" } {
global gspd ltop
- global gld
+ global ld_at_file
set cond [expr $og]
continue
}
@@ -361,10 +361,10 @@ outest "$b-21 exe savetmp named2" $mult
# Additional files are created when an @file is used
if !$skip_atsave {
-outest "$b-22 exe savetmp namedb-2" $sing "@$devnull -o $b.exe -save-temps" {} {{--0.i --0.s --0.o .args.0 !!$gld .ld1_args !0 .exe}}
-outest "$b-23 exe savetmp named2-2" $mult "@$devnull -o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o .args.0 !!$gld .ld1_args !0 .exe}}
-outest "$b-24 exe savetmp named2-3" $mult "@$devnull -I dummy -o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o -args.0 -args.1 .args.2 !!$gld .ld1_args !0 .exe}}
-outest "$b-25 exe savetmp named2-4" $mult "@$devnull -I dummy -L dummy -o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o -args.0 -args.1 .args.2 .args.3 !!$gld .ld1_args !0 .exe}}
+outest "$b-22 exe savetmp namedb-2" $sing "@$devnull -o $b.exe -save-temps" {} {{--0.i --0.s --0.o .args.0 !!$ld_at_file .ld1_args !0 .exe}}
+outest "$b-23 exe savetmp named2-2" $mult "@$devnull -o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o .args.0 !!$ld_at_file .ld1_args !0 .exe}}
+outest "$b-24 exe savetmp named2-3" $mult "@$devnull -I dummy -o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o -args.0 -args.1 .args.2 !!$ld_at_file .ld1_args !0 .exe}}
+outest "$b-25 exe savetmp named2-4" $mult "@$devnull -I dummy -L dummy -o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o -args.0 -args.1 .args.2 .args.3 !!$ld_at_file .ld1_args !0 .exe}}
}
# Setting the main output to a dir selects it as the default aux&dump
diff --git a/gcc/testsuite/lib/gen-et-static.awk b/gcc/testsuite/lib/gen-et-static.awk
new file mode 100644
--- /dev/null
+++ b/gcc/testsuite/lib/gen-et-static.awk
@@ -0,0 +1,40 @@
+# Copyright (C) 2026 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# This Awk script takes auto-host.h and writes et-static.exp for select static
+# definitions, generation support for corresponding effective-target keywords.
+#
+# Usage: awk -f gen-et-static.awk auto-gen.h
+
+BEGIN {
+ print "# This file is auto-generated by gen-et-static.awk from auto-host.h.";
+}
+
+function emit_effective_target_check(name, value, comment)
+{
+ print "";
+ print "# " comment;
+ print "proc check_effective_target_" name " { } {";
+ print " return " value;
+ print "}";
+}
+
+# Keep this sorted alphabetically by macro name. */
+
+/^#define HAVE_LD_AT_FILE/ {
+ emit_effective_target_check("ld_at_file", $3,
+ "Return 1 if your linker supports GNU style response files, 0 otherwise.");
+}
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
@@ -19,6 +19,20 @@
# This file defines procs for determining features supported by the target.
+# Try to load effective-target procs from the generated et-static.exp in
+# gcc/testsuite.
+
+global tool_root_dir
+
+set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
+if {$gccdir != ""} {
+ set gccdir [file dirname $gccdir]
+} else {
+ error "Couldn't find et-static.exp."
+}
+
+load_file $gccdir/testsuite/et-static.exp
+
# Try to compile the code given by CONTENTS into an output file of
# type TYPE, where TYPE is as for target_compile. Return a list
# whose first element contains the compiler messages and whose