]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Support plugin testing for installed compiler
authorJoseph Myers <josmyers@redhat.com>
Mon, 15 Dec 2025 17:58:20 +0000 (17:58 +0000)
committerJoseph Myers <josmyers@redhat.com>
Mon, 15 Dec 2025 17:58:20 +0000 (17:58 +0000)
Plugin tests are currently only enabled for build-tree testing.
Enable them for installed testing as well, using
-print-file-name=plugin/include to locate the installed headers in
that case.

Support is also added to contrib/test_installed for the associated
site.exp settings.  Installed testing also shows up that some plugin
tests are using text-art/*.h headers that aren't currently installed,
so add those to PLUGIN_HEADERS.

Bootstrapped with no regressions for x86_64-pc-linux-gnu, and also ran
plugin tests for an installed compiler with contrib/test_installed.

contrib/
* test_installed (--enable-plugin, --with-plugincc=)
(--with-plugincflags=, --with-gmpinc=): New options.

gcc/
* Makefile.in (PLUGIN_HEADERS): Add $(srcdir)/text-art/*.h.
(install-plugin): Preserve directory structure for text-art
headers.

gcc/testsuite/
* lib/plugin-support.exp (plugin-test-execute): Support installed
testing.
* g++.dg/plugin/plugin.exp, gcc.dg/plugin/plugin.exp,
obj-c++.dg/plugin/plugin.exp, objc.dg/plugin/plugin.exp: Do not
disable for installed testing.

contrib/test_installed
gcc/Makefile.in
gcc/testsuite/g++.dg/plugin/plugin.exp
gcc/testsuite/gcc.dg/plugin/plugin.exp
gcc/testsuite/lib/plugin-support.exp
gcc/testsuite/obj-c++.dg/plugin/plugin.exp
gcc/testsuite/objc.dg/plugin/plugin.exp

index 530d21ed74eca2848945a5216c9e09bf662cc3a1..9567ace54b3d0261e286de65f868abbafe9f42a3 100755 (executable)
@@ -49,6 +49,7 @@ while true; do
   --srcdir=*) srcdir=`echo "$1" | sed 's/[^=]*=//'`; shift;;
   --target=*) target=`echo "$1" | sed 's/[^=]*=//'`; shift;;
   --prefix=*) prefix=`echo "$1" | sed 's/[^=]*=//'`; shift;;
+  --enable-plugin) ENABLE_PLUGIN=1; 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;;
@@ -56,6 +57,9 @@ while true; do
   --with-alt-cxx=*) ALT_CXX_UNDER_TEST=`echo "$1" | sed 's/[^=]*=//'`; shift;;
   --with-compat-options=*) COMPAT_OPTIONS=`echo "$1" | sed 's/[^=]*=//'`; shift;;
   --with-libiconv=*) libiconv=`echo "$1" | sed 's/[^=]*=//'`; shift;;
+  --with-plugincc=*) PLUGINCC=`echo "$1" | sed 's/[^=]*=//'`; shift;;
+  --with-plugincflags=*) PLUGINCFLAGS=`echo "$1" | sed 's/[^=]*=//'`; shift;;
+  --with-gmpinc=*) GMPINC=`echo "$1" | sed 's/[^=]*=//'`; shift;;
   --without-gcc) GCC_UNDER_TEST=no; shift;;
   --without-g++) GXX_UNDER_TEST=no; shift;;
   --without-gfortran) GFORTRAN_UNDER_TEST=no; shift;;
@@ -80,6 +84,7 @@ Supported arguments:
                               tested if different than the host.
 
 --prefix=/some/dir            use gcc, g++ and gfortran from /some/dir/bin [PATH]
+--enable-plugin               run GCC plugin tests
 --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]
@@ -87,6 +92,9 @@ Supported arguments:
 --with-alt-cxx=/some/compiler use specified alternative compiler in compat tests
 --with-compat-options=opts    use specified COMPAT_OPTIONS in compat tests
 --with-libiconv=linker-args   use given arguments to link with iconv [-liconv]
+--with-plugincc=/some/c++     use given host compiler to build plugins [g++]
+--with-plugincflags=args      use given options to build plugins [-g -O2]
+--with-gmpinc=args            use given options to find GMP for host []
 --without-gcc                 do not run gcc testsuite
 --without-g++                 do not run g++ testsuite
 --without-gfortran            do not run gfortran testsuite
@@ -146,6 +154,12 @@ fi
 if test x"$COMPAT_OPTIONS" != x; then
   echo "set COMPAT_OPTIONS \"${COMPAT_OPTIONS}\"" >> site.exp
 fi
+if test x"$ENABLE_PLUGIN" != x; then
+    echo "set ENABLE_PLUGIN \"${ENABLE_PLUGIN}\"" >> site.exp
+    echo "set PLUGINCC \"${PLUGINCC-g++}\"" >> site.exp
+    echo "set PLUGINCFLAGS \"${PLUGINCFLAGS--g -O2}\"" >> site.exp
+    echo "set GMPINC \"${GMPINC}\"" >> site.exp
+fi
 
 test x"${GCC_UNDER_TEST}" = x"no" || runtest --tool gcc ${1+"$@"}
 test x"${GXX_UNDER_TEST}" = x"no" || runtest --tool g++ ${1+"$@"}
index f60494ffa441f36e3e0d21659705195a91e1fa12..e099fc1bb094aafacd3da8e499be9cf741a2c200 100644 (file)
@@ -4140,7 +4140,8 @@ PLUGIN_HEADERS = $(TREE_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
   hash-set.h dominance.h cfg.h cfgrtl.h cfganal.h cfgbuild.h cfgcleanup.h \
   lcm.h cfgloopmanip.h file-prefix-map.h builtins.def $(INSN_ATTR_H) \
   pass-instances.def params.list $(srcdir)/../include/gomp-constants.h \
-  $(EXPR_H) $(srcdir)/analyzer/*.h $(srcdir)/diagnostics/*.h
+  $(EXPR_H) $(srcdir)/analyzer/*.h $(srcdir)/diagnostics/*.h \
+  $(srcdir)/text-art/*.h
 
 # generate the 'build fragment' b-header-vars
 s-header-vars: Makefile
@@ -4179,6 +4180,7 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype
          case $$path in \
          "$(srcdir)"/analyzer/* \
          | "$(srcdir)"/diagnostics/* \
+         | "$(srcdir)"/text-art/* \
          | "$(srcdir)"/config/* | "$(srcdir)"/common/config/* \
          | "$(srcdir)"/c-family/* | "$(srcdir)"/*.def ) \
            base=`echo "$$path" | sed -e "s|$$srcdirstrip/||"`;; \
index 9410fea6d7d98bd05cf53834e82e60c602b2de38..2615f31158cbed5e05f702af4602493484753cfd 100644 (file)
 load_lib target-supports.exp
 load_lib g++-dg.exp
 
-global TESTING_IN_BUILD_TREE
 global ENABLE_PLUGIN
 
-# The plugin testcases currently only work when the build tree is available.
-# Also check whether the host supports plugins.
-if { ![info exists TESTING_IN_BUILD_TREE] || ![info exists ENABLE_PLUGIN] } {
+# Check whether the host supports plugins.
+if { ![info exists ENABLE_PLUGIN] } {
     return
 }
 
index 83ef1b2dd939774ed1228fda8c34c7a6eaade66b..9894b4a461577e14a7bc0ac98c897b593c1b6e16 100644 (file)
 load_lib target-supports.exp
 load_lib gcc-dg.exp
 
-global TESTING_IN_BUILD_TREE
 global ENABLE_PLUGIN
 
-# The plugin testcases currently only work when the build tree is available.
-# Also check whether the host supports plugins.
-if { ![info exists TESTING_IN_BUILD_TREE] || ![info exists ENABLE_PLUGIN] } {
+# Check whether the host supports plugins.
+if { ![info exists ENABLE_PLUGIN] } {
     return
 }
 
index 9188adbdf2f729e78272378cba277a173628a27e..b2e76a7993149c3832a39af276d5d2d4423cc6f6 100644 (file)
@@ -62,9 +62,11 @@ proc plugin-get-options { src } {
 proc plugin-test-execute { plugin_src plugin_tests } {
     global srcdir objdir
     global verbose
+    global tool
     global GMPINC
     global PLUGINCC
     global PLUGINCFLAGS
+    global TESTING_IN_BUILD_TREE
 
     set basename [file tail $plugin_src]
     set base [file rootname $basename]
@@ -76,16 +78,17 @@ proc plugin-test-execute { plugin_src plugin_tests } {
     # Build the plugin itself
     set extra_flags [plugin-get-options $plugin_src]
 
-    # Note that the plugin test support currently only works when the GCC
-    # build tree is available. (We make sure that is the case in plugin.exp.)
-    # Once we have figured out how/where to package/install GCC header files
-    # for general plugin support, we should modify the following include paths
-    # accordingly.
-    set gcc_srcdir "$srcdir/../.."
-    set gcc_objdir "$objdir/../../.."
-    set includes "-I. -I${srcdir} -I${gcc_srcdir}/gcc -I${gcc_objdir}/gcc \
+    if { [info exists TESTING_IN_BUILD_TREE] } {
+       set gcc_srcdir "$srcdir/../.."
+       set gcc_objdir "$objdir/../../.."
+       set includes "-I. -I${srcdir} -I${gcc_srcdir}/gcc -I${gcc_objdir}/gcc \
                   -I${gcc_srcdir}/include -I${gcc_srcdir}/libcpp/include \
                   $GMPINC -I${gcc_objdir}/gettext/intl"
+    } else {
+       set options [list "additional_flags=-print-file-name=plugin/include"]
+       set plugin_inc [lindex [${tool}_target_compile "" "" "none" $options] 0]
+       set includes "-I. -I${srcdir} -I${plugin_inc} $GMPINC"
+    }
 
     if { [ ishost *-*-darwin* ] } {
        # -mdynamic-no-pic is incompatible with -fPIC.
index ad2ca18bf20b1a4e06353451404e4c9774fc0bca..1de7df886c02709951692948b439a652c6ebb992 100644 (file)
 load_lib target-supports.exp
 load_lib obj-c++-dg.exp
 
-global TESTING_IN_BUILD_TREE
 global ENABLE_PLUGIN
 
-# The plugin testcases currently only work when the build tree is available.
-# Also check whether the host supports plugins.
-if { ![info exists TESTING_IN_BUILD_TREE] || ![info exists ENABLE_PLUGIN] } {
+# Check whether the host supports plugins.
+if { ![info exists ENABLE_PLUGIN] } {
     return
 }
 
index d03ec729aa7e1bccd5469cd8446521149a1240be..a508a433fcf2c8232de27bf37f475a160cd3bc1c 100644 (file)
 load_lib target-supports.exp
 load_lib objc-dg.exp
 
-global TESTING_IN_BUILD_TREE
 global ENABLE_PLUGIN
 
-# The plugin testcases currently only work when the build tree is available.
-# Also check whether the host supports plugins.
-if { ![info exists TESTING_IN_BUILD_TREE] || ![info exists ENABLE_PLUGIN] } {
+# Check whether the host supports plugins.
+if { ![info exists ENABLE_PLUGIN] } {
     return
 }