diff -rubB gcc-4.5.1.orig/gcc/config.in gcc-4.5.1/gcc/config.in --- gcc-4.5.1.orig/gcc/config.in 2010-07-31 11:34:58.000000000 +0200 +++ gcc-4.5.1/gcc/config.in 2010-09-02 11:44:15.000000000 +0200 @@ -131,6 +131,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 -rubB gcc-4.5.1.orig/gcc/configure.ac gcc-4.5.1/gcc/configure.ac --- gcc-4.5.1.orig/gcc/configure.ac 2010-06-14 12:38:18.000000000 +0200 +++ gcc-4.5.1/gcc/configure.ac 2010-09-02 11:43:40.000000000 +0200 @@ -4600,6 +4600,15 @@ 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 + # Configure the subdirectories # AC_CONFIG_SUBDIRS($subdirs) diff -rubB gcc-4.5.1.orig/gcc/cp/Make-lang.in gcc-4.5.1/gcc/cp/Make-lang.in --- gcc-4.5.1.orig/gcc/cp/Make-lang.in 2010-04-02 21:54:46.000000000 +0200 +++ gcc-4.5.1/gcc/cp/Make-lang.in 2010-09-02 12:37:02.000000000 +0200 @@ -94,7 +94,8 @@ cc1plus-dummy$(exeext): $(CXX_OBJS) dummy-checksum.o $(BACKEND) $(LIBDEPS) $(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ - $(CXX_OBJS) dummy-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS) + $(CXX_OBJS) dummy-checksum.o $(BACKEND) $(STATIC_PLUGIN_LIBS) \ + $(LIBS) $(BACKENDLIBS) cc1plus-checksum.c : cc1plus-dummy$(exeext) build/genchecksum$(build_exeext) build/genchecksum$(build_exeext) cc1plus-dummy$(exeext) > $@ @@ -103,7 +104,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) # Special build rules. $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf diff -rubB gcc-4.5.1.orig/gcc/opts.c gcc-4.5.1/gcc/opts.c --- gcc-4.5.1.orig/gcc/opts.c 2010-05-17 12:13:28.000000000 +0200 +++ gcc-4.5.1/gcc/opts.c 2010-09-02 11:31:24.000000000 +0200 @@ -1829,7 +1829,7 @@ break; case OPT_fplugin_: -#ifdef ENABLE_PLUGIN +#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN) add_new_plugin (arg); #else error ("Plugin support is disabled. Configure with --enable-plugin."); @@ -1837,7 +1837,7 @@ break; case OPT_fplugin_arg_: -#ifdef ENABLE_PLUGIN +#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN) parse_plugin_arg_opt (arg); #else error ("Plugin support is disabled. Configure with --enable-plugin."); diff -rubB gcc-4.5.1.orig/gcc/plugin.c gcc-4.5.1/gcc/plugin.c --- gcc-4.5.1.orig/gcc/plugin.c 2009-12-21 22:37:49.000000000 +0200 +++ gcc-4.5.1/gcc/plugin.c 2010-09-02 11:36:53.000000000 +0200 @@ -40,7 +40,7 @@ #include "timevar.h" #include "ggc.h" -#ifdef ENABLE_PLUGIN +#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN) #include "plugin-version.h" #endif @@ -602,8 +602,31 @@ 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 toplev.c. */ @@ -616,7 +639,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