diff -ru -bB gcc-4.7.2/gcc/config.in gcc/gcc/config.in --- gcc-4.7.2/gcc/config.in 2012-09-20 09:23:55.000000000 +0200 +++ gcc/gcc/config.in 2013-02-09 16:42:31.000000000 +0200 @@ -143,6 +143,10 @@ #undef ENABLE_PLUGIN #endif +/* Define to enable static plugin support. */ +#ifndef USED_FOR_TARGET +#undef ENABLE_STATIC_PLUGIN +#endif /* Define if you want all operations on RTL (the basic data structure of the optimizer and back end) to be checked for dynamic type safety at runtime. diff -ru -bB gcc-4.7.2/gcc/configure.ac gcc/gcc/configure.ac --- gcc-4.7.2/gcc/configure.ac 2012-09-13 15:32:31.000000000 +0200 +++ gcc/gcc/configure.ac 2013-02-09 16:46:29.000000000 +0200 @@ -5188,6 +5188,14 @@ AC_DEFINE(ENABLE_PLUGIN, 1, [Define to enable plugin support.]) fi +AC_ARG_ENABLE(static-plugin, +[ --enable-static-plugin enable static plugin support], +enable_static_plugin=$enableval, +enable_static_plugin==no) + +if test x"$enable_static_plugin" = x"yes"; then + AC_DEFINE(ENABLE_STATIC_PLUGIN, 1, [Define to enable static plugin support.]) +fi AC_ARG_ENABLE(libquadmath-support, [AS_HELP_STRING([--disable-libquadmath-support], diff -ru -bB gcc-4.7.2/gcc/cp/Make-lang.in gcc/gcc/cp/Make-lang.in --- gcc-4.7.2/gcc/cp/Make-lang.in 2011-11-09 19:53:53.000000000 +0200 +++ gcc/gcc/cp/Make-lang.in 2013-02-10 13:03:11.000000000 +0200 @@ -103,7 +103,8 @@ cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS) +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ - $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS) + $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(STATIC_PLUGIN_LIBS) \ + $(LIBS) $(BACKENDLIBS) ifeq ($(ENABLE_MAINTAINER_RULES), true) # Special build rule. This is a maintainer rule, that is only diff -ru -bB gcc-4.7.2/gcc/opts-global.c gcc/gcc/opts-global.c --- gcc-4.7.2/gcc/opts-global.c 2011-11-03 16:46:26.000000000 +0200 +++ gcc/gcc/opts-global.c 2013-02-09 16:53:51.000000000 +0200 @@ -365,7 +365,7 @@ break; case OPT_fplugin_: -#ifdef ENABLE_PLUGIN +#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN) add_new_plugin (opt->arg); #else error ("plugin support is disabled; configure with --enable-plugin"); @@ -373,7 +373,7 @@ break; case OPT_fplugin_arg_: -#ifdef ENABLE_PLUGIN +#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN) parse_plugin_arg_opt (opt->arg); #else error ("plugin support is disabled; configure with --enable-plugin"); diff -ru -bB gcc-4.7.2/gcc/plugin.c gcc/gcc/plugin.c --- gcc-4.7.2/gcc/plugin.c 2011-10-19 15:20:22.000000000 +0200 +++ gcc/gcc/plugin.c 2013-02-10 09:19:37.000000000 +0200 @@ -31,7 +31,7 @@ #include "timevar.h" #include "ggc.h" -#ifdef ENABLE_PLUGIN +#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN) #include "plugin-version.h" #endif @@ -132,6 +132,7 @@ flag_plugin_added = true; +#ifdef ENABLE_PLUGIN /* Replace short names by their full path when relevant. */ name_is_short = !IS_ABSOLUTE_PATH (plugin_name); for (pc = plugin_name; name_is_short && *pc; pc++) @@ -153,6 +154,7 @@ plugin_name, base_name); } else +#endif base_name = get_plugin_base_name (plugin_name); /* If this is the first -fplugin= option we encounter, create @@ -619,6 +621,26 @@ return 1; } +#elif defined(ENABLE_STATIC_PLUGIN) + +extern int +plugin_init (struct plugin_name_args*, struct plugin_gcc_version*); + +static int +init_one_plugin (void **slot, void * ARG_UNUSED (info)) +{ + struct plugin_name_args *plugin = (struct plugin_name_args *) *slot; + + /* Call the plugin-provided initialization routine with the arguments. */ + if (plugin_init (plugin, &gcc_version)) + { + error ("Fail to initialize plugin %s", plugin->full_name); + htab_remove_elt (plugin_name_args_tab, plugin->base_name); + XDELETE (plugin); + } + return 1; +} + #endif /* ENABLE_PLUGIN */ /* Main plugin initialization function. Called from compile_file() in @@ -633,7 +655,7 @@ timevar_push (TV_PLUGIN_INIT); -#ifdef ENABLE_PLUGIN +#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN) /* Traverse and initialize each plugin specified in the command-line. */ htab_traverse_noresize (plugin_name_args_tab, init_one_plugin, NULL); #endif diff -ru -bB gcc-4.7.2/gcc/plugin.h gcc/gcc/plugin.h --- gcc-4.7.2/gcc/plugin.h 2010-10-05 16:28:39.000000000 +0200 +++ gcc/gcc/plugin.h 2013-02-09 17:01:32.000000000 +0200 @@ -52,7 +52,7 @@ invoke_plugin_callbacks (int event ATTRIBUTE_UNUSED, void *gcc_data ATTRIBUTE_UNUSED) { -#ifdef ENABLE_PLUGIN +#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN) /* True iff at least one plugin has been added. */ if (flag_plugin_added) return invoke_plugin_callbacks_full (event, gcc_data);