modula2: PR-108119 Disable m2 plugin m2rte

Message ID 877cyl0wb8.fsf@debian
State Accepted
Headers
Series modula2: PR-108119 Disable m2 plugin m2rte |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Gaius Mulley Dec. 21, 2022, 12:34 p.m. UTC
  Hello,

PR-108119 Disable m2 plugin m2rte (provide --enable-m2plugin configure option).

The m2 plugin m2rte attempts to find reachable calls to the m2 exception
handler, but it identifies the m2 exception calls by procedure name.
As this won't work with other languages it should be disabled by default.

This patch disables the plugin from being built.  It provides a new
configure switch --enable-m2plugin to override the default and it will
check the HAVE_PLUGIN of the host and warn if there is a conflict.

Tested on x86_64 GNU/Linux bootstrapped for all languages no extra
failures (m2 tests missing as the plugin is disabled and TCL expect
now disables m2 plugin tests)

ok for trunk?

regards,
Gaius


ChangeLog:

	* Makefile.def (extra_configure_flags): Add @enable_m2plugin@.
	* Makefile.in : Rebuilt.
	* configure : Rebuilt.
	* configure.ac (host_tools): Remove unused gm2tools.
	(m2plugin) New AC_ARG_ENABLE.
	(enable_m2plugin) New AC_SUBST added.

gcc/ChangeLog:

	* Makefile.in (enable_m2plugin): Added.
	(site.exp): New variable ENABLE_M2PLUGIN.
	* config.in: Rebuilt.
	* configure : Rebuilt.
	* gcc/configure.ac (m2plugin): New AC_ARG_ENABLE.
	(enable_m2plugin) New AC_SUBST added.
	* doc/install.texi (--enable-m2plugin): Documented.

gcc/m2/ChangeLog:

	* gm2spec.cc (ENABLE_PLUGIN): Replaced by ENABLE_M2PLUGIN.  Ensure
	that OPT_fplugin option is only created if ENABLE_M2PLUGIN is
	defined.
	(lang_specific_driver) Change warning to mention
	--enable-m2plugin.
	* Make-lang.in (enable_m2plugin): Set to no if enable_plugin is
	no.
	(M2RTE_PLUGIN_SO) New definition.
	(m2.all.cross) Use M2RTE_PLUGIN_SO.
	(m2.start.encap) Use M2RTE_PLUGIN_SO.
	(m2.install-plugin) Use M2RTE_PLUGIN_SO.
	(m2.install-plugin) Add dummy rule when enable_m2plugin is no.
	(plugin/m2rte$(exeext).so) Add dummy rule when enable_m2plugin is
	no.
	(stage1/m2/cc1gm2$(exeext) Use M2RTE_PLUGIN_SO.
	(stage2/m2/cc1gm2$(exeext) Use M2RTE_PLUGIN_SO.

gcc/testsuite/ChangeLog:

	* gm2/coroutines/pim/run/pass/coroutines-pim-run-pass.exp
	(ENABLE_M2PLUGIN): Checked to see whether the test should be ignored.
	* gm2/iso/check/fail/iso-check-fail.exp	(ENABLE_M2PLUGIN): Ditto.
	* gm2/switches/auto-init/fail/switches-auto-init-fail.exp
	(ENABLE_M2PLUGIN): Ditto.
	* gm2/switches/check-all/pim2/fail/switches-check-all-pim2-fail.exp
	(ENABLE_M2PLUGIN): Ditto.
	* gm2/switches/check-all/plugin/iso/fail/switches-check-all-plugin-iso-fail.exp
	(ENABLE_M2PLUGIN): Ditto.
	* gm2/switches/check-all/plugin/pim2/fail/switches-check-all-plugin-pim2-fail.exp
	(ENABLE_M2PLUGIN): Ditto.
  

Comments

Richard Biener Dec. 21, 2022, 12:51 p.m. UTC | #1
On Wed, Dec 21, 2022 at 1:35 PM Gaius Mulley via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
>
> Hello,
>
> PR-108119 Disable m2 plugin m2rte (provide --enable-m2plugin configure option).
>
> The m2 plugin m2rte attempts to find reachable calls to the m2 exception
> handler, but it identifies the m2 exception calls by procedure name.
> As this won't work with other languages it should be disabled by default.
>
> This patch disables the plugin from being built.  It provides a new
> configure switch --enable-m2plugin to override the default and it will
> check the HAVE_PLUGIN of the host and warn if there is a conflict.
>
> Tested on x86_64 GNU/Linux bootstrapped for all languages no extra
> failures (m2 tests missing as the plugin is disabled and TCL expect
> now disables m2 plugin tests)
>
> ok for trunk?
>
> regards,
> Gaius
>
>
> ChangeLog:
>
>         * Makefile.def (extra_configure_flags): Add @enable_m2plugin@.
>         * Makefile.in : Rebuilt.
>         * configure : Rebuilt.
>         * configure.ac (host_tools): Remove unused gm2tools.
>         (m2plugin) New AC_ARG_ENABLE.
>         (enable_m2plugin) New AC_SUBST added.

Why's this at the toplevel?

>
> gcc/ChangeLog:
>
>         * Makefile.in (enable_m2plugin): Added.
>         (site.exp): New variable ENABLE_M2PLUGIN.
>         * config.in: Rebuilt.
>         * configure : Rebuilt.
>         * gcc/configure.ac (m2plugin): New AC_ARG_ENABLE.
>         (enable_m2plugin) New AC_SUBST added.
>         * doc/install.texi (--enable-m2plugin): Documented.

Likewise - shouldn't this be in gcc/m2/?

>
> gcc/m2/ChangeLog:
>
>         * gm2spec.cc (ENABLE_PLUGIN): Replaced by ENABLE_M2PLUGIN.  Ensure
>         that OPT_fplugin option is only created if ENABLE_M2PLUGIN is
>         defined.
>         (lang_specific_driver) Change warning to mention
>         --enable-m2plugin.
>         * Make-lang.in (enable_m2plugin): Set to no if enable_plugin is
>         no.
>         (M2RTE_PLUGIN_SO) New definition.
>         (m2.all.cross) Use M2RTE_PLUGIN_SO.
>         (m2.start.encap) Use M2RTE_PLUGIN_SO.
>         (m2.install-plugin) Use M2RTE_PLUGIN_SO.
>         (m2.install-plugin) Add dummy rule when enable_m2plugin is no.
>         (plugin/m2rte$(exeext).so) Add dummy rule when enable_m2plugin is
>         no.
>         (stage1/m2/cc1gm2$(exeext) Use M2RTE_PLUGIN_SO.
>         (stage2/m2/cc1gm2$(exeext) Use M2RTE_PLUGIN_SO.
>
> gcc/testsuite/ChangeLog:
>
>         * gm2/coroutines/pim/run/pass/coroutines-pim-run-pass.exp
>         (ENABLE_M2PLUGIN): Checked to see whether the test should be ignored.
>         * gm2/iso/check/fail/iso-check-fail.exp (ENABLE_M2PLUGIN): Ditto.
>         * gm2/switches/auto-init/fail/switches-auto-init-fail.exp
>         (ENABLE_M2PLUGIN): Ditto.
>         * gm2/switches/check-all/pim2/fail/switches-check-all-pim2-fail.exp
>         (ENABLE_M2PLUGIN): Ditto.
>         * gm2/switches/check-all/plugin/iso/fail/switches-check-all-plugin-iso-fail.exp
>         (ENABLE_M2PLUGIN): Ditto.
>         * gm2/switches/check-all/plugin/pim2/fail/switches-check-all-plugin-pim2-fail.exp
>         (ENABLE_M2PLUGIN): Ditto.
>
> diff --git a/Makefile.def b/Makefile.def
> index 5f44190154e..d33e4528b63 100644
> --- a/Makefile.def
> +++ b/Makefile.def
> @@ -103,7 +103,7 @@ host_modules= { module= libiberty; bootstrap=true;
>  // @extra_linker_plugin_flags@ and @extra_linker_plugin_configure_flags@.
>  host_modules= { module= libiberty-linker-plugin; bootstrap=true;
>                 module_srcdir=libiberty;
> -               extra_configure_flags='@extra_host_libiberty_configure_flags@ --disable-install-libiberty @extra_linker_plugin_flags@ @extra_linker_plugin_configure_flags@';
> +               extra_configure_flags='@extra_host_libiberty_configure_flags@ --disable-install-libiberty @extra_linker_plugin_flags@ @extra_linker_plugin_configure_flags@ @enable_m2plugin@';
>                 extra_make_flags='@extra_linker_plugin_flags@'; };
>  // We abuse missing to avoid installing anything for libiconv.
>  host_modules= { module= libiconv;
> diff --git a/configure.ac b/configure.ac
> index c5191ce24ae..b771f61ef33 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -140,7 +140,7 @@ host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktr
>  # binutils, gas and ld appear in that order because it makes sense to run
>  # "make check" in that particular order.
>  # If --enable-gold is used, "gold" may replace "ld".
> -host_tools="texinfo flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gdbserver gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gm2tools gotools c++tools"
> +host_tools="texinfo flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gdbserver gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gotools c++tools"
>
>  # these libraries are built for the target environment, and are built after
>  # the host libraries and the host tools (which may be a cross compiler)
> @@ -465,13 +465,22 @@ if test "${ENABLE_LIBADA}" != "yes" ; then
>    noconfigdirs="$noconfigdirs gnattools"
>  fi
>
> +
>  AC_ARG_ENABLE(libgm2,
>  [AS_HELP_STRING([--enable-libgm2], [build libgm2 directory])],
>  ENABLE_LIBGM2=$enableval,
>  ENABLE_LIBGM2=no)
> -if test "${ENABLE_LIBGM2}" != "yes" ; then
> -  noconfigdirs="$noconfigdirs gm2tools"
> +
> +
> +AC_ARG_ENABLE(m2plugin,
> +[AS_HELP_STRING([--enable-m2plugin], [enable m2rte plugin])],
> +enable_m2plugin=$enableval,
> +enable_m2plugin=yes)
> +if test "${enable_m2plugin}" != "yes" ; then
> +  enable_m2plugin=no
>  fi
> +AC_SUBST(enable_m2plugin)
> +
>
>  AC_ARG_ENABLE(libssp,
>  [AS_HELP_STRING([--enable-libssp], [build libssp directory])],
> diff --git a/gcc/Makefile.in b/gcc/Makefile.in
> index 995d77f96c4..46bdcb730aa 100644
> --- a/gcc/Makefile.in
> +++ b/gcc/Makefile.in
> @@ -404,6 +404,8 @@ PLUGINCFLAGS = @CXXFLAGS@
>  PLUGINLIBS = @pluginlibs@
>
>  enable_plugin = @enable_plugin@
> +# Should we build the m2plugin?
> +enable_m2plugin = @enable_m2plugin@
>
>  # On MinGW plugin installation involves installing import libraries.
>  ifeq ($(enable_plugin),yes)
> @@ -4101,6 +4103,9 @@ site.exp: ./config.status Makefile
>           echo "set PLUGINCFLAGS \"$(PLUGINCFLAGS)\"" >> ./site.tmp; \
>           echo "set GMPINC \"$(GMPINC)\"" >> ./site.tmp; \
>         fi
> +       @if test "@enable_m2plugin@" = "yes" ; then \
> +         echo "set ENABLE_M2PLUGIN 1" >> ./site.tmp; \
> +       fi
>  # If newlib has been configured, we need to pass -B to gcc so it can find
>  # newlib's crt0.o if it exists.  This will cause a "path prefix not used"
>  # message if it doesn't, but the testsuite is supposed to ignore the message -
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 5efbf11793c..61052d4a2bc 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -1011,6 +1011,7 @@ analyzer=1)
>  AC_DEFINE_UNQUOTED(ENABLE_ANALYZER, $analyzer,
>  [Define 0/1 if static analyzer feature is enabled.])
>
> +
>  AC_ARG_ENABLE(objc-gc,
>  [AS_HELP_STRING([--enable-objc-gc],
>                 [enable the use of Boehm's garbage collector with
> @@ -7375,6 +7376,26 @@ if test x"$enable_plugin" = x"yes"; then
>  fi
>
>
> +AC_ARG_ENABLE(m2plugin,
> +[AS_HELP_STRING([--enable-m2plugin],
> +               [enable the modula-2 static analysis plugin])],
> +if test x$enable_m2plugin = xno; then
> +  m2plugin=0
> +else
> +  if test x"$enable_plugin" = x"yes"; then
> +     m2plugin=1
> +  else
> +     m2plugin=0
> +     AC_MSG_WARN([modula-2 plugin is disabled as the host has disabled plugins])
> +  fi
> +fi,
> +m2plugin=0)
> +if test x"$enable_m2plugin" = x"yes"; then
> +  AC_DEFINE(ENABLE_M2PLUGIN, 1, [Define to enable m2plugin support.])
> +fi
> +AC_SUBST(enable_m2plugin)
> +
> +
>  # Enable --enable-host-shared
>  AC_ARG_ENABLE(host-shared,
>  [AS_HELP_STRING([--enable-host-shared],
> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
> index 6884a74936b..b1966369ff2 100644
> --- a/gcc/doc/install.texi
> +++ b/gcc/doc/install.texi
> @@ -1926,6 +1926,9 @@ do a @samp{make -C gcc gnatlib_and_tools}.
>  Specify that the run-time libraries and tools used by Modula-2 should not
>  be built.  This can be useful for debugging.
>
> +@item --enable-m2plugin
> +Specify that the modula-2 static analysis plugin should be built.
> +
>  @item --disable-libsanitizer
>  Specify that the run-time libraries for the various sanitizers should
>  not be built.
> diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
> index a8bd7fe4d19..3d9c84f7607 100644
> --- a/gcc/m2/Make-lang.in
> +++ b/gcc/m2/Make-lang.in
> @@ -82,6 +82,18 @@ PGE=m2/pge$(exeext)
>
>  SRC_PREFIX=G
>
> +ifeq ($(enable_plugin),no)
> +# Override enable_m2plugin if host does not support plugins.
> +ifeq ($(enable_m2plugin),yes)
> +$(warning modula-2 plugin will be disabled as the host does not support plugins)
> +endif
> +enable_m2plugin=no
> +endif
> +
> +ifeq ($(enable_m2plugin),yes)
> +M2RTE_PLUGIN_SO=plugin/m2rte$(exeext).so
> +endif
> +
>  m2/gm2spec.o: $(srcdir)/m2/gm2spec.cc $(SYSTEM_H) $(GCC_H) $(CONFIG_H) \
>                 m2/gm2config.h $(TARGET_H) $(PLUGIN_HEADERS) \
>                 $(generated_files) $(C_TREE_H) insn-attr-common.h
> @@ -114,9 +126,9 @@ po-generated:
>
>  # Build hooks:
>
> -m2.all.cross: gm2-cross$(exeext) plugin/m2rte$(exeext).so
> +m2.all.cross: gm2-cross$(exeext) $(M2RTE_PLUGIN_SO)
>
> -m2.start.encap: gm2$(exeext) plugin/m2rte$(exeext).so
> +m2.start.encap: gm2$(exeext) $(M2RTE_PLUGIN_SO)
>  m2.rest.encap:
>
>
> @@ -401,16 +413,22 @@ m2.uninstall:
>         -rm -rf $(bindir)/$(GM2_INSTALL_NAME)
>         -rm -rf $(bindir)/$(GM2_CROSS_NAME)
>
> +
> +ifeq ($(enable_m2plugin),yes)
>  m2.install-plugin: installdirs
>         $(mkinstalldirs) $(DESTDIR)$(plugin_resourcesdir)
> -       $(INSTALL_PROGRAM) plugin/m2rte$(exeext).so $(DESTDIR)$(plugin_resourcesdir)/m2rte$(exeext).so
> +       $(INSTALL_PROGRAM) $(M2RTE_PLUGIN_SO) $(DESTDIR)$(plugin_resourcesdir)/m2rte$(exeext).so
>         chmod a+x $(DESTDIR)$(plugin_resourcesdir)/m2rte$(exeext).so
>
>  plugin/m2rte$(exeext).so: $(srcdir)/m2/plugin/m2rte.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) \
>          insn-attr-common.h insn-flags.h $(generated_files)
>         test -d plugin || mkdir plugin
> -       $(PLUGINCC) $(PLUGINCFLAGS) -fno-rtti -I. -I$(srcdir) -I$(srcdir)/m2 -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/../include -I$(srcdir)/../libcpp/include -Wall $(GMPINC) -Wno-literal-suffix -fPIC -c -o plugin/m2rte.o $(srcdir)/m2/plugin/m2rte.cc
> +       $(PLUGINCC) $(PLUGINCFLAGS) -fno-rtti -I. -I$(srcdir) -I$(srcdir)/m2 -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/../include -I$(srcdir)/../libcpp/include -I$(objdir)/../intl -Wall $(GMPINC) -Wno-literal-suffix -fPIC -c -o plugin/m2rte.o $(srcdir)/m2/plugin/m2rte.cc
>         $(PLUGINCC) $(PLUGINCFLAGS) $(PLUGINLIBS) -fno-rtti plugin/m2rte.o -shared -o $@
> +else
> +m2.install-plugin:
> +plugin/m2rte$(exeext).so:
> +endif
>
>
>  # Clean hooks:
> @@ -526,7 +544,7 @@ cc1gm2$(exeext): stage1/m2/cc1gm2$(exeext) $(m2.prev)
>
>  stage2/m2/cc1gm2$(exeext): stage1/m2/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(P) \
>                              $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS) \
> -                            m2/gm2-gcc/rtegraph.o plugin/m2rte$(exeext).so m2/gm2-libs-boot/M2LINK.o
> +                            m2/gm2-gcc/rtegraph.o $(M2RTE_PLUGIN_SO) m2/gm2-libs-boot/M2LINK.o
>         @$(call LINK_PROGRESS,$(INDEX.m2),start)
>         +$(LLINKER) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GM2_C_OBJS) m2/gm2-compiler/m2flex.o \
>                              attribs.o \
> @@ -538,7 +556,7 @@ stage2/m2/cc1gm2$(exeext): stage1/m2/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(
>  stage1/m2/cc1gm2$(exeext): gm2$(exeext) m2/gm2-compiler-boot/m2flex.o \
>                              $(P) $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) \
>                              $(GM2_LIBS_BOOT) $(MC_LIBS) \
> -                            m2/gm2-gcc/rtegraph.o plugin/m2rte$(exeext).so \
> +                            m2/gm2-gcc/rtegraph.o $(M2RTE_PLUGIN_SO) \
>                              m2/gm2-libs-boot/M2LINK.o \
>                              $(m2.prev)
>         @$(call LINK_PROGRESS,$(INDEX.m2),start)
> diff --git a/gcc/m2/gm2spec.cc b/gcc/m2/gm2spec.cc
> index 680dd3602ef..49ad14038d2 100644
> --- a/gcc/m2/gm2spec.cc
> +++ b/gcc/m2/gm2spec.cc
> @@ -610,7 +610,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
>    /* The number of libraries added in.  */
>    int added_libraries;
>
> -#ifdef ENABLE_PLUGIN
> +#ifdef ENABLE_M2PLUGIN
>    /* True if we should add -fplugin=m2rte to the command-line.  */
>    bool need_plugin = true;
>  #else
> @@ -678,10 +678,10 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
>            break;
>          case OPT_fm2_plugin:
>            need_plugin = decoded_options[i].value;
> -#ifndef ENABLE_PLUGIN
> +#ifndef ENABLE_M2PLUGIN
>           if (need_plugin)
>             error ("plugin support is disabled; configure with "
> -                  "%<--enable-plugin%>");
> +                  "%<--enable-m2plugin%>");
>  #endif
>            break;
>         case OPT_fscaffold_dynamic:
> @@ -802,7 +802,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
>                "-fgen-module-list=", "-fuse-list=");
>      }
>
> -
>    /* There's no point adding -shared-libgcc if we don't have a shared
>       libgcc.  */
>  #ifndef ENABLE_SHARED_LIBGCC
> @@ -848,7 +847,8 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
>    if (allow_libraries)
>      {
>        /* If the libraries have not been specified by the user but the
> -        dialect has been specified then select the appropriate libraries.  */
> +        dialect has been specified then select the appropriate
> +        libraries.  */
>        if (libraries == NULL)
>         {
>           if (strcmp (dialect, "iso") == 0)
> @@ -865,8 +865,10 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
>    if ((! seen_x_flag) && seen_module_extension)
>      append_option (OPT_x, "modula-2", 1);
>
> +#ifdef ENABLE_M2PLUGIN
>    if (need_plugin)
>      append_option (OPT_fplugin_, "m2rte", 1);
> +#endif
>
>    if (linking)
>      {
> diff --git a/gcc/testsuite/gm2/iso/check/fail/iso-check-fail.exp b/gcc/testsuite/gm2/iso/check/fail/iso-check-fail.exp
> index a519f839f90..4aa02ef61fb 100644
> --- a/gcc/testsuite/gm2/iso/check/fail/iso-check-fail.exp
> +++ b/gcc/testsuite/gm2/iso/check/fail/iso-check-fail.exp
> @@ -21,10 +21,13 @@ load_lib target-supports.exp
>
>  global TESTING_IN_BUILD_TREE
>  global ENABLE_PLUGIN
> +global ENABLE_M2PLUGIN
>
>  # 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] } {
> +if { ![info exists TESTING_IN_BUILD_TREE]
> +     || ![info exists ENABLE_PLUGIN]
> +     || ![info exists ENABLE_M2PLUGIN] } {
>      return
>  }
>
> diff --git a/gcc/testsuite/gm2/switches/auto-init/fail/switches-auto-init-fail.exp b/gcc/testsuite/gm2/switches/auto-init/fail/switches-auto-init-fail.exp
> index c60027ff751..1b5488bc4da 100644
> --- a/gcc/testsuite/gm2/switches/auto-init/fail/switches-auto-init-fail.exp
> +++ b/gcc/testsuite/gm2/switches/auto-init/fail/switches-auto-init-fail.exp
> @@ -22,10 +22,13 @@ load_lib target-supports.exp
>
>  global TESTING_IN_BUILD_TREE
>  global ENABLE_PLUGIN
> +global ENABLE_M2PLUGIN
>
>  # 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] } {
> +if { ![info exists TESTING_IN_BUILD_TREE]
> +     || ![info exists ENABLE_PLUGIN]
> +     || ![info exists ENABLE_M2PLUGIN] } {
>      return
>  }
>
> diff --git a/gcc/testsuite/gm2/switches/check-all/pim2/fail/switches-check-all-pim2-fail.exp b/gcc/testsuite/gm2/switches/check-all/pim2/fail/switches-check-all-pim2-fail.exp
> index 3c654ad0b73..791ebe294b2 100644
> --- a/gcc/testsuite/gm2/switches/check-all/pim2/fail/switches-check-all-pim2-fail.exp
> +++ b/gcc/testsuite/gm2/switches/check-all/pim2/fail/switches-check-all-pim2-fail.exp
> @@ -22,10 +22,13 @@ load_lib target-supports.exp
>
>  global TESTING_IN_BUILD_TREE
>  global ENABLE_PLUGIN
> +global ENABLE_M2PLUGIN
>
>  # 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] } {
> +if { ![info exists TESTING_IN_BUILD_TREE]
> +     || ![info exists ENABLE_PLUGIN]
> +     || ![info exists ENABLE_M2PLUGIN] } {
>      return
>  }
>
> diff --git a/gcc/testsuite/gm2/switches/check-all/plugin/iso/fail/switches-check-all-plugin-iso-fail.exp b/gcc/testsuite/gm2/switches/check-all/plugin/iso/fail/switches-check-all-plugin-iso-fail.exp
> index 84a3f37e2bb..2c6b56fcca0 100644
> --- a/gcc/testsuite/gm2/switches/check-all/plugin/iso/fail/switches-check-all-plugin-iso-fail.exp
> +++ b/gcc/testsuite/gm2/switches/check-all/plugin/iso/fail/switches-check-all-plugin-iso-fail.exp
> @@ -22,10 +22,13 @@ load_lib target-supports.exp
>
>  global TESTING_IN_BUILD_TREE
>  global ENABLE_PLUGIN
> +global ENABLE_M2PLUGIN
>
>  # 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] } {
> +if { ![info exists TESTING_IN_BUILD_TREE]
> +     || ![info exists ENABLE_PLUGIN]
> +     || ![info exists ENABLE_M2PLUGIN] } {
>      return
>  }
>
> diff --git a/gcc/testsuite/gm2/switches/check-all/plugin/pim2/fail/switches-check-all-plugin-pim2-fail.exp b/gcc/testsuite/gm2/switches/check-all/plugin/pim2/fail/switches-check-all-plugin-pim2-fail.exp
> index 238e5c8af90..24644ce9044 100644
> --- a/gcc/testsuite/gm2/switches/check-all/plugin/pim2/fail/switches-check-all-plugin-pim2-fail.exp
> +++ b/gcc/testsuite/gm2/switches/check-all/plugin/pim2/fail/switches-check-all-plugin-pim2-fail.exp
> @@ -22,10 +22,13 @@ load_lib target-supports.exp
>
>  global TESTING_IN_BUILD_TREE
>  global ENABLE_PLUGIN
> +global ENABLE_M2PLUGIN
>
>  # 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] } {
> +if { ![info exists TESTING_IN_BUILD_TREE]
> +     || ![info exists ENABLE_PLUGIN]
> +     || ![info exists ENABLE_M2PLUGIN] } {
>      return
>  }
>
  
Gaius Mulley Dec. 21, 2022, 3:18 p.m. UTC | #2
Richard Biener <richard.guenther@gmail.com> writes:

>>
>> ChangeLog:
>>
>>         * Makefile.def (extra_configure_flags): Add @enable_m2plugin@.
>>         * Makefile.in : Rebuilt.
>>         * configure : Rebuilt.
>>         * configure.ac (host_tools): Remove unused gm2tools.
>>         (m2plugin) New AC_ARG_ENABLE.
>>         (enable_m2plugin) New AC_SUBST added.
>
> Why's this at the toplevel?

ah sorry - my misunderstanding on how configure and friends work.  I'll
rework the patch local to gcc/m2.  Thanks for spotting this error,

regards,
Gaius
  
Rainer Orth Dec. 21, 2022, 3:24 p.m. UTC | #3
Hi Gaius,

Btw., you've got a couple of formatting errors in your ChangeLog entires:

>>> ChangeLog:
>>>
>>>         * Makefile.def (extra_configure_flags): Add @enable_m2plugin@.
>>>         * Makefile.in : Rebuilt.
                         ^ no blank here.  Besides, the entires are
                           usually in present tense ("Rebuild").

>>>         * configure.ac (host_tools): Remove unused gm2tools.
>>>         (m2plugin) New AC_ARG_ENABLE.
                      ^ missing :

and several times more.  Just nits, but best keep the entires consistent
with the GNU Coding Standards.

Thanks.
        Rainer
  
Gaius Mulley Dec. 21, 2022, 7 p.m. UTC | #4
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> Hi Gaius,
>
> Btw., you've got a couple of formatting errors in your ChangeLog entires:
>
>>>> ChangeLog:
>>>>
>>>>         * Makefile.def (extra_configure_flags): Add @enable_m2plugin@.
>>>>         * Makefile.in : Rebuilt.
>                          ^ no blank here.  Besides, the entires are
>                            usually in present tense ("Rebuild").
>
>>>>         * configure.ac (host_tools): Remove unused gm2tools.
>>>>         (m2plugin) New AC_ARG_ENABLE.
>                       ^ missing :
>
> and several times more.  Just nits, but best keep the entires consistent
> with the GNU Coding Standards.
>
> Thanks.
>         Rainer

Hi Rainer,

thanks for spotting these - yes I'll double check ChangeLogs in the
future and adjust to present tense,

regards,
Gaius
  

Patch

diff --git a/Makefile.def b/Makefile.def
index 5f44190154e..d33e4528b63 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -103,7 +103,7 @@  host_modules= { module= libiberty; bootstrap=true;
 // @extra_linker_plugin_flags@ and @extra_linker_plugin_configure_flags@.
 host_modules= { module= libiberty-linker-plugin; bootstrap=true;
 		module_srcdir=libiberty;
-	        extra_configure_flags='@extra_host_libiberty_configure_flags@ --disable-install-libiberty @extra_linker_plugin_flags@ @extra_linker_plugin_configure_flags@';
+	        extra_configure_flags='@extra_host_libiberty_configure_flags@ --disable-install-libiberty @extra_linker_plugin_flags@ @extra_linker_plugin_configure_flags@ @enable_m2plugin@';
 		extra_make_flags='@extra_linker_plugin_flags@'; };
 // We abuse missing to avoid installing anything for libiconv.
 host_modules= { module= libiconv;
diff --git a/configure.ac b/configure.ac
index c5191ce24ae..b771f61ef33 100644
--- a/configure.ac
+++ b/configure.ac
@@ -140,7 +140,7 @@  host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktr
 # binutils, gas and ld appear in that order because it makes sense to run
 # "make check" in that particular order.
 # If --enable-gold is used, "gold" may replace "ld".
-host_tools="texinfo flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gdbserver gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gm2tools gotools c++tools"
+host_tools="texinfo flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gdbserver gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gotools c++tools"
 
 # these libraries are built for the target environment, and are built after
 # the host libraries and the host tools (which may be a cross compiler)
@@ -465,13 +465,22 @@  if test "${ENABLE_LIBADA}" != "yes" ; then
   noconfigdirs="$noconfigdirs gnattools"
 fi
 
+
 AC_ARG_ENABLE(libgm2,
 [AS_HELP_STRING([--enable-libgm2], [build libgm2 directory])],
 ENABLE_LIBGM2=$enableval,
 ENABLE_LIBGM2=no)
-if test "${ENABLE_LIBGM2}" != "yes" ; then
-  noconfigdirs="$noconfigdirs gm2tools"
+
+
+AC_ARG_ENABLE(m2plugin,
+[AS_HELP_STRING([--enable-m2plugin], [enable m2rte plugin])],
+enable_m2plugin=$enableval,
+enable_m2plugin=yes)
+if test "${enable_m2plugin}" != "yes" ; then
+  enable_m2plugin=no
 fi
+AC_SUBST(enable_m2plugin)
+
 
 AC_ARG_ENABLE(libssp,
 [AS_HELP_STRING([--enable-libssp], [build libssp directory])],
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 995d77f96c4..46bdcb730aa 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -404,6 +404,8 @@  PLUGINCFLAGS = @CXXFLAGS@
 PLUGINLIBS = @pluginlibs@
 
 enable_plugin = @enable_plugin@
+# Should we build the m2plugin?
+enable_m2plugin = @enable_m2plugin@
 
 # On MinGW plugin installation involves installing import libraries.
 ifeq ($(enable_plugin),yes)
@@ -4101,6 +4103,9 @@  site.exp: ./config.status Makefile
 	  echo "set PLUGINCFLAGS \"$(PLUGINCFLAGS)\"" >> ./site.tmp; \
 	  echo "set GMPINC \"$(GMPINC)\"" >> ./site.tmp; \
 	fi
+	@if test "@enable_m2plugin@" = "yes" ; then \
+	  echo "set ENABLE_M2PLUGIN 1" >> ./site.tmp; \
+	fi
 # If newlib has been configured, we need to pass -B to gcc so it can find
 # newlib's crt0.o if it exists.  This will cause a "path prefix not used"
 # message if it doesn't, but the testsuite is supposed to ignore the message -
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 5efbf11793c..61052d4a2bc 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1011,6 +1011,7 @@  analyzer=1)
 AC_DEFINE_UNQUOTED(ENABLE_ANALYZER, $analyzer,
 [Define 0/1 if static analyzer feature is enabled.])
 
+
 AC_ARG_ENABLE(objc-gc,
 [AS_HELP_STRING([--enable-objc-gc],
 		[enable the use of Boehm's garbage collector with
@@ -7375,6 +7376,26 @@  if test x"$enable_plugin" = x"yes"; then
 fi
 
 
+AC_ARG_ENABLE(m2plugin,
+[AS_HELP_STRING([--enable-m2plugin],
+		[enable the modula-2 static analysis plugin])],
+if test x$enable_m2plugin = xno; then
+  m2plugin=0
+else
+  if test x"$enable_plugin" = x"yes"; then
+     m2plugin=1
+  else
+     m2plugin=0
+     AC_MSG_WARN([modula-2 plugin is disabled as the host has disabled plugins])
+  fi
+fi,
+m2plugin=0)
+if test x"$enable_m2plugin" = x"yes"; then
+  AC_DEFINE(ENABLE_M2PLUGIN, 1, [Define to enable m2plugin support.])
+fi
+AC_SUBST(enable_m2plugin)
+
+
 # Enable --enable-host-shared
 AC_ARG_ENABLE(host-shared,
 [AS_HELP_STRING([--enable-host-shared],
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 6884a74936b..b1966369ff2 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1926,6 +1926,9 @@  do a @samp{make -C gcc gnatlib_and_tools}.
 Specify that the run-time libraries and tools used by Modula-2 should not
 be built.  This can be useful for debugging.
 
+@item --enable-m2plugin
+Specify that the modula-2 static analysis plugin should be built.
+
 @item --disable-libsanitizer
 Specify that the run-time libraries for the various sanitizers should
 not be built.
diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
index a8bd7fe4d19..3d9c84f7607 100644
--- a/gcc/m2/Make-lang.in
+++ b/gcc/m2/Make-lang.in
@@ -82,6 +82,18 @@  PGE=m2/pge$(exeext)
 
 SRC_PREFIX=G
 
+ifeq ($(enable_plugin),no)
+# Override enable_m2plugin if host does not support plugins.
+ifeq ($(enable_m2plugin),yes)
+$(warning modula-2 plugin will be disabled as the host does not support plugins)
+endif
+enable_m2plugin=no
+endif
+
+ifeq ($(enable_m2plugin),yes)
+M2RTE_PLUGIN_SO=plugin/m2rte$(exeext).so
+endif
+
 m2/gm2spec.o: $(srcdir)/m2/gm2spec.cc $(SYSTEM_H) $(GCC_H) $(CONFIG_H) \
                m2/gm2config.h $(TARGET_H) $(PLUGIN_HEADERS) \
                $(generated_files) $(C_TREE_H) insn-attr-common.h
@@ -114,9 +126,9 @@  po-generated:
 
 # Build hooks:
 
-m2.all.cross: gm2-cross$(exeext) plugin/m2rte$(exeext).so
+m2.all.cross: gm2-cross$(exeext) $(M2RTE_PLUGIN_SO)
 
-m2.start.encap: gm2$(exeext) plugin/m2rte$(exeext).so
+m2.start.encap: gm2$(exeext) $(M2RTE_PLUGIN_SO)
 m2.rest.encap:
 
 
@@ -401,16 +413,22 @@  m2.uninstall:
 	-rm -rf $(bindir)/$(GM2_INSTALL_NAME)
 	-rm -rf $(bindir)/$(GM2_CROSS_NAME)
 
+
+ifeq ($(enable_m2plugin),yes)
 m2.install-plugin: installdirs
 	$(mkinstalldirs) $(DESTDIR)$(plugin_resourcesdir)
-	$(INSTALL_PROGRAM) plugin/m2rte$(exeext).so $(DESTDIR)$(plugin_resourcesdir)/m2rte$(exeext).so
+	$(INSTALL_PROGRAM) $(M2RTE_PLUGIN_SO) $(DESTDIR)$(plugin_resourcesdir)/m2rte$(exeext).so
 	chmod a+x $(DESTDIR)$(plugin_resourcesdir)/m2rte$(exeext).so
 
 plugin/m2rte$(exeext).so: $(srcdir)/m2/plugin/m2rte.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) \
         insn-attr-common.h insn-flags.h $(generated_files)
 	test -d plugin || mkdir plugin
-	$(PLUGINCC) $(PLUGINCFLAGS) -fno-rtti -I. -I$(srcdir) -I$(srcdir)/m2 -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/../include -I$(srcdir)/../libcpp/include -Wall $(GMPINC) -Wno-literal-suffix -fPIC -c -o plugin/m2rte.o $(srcdir)/m2/plugin/m2rte.cc
+	$(PLUGINCC) $(PLUGINCFLAGS) -fno-rtti -I. -I$(srcdir) -I$(srcdir)/m2 -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/../include -I$(srcdir)/../libcpp/include -I$(objdir)/../intl -Wall $(GMPINC) -Wno-literal-suffix -fPIC -c -o plugin/m2rte.o $(srcdir)/m2/plugin/m2rte.cc
 	$(PLUGINCC) $(PLUGINCFLAGS) $(PLUGINLIBS) -fno-rtti plugin/m2rte.o -shared -o $@
+else
+m2.install-plugin:
+plugin/m2rte$(exeext).so:
+endif
 
 
 # Clean hooks:
@@ -526,7 +544,7 @@  cc1gm2$(exeext): stage1/m2/cc1gm2$(exeext) $(m2.prev)
 
 stage2/m2/cc1gm2$(exeext): stage1/m2/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(P) \
                             $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS) \
-                            m2/gm2-gcc/rtegraph.o plugin/m2rte$(exeext).so m2/gm2-libs-boot/M2LINK.o
+                            m2/gm2-gcc/rtegraph.o $(M2RTE_PLUGIN_SO) m2/gm2-libs-boot/M2LINK.o
 	@$(call LINK_PROGRESS,$(INDEX.m2),start)
 	+$(LLINKER) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GM2_C_OBJS) m2/gm2-compiler/m2flex.o \
                             attribs.o \
@@ -538,7 +556,7 @@  stage2/m2/cc1gm2$(exeext): stage1/m2/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(
 stage1/m2/cc1gm2$(exeext): gm2$(exeext) m2/gm2-compiler-boot/m2flex.o \
                             $(P) $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) \
                             $(GM2_LIBS_BOOT) $(MC_LIBS) \
-                            m2/gm2-gcc/rtegraph.o plugin/m2rte$(exeext).so \
+                            m2/gm2-gcc/rtegraph.o $(M2RTE_PLUGIN_SO) \
                             m2/gm2-libs-boot/M2LINK.o \
                             $(m2.prev)
 	@$(call LINK_PROGRESS,$(INDEX.m2),start)
diff --git a/gcc/m2/gm2spec.cc b/gcc/m2/gm2spec.cc
index 680dd3602ef..49ad14038d2 100644
--- a/gcc/m2/gm2spec.cc
+++ b/gcc/m2/gm2spec.cc
@@ -610,7 +610,7 @@  lang_specific_driver (struct cl_decoded_option **in_decoded_options,
   /* The number of libraries added in.  */
   int added_libraries;
 
-#ifdef ENABLE_PLUGIN
+#ifdef ENABLE_M2PLUGIN
   /* True if we should add -fplugin=m2rte to the command-line.  */
   bool need_plugin = true;
 #else
@@ -678,10 +678,10 @@  lang_specific_driver (struct cl_decoded_option **in_decoded_options,
           break;
         case OPT_fm2_plugin:
           need_plugin = decoded_options[i].value;
-#ifndef ENABLE_PLUGIN
+#ifndef ENABLE_M2PLUGIN
 	  if (need_plugin)
 	    error ("plugin support is disabled; configure with "
-		   "%<--enable-plugin%>");
+		   "%<--enable-m2plugin%>");
 #endif
           break;
 	case OPT_fscaffold_dynamic:
@@ -802,7 +802,6 @@  lang_specific_driver (struct cl_decoded_option **in_decoded_options,
 	       "-fgen-module-list=", "-fuse-list=");
     }
 
-
   /* There's no point adding -shared-libgcc if we don't have a shared
      libgcc.  */
 #ifndef ENABLE_SHARED_LIBGCC
@@ -848,7 +847,8 @@  lang_specific_driver (struct cl_decoded_option **in_decoded_options,
   if (allow_libraries)
     {
       /* If the libraries have not been specified by the user but the
-	 dialect has been specified then select the appropriate libraries.  */
+	 dialect has been specified then select the appropriate
+	 libraries.  */
       if (libraries == NULL)
 	{
 	  if (strcmp (dialect, "iso") == 0)
@@ -865,8 +865,10 @@  lang_specific_driver (struct cl_decoded_option **in_decoded_options,
   if ((! seen_x_flag) && seen_module_extension)
     append_option (OPT_x, "modula-2", 1);
 
+#ifdef ENABLE_M2PLUGIN
   if (need_plugin)
     append_option (OPT_fplugin_, "m2rte", 1);
+#endif
 
   if (linking)
     {
diff --git a/gcc/testsuite/gm2/iso/check/fail/iso-check-fail.exp b/gcc/testsuite/gm2/iso/check/fail/iso-check-fail.exp
index a519f839f90..4aa02ef61fb 100644
--- a/gcc/testsuite/gm2/iso/check/fail/iso-check-fail.exp
+++ b/gcc/testsuite/gm2/iso/check/fail/iso-check-fail.exp
@@ -21,10 +21,13 @@  load_lib target-supports.exp
 
 global TESTING_IN_BUILD_TREE
 global ENABLE_PLUGIN
+global ENABLE_M2PLUGIN
 
 # 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] } {
+if { ![info exists TESTING_IN_BUILD_TREE]
+     || ![info exists ENABLE_PLUGIN]
+     || ![info exists ENABLE_M2PLUGIN] } {
     return
 }
 
diff --git a/gcc/testsuite/gm2/switches/auto-init/fail/switches-auto-init-fail.exp b/gcc/testsuite/gm2/switches/auto-init/fail/switches-auto-init-fail.exp
index c60027ff751..1b5488bc4da 100644
--- a/gcc/testsuite/gm2/switches/auto-init/fail/switches-auto-init-fail.exp
+++ b/gcc/testsuite/gm2/switches/auto-init/fail/switches-auto-init-fail.exp
@@ -22,10 +22,13 @@  load_lib target-supports.exp
 
 global TESTING_IN_BUILD_TREE
 global ENABLE_PLUGIN
+global ENABLE_M2PLUGIN
 
 # 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] } {
+if { ![info exists TESTING_IN_BUILD_TREE]
+     || ![info exists ENABLE_PLUGIN]
+     || ![info exists ENABLE_M2PLUGIN] } {
     return
 }
 
diff --git a/gcc/testsuite/gm2/switches/check-all/pim2/fail/switches-check-all-pim2-fail.exp b/gcc/testsuite/gm2/switches/check-all/pim2/fail/switches-check-all-pim2-fail.exp
index 3c654ad0b73..791ebe294b2 100644
--- a/gcc/testsuite/gm2/switches/check-all/pim2/fail/switches-check-all-pim2-fail.exp
+++ b/gcc/testsuite/gm2/switches/check-all/pim2/fail/switches-check-all-pim2-fail.exp
@@ -22,10 +22,13 @@  load_lib target-supports.exp
 
 global TESTING_IN_BUILD_TREE
 global ENABLE_PLUGIN
+global ENABLE_M2PLUGIN
 
 # 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] } {
+if { ![info exists TESTING_IN_BUILD_TREE]
+     || ![info exists ENABLE_PLUGIN]
+     || ![info exists ENABLE_M2PLUGIN] } {
     return
 }
 
diff --git a/gcc/testsuite/gm2/switches/check-all/plugin/iso/fail/switches-check-all-plugin-iso-fail.exp b/gcc/testsuite/gm2/switches/check-all/plugin/iso/fail/switches-check-all-plugin-iso-fail.exp
index 84a3f37e2bb..2c6b56fcca0 100644
--- a/gcc/testsuite/gm2/switches/check-all/plugin/iso/fail/switches-check-all-plugin-iso-fail.exp
+++ b/gcc/testsuite/gm2/switches/check-all/plugin/iso/fail/switches-check-all-plugin-iso-fail.exp
@@ -22,10 +22,13 @@  load_lib target-supports.exp
 
 global TESTING_IN_BUILD_TREE
 global ENABLE_PLUGIN
+global ENABLE_M2PLUGIN
 
 # 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] } {
+if { ![info exists TESTING_IN_BUILD_TREE]
+     || ![info exists ENABLE_PLUGIN]
+     || ![info exists ENABLE_M2PLUGIN] } {
     return
 }
 
diff --git a/gcc/testsuite/gm2/switches/check-all/plugin/pim2/fail/switches-check-all-plugin-pim2-fail.exp b/gcc/testsuite/gm2/switches/check-all/plugin/pim2/fail/switches-check-all-plugin-pim2-fail.exp
index 238e5c8af90..24644ce9044 100644
--- a/gcc/testsuite/gm2/switches/check-all/plugin/pim2/fail/switches-check-all-plugin-pim2-fail.exp
+++ b/gcc/testsuite/gm2/switches/check-all/plugin/pim2/fail/switches-check-all-plugin-pim2-fail.exp
@@ -22,10 +22,13 @@  load_lib target-supports.exp
 
 global TESTING_IN_BUILD_TREE
 global ENABLE_PLUGIN
+global ENABLE_M2PLUGIN
 
 # 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] } {
+if { ![info exists TESTING_IN_BUILD_TREE]
+     || ![info exists ENABLE_PLUGIN]
+     || ![info exists ENABLE_M2PLUGIN] } {
     return
 }