# --testsuite, --srcdir will be ignored; otherwise, `/gcc/testsuite'
# will be appended to the srcdir.
+# target-supports.exp depends on et-static.exp generated from auto-host.h.
+# It is usually taken from the installed compiler, but can be specified
+# using --with-et-static. To support testing with a source tree newer than
+# the installed compiler, it can also be generated from an auto-host.h
+# specified with --with-auto-host-h. If the actual auto-host.h is missing,
+# /dev/null can be used to generate a fallback et-static.exp.
+
# You may specify where the binaries to be tested should be picked up
# from. If you specify --prefix=/some/dir, gcc, g++ and gfortran will be
# looked for at /some/dir/bin. Each one may be overridden by
# specifying --with-gcc=/pathname/to/gcc, --with-g++=/pathname/to/g++
# and --with-gfortran=/pathname/to/gfortran. If you specify --without-gcc,
-# --without-g++ or --without-gfortran, the test for the specified program
-# will be skipped. By default, gcc, g++ and gfortran will be searched in
-# the PATH.
+# --without-g++ --without-gfortran, or --without-objc the test for the
+# specified program will be skipped. By default, gcc, g++ and gfortran
+# will be searched in the PATH.
# An additional argument may specify --tmpdir=/some/dir; by default,
# temporaries will be stored in the current directory, where the log
while true; do
case "$1" in
--with-testsuite=*) testsuite=`echo "$1" | sed 's/[^=]*=//'`; shift;;
+ --with-auto-host-h=*) auto_host_h=`echo "$1" | sed 's/[^=]*=//'`; shift;;
+ --with-et-static=*) et_static=`echo "$1" | sed 's/[^=]*=//'`; shift;;
--srcdir=*) srcdir=`echo "$1" | sed 's/[^=]*=//'`; shift;;
--target=*) target=`echo "$1" | sed 's/[^=]*=//'`; shift;;
--prefix=*) prefix=`echo "$1" | sed 's/[^=]*=//'`; shift;;
--with-gcc=*) GCC_UNDER_TEST=`echo "$1" | sed 's/[^=]*=//'`; shift;;
--with-g++=*) GXX_UNDER_TEST=`echo "$1" | sed 's/[^=]*=//'`; shift;;
--with-gfortran=*) GFORTRAN_UNDER_TEST=`echo "$1" | sed 's/[^=]*=//'`; shift;;
+ --with-objc=*) OBJC_UNDER_TEST=`echo "$1" | sed 's/[^=]*=//'`; shift;;
--with-alt-cc=*) ALT_CC_UNDER_TEST=`echo "$1" | sed 's/[^=]*=//'`; shift;;
--with-alt-cxx=*) ALT_CXX_UNDER_TEST=`echo "$1" | sed 's/[^=]*=//'`; shift;;
--with-compat-options=*) COMPAT_OPTIONS=`echo "$1" | sed 's/[^=]*=//'`; shift;;
--help prints this page
--with-testsuite=/some/dir/gcc/testsuite specify the testsuite directory
+--with-auto-host-h=/some/dir/auto-host.h specify auto-host.h
+--with-et-static=/some/dir/et-static.exp specify et-static.exp
--srcdir=/some/dir same as --with-testsuite=/some/dir/gcc/testsuite
[deduced from shell-script pathname]
--with-gcc=/some/dir/bin/gcc use specified gcc program [gcc]
--with-g++=/some/dir/bin/g++ use specified g++ program [g++]
--with-gfortran=/some/dir/bin/gfortran use specified gfortran program [gfortran]
+--with-objc=/some/dir/bin/gcc use specified gcc program [gcc]
--with-alt-cc=/some/compiler use specified alternative compiler in compat tests
--with-alt-cxx=/some/compiler use specified alternative compiler in compat tests
--with-compat-options=opts use specified COMPAT_OPTIONS in compat tests
srcdir=$top_srcdir
fi
+# Prefer et-static.exp explicitly specified. Alternatively, generate one
+# from the specified auto-host.h.
+if test x"${et_static+set}" != x"set" && test x"${auto_host_h+set}" = x"set"; then
+ gcc_srcdir=${srcdir}/gcc
+ awk -f ${gcc_srcdir}/et-gather.awk \
+ ${gcc_srcdir}/testsuite/lib/et-static.def > etlist
+ awk -f ${gcc_srcdir}/gen-et-static.awk -v etlist=etlist \
+ ${auto_host_h} > et-static.exp
+ et_static=et-static.exp
+fi
+
+# If neither option has been given, the testsuite will use the et-static.exp
+# from the installed compiler.
+
cat >site.exp <<EOF
set rootme "."
set tmpdir "${tmpdir-`${PWDCMD-pwd}`}"
set libiconv "$libiconv"
set CFLAGS ""
set CXXFLAGS ""
+EOF
+test x"${GCC_UNDER_TEST}" = x"no" || cat >>site.exp <<EOF
set GCC_UNDER_TEST "${GCC_UNDER_TEST-${prefix}${prefix+/bin/}\
${target+$target-}gcc}"
+EOF
+test x"${GXX_UNDER_TEST}" = x"no" || cat >>site.exp <<EOF
set GXX_UNDER_TEST "${GXX_UNDER_TEST-${prefix}${prefix+/bin/}\
${target+$target-}g++}"
+EOF
+test x"${GFORTRAN_UNDER_TEST}" = x"no" || cat >>site.exp <<EOF
set GFORTRAN_UNDER_TEST "${GFORTRAN_UNDER_TEST-${prefix}${prefix+/bin/}\
${target+$target-}gfortran}"
+EOF
+test x"${OBJCC_UNDER_TEST}" = x"no" || cat >>site.exp <<EOF
set OBJC_UNDER_TEST "${OBJC_UNDER_TEST-${prefix}${prefix+/bin/}\
${target+$target-}gcc}"
+EOF
+cat >>site.exp <<EOF
set HOSTCC "${HOSTCC-cc}"
set HOSTCXX "${HOSTCXX-c++}"
set HOSTCFLAGS ""
set HOSTCXXFLAGS ""
EOF
+if test x${et_static+set} = xset; then
+ echo "set et_static \"${et_static}\"" >> site.exp
+fi
if test x${target} != x; then
target_canonical=`$top_srcdir/config.sub $target`
echo "set target_triplet $target_canonical" >> site.exp
plugin_includedir = $(plugin_resourcesdir)/include
# Directory in which plugin specific executables are installed
plugin_bindir = $(libexecsubdir)/plugin
+# Directory where files for installed testing are installed
+testsuitedir = $(libsubdir)/testsuite
# Used to produce a relative $(gcc_tooldir) in gcc.o
ifeq ($(enable_as_accelerator),yes)
unlibsubdir = ../../../../..
rest.encap: lang.rest.encap
# This is what is made with the host's compiler
# whether making a cross compiler or not.
-native: config.status auto-host.h build-@POSUB@ $(LANGUAGES) \
+native: config.status auto-host.h testsuite/et-static.exp build-@POSUB@ \
+ $(LANGUAGES) \
$(EXTRA_PROGRAMS) $(COLLECT2) lto-wrapper$(exeext) \
gcc-ar$(exeext) gcc-nm$(exeext) gcc-ranlib$(exeext)
-rm -f libgcc_s*
-rm -f libunwind*
-rm -f config.h tconfig.h bconfig.h tm_p.h tm.h
+ -rm -f etlist
-rm -f options.cc options.h optionlist
-rm -f cs-*
-rm -f doc/*.dvi
-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)
# broken is small.
install: install-common $(INSTALL_HEADERS) \
install-cpp install-man install-info install-@POSUB@ \
- install-driver install-lto-wrapper install-gcc-ar
+ install-driver install-lto-wrapper install-gcc-ar install-testsuite
ifeq ($(enable_plugin),yes)
install: install-plugin
done; \
fi
+# Install files needed for installed testing.
+install-testsuite: testsuite/et-static.exp auto-host.h installdirs
+ $(mkinstalldirs) $(DESTDIR)$(testsuitedir)
+ $(INSTALL_DATA) testsuite/et-static.exp $(DESTDIR)$(testsuitedir)/et-static.exp
+ $(INSTALL_DATA) auto-host.h $(DESTDIR)$(testsuitedir)/auto-host.h
+
# Cancel installation by deleting the installed files.
uninstall: lang.uninstall
-rm -rf $(DESTDIR)$(libsubdir)
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
-e '1,/^## All variables above are.*##/ d' >> site.exp
-@rm -f ./site.tmp
+testsuite/et-static.exp: $(srcdir)/et-gather.awk $(srcdir)/gen-et-static.awk \
+ $(srcdir)/testsuite/lib/et-static.def Makefile auto-host.h
+ $(AWK) -f $(srcdir)/et-gather.awk $(srcdir)/testsuite/lib/et-static.def > etlist
+ -test -d $(TESTSUITEDIR) || mkdir $(TESTSUITEDIR)
+ $(AWK) -f $(srcdir)/gen-et-static.awk -v etlist=etlist auto-host.h > $@
+
CHECK_TARGETS = @check_languages@
check: $(CHECK_TARGETS)
Effective-target keywords are defined in @file{lib/target-supports.exp} in
the GCC testsuite, with the exception of those that are documented as
-being local to a particular test directory.
+being local to a particular test directory. Effective-target keywords
+matching @file{auto-host.h} macros can be generated from definitions
+in @file{lib/et-static.def}.
The @samp{effective target} takes into account all of the compiler options
with which the test will be compiled, including the multilib options.
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.
--- /dev/null
+# Copyright (C) 2026 Free Software Foundation, Inc.
+# Based on opt-gather.awk.
+#
+# 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 et-static.def and creates a three-field list
+# suitable for input into gen-et-static.awk.
+#
+# Usage: awk -f et-gather.awk et-static.def > outputfile
+
+BEGIN { numrec = 0 }
+
+# Ignore comments and blank lines
+/^[ \t]*(#|$)/ { flag = 0; next }
+/^[^ \t]/ { if (flag == 0) {
+ record[++numrec] = $0
+ flag = 1 }
+ else {
+ record[numrec] = record[numrec] SUBSEP $0
+ }
+}
+
+END {
+ for (i = 1; i <= numrec; i++) {
+ print record[i] }
+}
--- /dev/null
+# 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 input file (usually auto-host.h) and effective target
+# definitions from preprocessed et-static.def, and writes et-static.exp
+# implementing checks for select effective-target keywords.
+#
+# Usage: awk -v etlist=<path to etlist> -f gen-et-static.awk <input file>
+
+BEGIN {
+ input = ARGV[1]
+
+ SAVEFS=FS
+ FS=SUBSEP
+
+ # Read preprocessed et-static.def. Each line consists of
+ # <effective-target> <macro> <comment>.
+ while ((getline < etlist) > 0) {
+ et[$2] = $1
+ comment[$2] = $3
+ }
+ close(etlist)
+
+ FS=SAVEFS
+}
+
+function emit_effective_target(name, value, comment)
+{
+ print "";
+ print "# " comment;
+ print "proc check_effective_target_" name " { } {";
+ print " return " value;
+ print "}";
+}
+
+# #define <MACRO> <value>
+/^#define/ { value[$2] = $3 }
+
+# /* #undef <MACRO> */
+/^\/\* #undef/ { value[$3] = 0 }
+
+END {
+ print "# This file is auto-generated by gen-et-static.awk from " input
+ print "# and et-static.def."
+
+ for (macro in et) {
+ if (macro in value) {
+ val = value[macro]
+ # Characters, strings and tri-state macros would need
+ # special handling.
+ if (val !~ /^[01]/) {
+ print "#error non-0/1/#undef value " val " for " macro
+ exit(1)
+ }
+ } else {
+ # Treat missing macros as unsupported.
+ print "#warning definition for " macro " missing"
+ val = 0
+ }
+
+ emit_effective_target(et[macro], val,
+ "Return 1 if " comment[macro] ", 0 otherwise.");
+ }
+}
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]
# Darwin's linker is not silent about missing -L values.
set ld64 [istarget *-*-darwin*]
foreach og $olist {
if { [string index $og 0] == "!" } {
global gspd ltop
- global gld ld64
+ global ld_at_file ld64
set cond [expr $og]
continue
}
# 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-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}}
if $ld64 {
# Darwin's linker warns about missing args to -L.
- outest "$b-25 exe savetmp named2-4" $mult "@$devnull -I dummy -L dummy -o $b.exe -save-temps -Wl,-w" {} {{--1.i --1.s --1.o --2.i --2.s --2.o -args.0 -args.1 .args.2 !!0 .args.3 !!$gld .ld1_args !0 .exe}}
+ outest "$b-25 exe savetmp named2-4" $mult "@$devnull -I dummy -L dummy -o $b.exe -save-temps -Wl,-w" {} {{--1.i --1.s --1.o --2.i --2.s --2.o -args.0 -args.1 .args.2 !!0 .args.3 !!$ld_at_file .ld1_args !0 .exe}}
} else {
- 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-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}}
}
}
--- /dev/null
+# Definitions of static effective targets determined from auto-host.h.
+
+# 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/>.
+
+# Each record consist of 3 lines:
+#
+# <effective target>
+# <MACRO>
+# <comment> to be emitted as "Return 0 if <comment>, 1 otherwise."
+
+# Keep this sorted alphabetically by effective-target name. */
+
+ld_at_file
+HAVE_LD_AT_FILE
+your linker supports GNU style response files
# 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
+global et_static
+
+if { ![info exists et_static] } {
+ global GCC_UNDER_TEST
+
+ if [info exists GCC_UNDER_TEST] {
+ set compiler $GCC_UNDER_TEST
+ } else {
+ set compiler [find_gcc]
+ }
+
+ set output [remote_exec host "$compiler -print-file-name=testsuite/et-static.exp"]
+ set et_static [string trim [lindex $output 1]]
+}
+
+if { ![file exists $et_static] } {
+ error "Couldn't find $et_static."
+}
+
+load_file $et_static
+
# 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