Index: gcc/doc/plugins.texi
===================================================================
--- gcc/doc/plugins.texi	(revision 160389)
+++ gcc/doc/plugins.texi	(working copy)
@@ -50,8 +50,10 @@ fatal error: plugin <name> is not licens
 compilation terminated
 @end smallexample
 
-The type of the symbol is irrelevant.  The compiler merely asserts that
-it exists in the global scope.  Something like this is enough:
+The declared type of the symbol should be int, to match a forward declaration
+in @file{gcc-plugin.h} that suppresses C++ mangling.  It does not need to be in
+any allocated section, though.  The compiler merely asserts that
+the symbol exists in the global scope.  Something like this is enough:
 
 @smallexample
 int plugin_is_GPL_compatible;
Index: gcc/testsuite/gcc.dg/plugin/selfassign.c
===================================================================
--- gcc/testsuite/gcc.dg/plugin/selfassign.c	(revision 160389)
+++ gcc/testsuite/gcc.dg/plugin/selfassign.c	(working copy)
@@ -275,7 +275,7 @@ static struct gimple_opt_pass pass_warn_
     NULL,                                 /* sub */
     NULL,                                 /* next */
     0,                                    /* static_pass_number */
-    0,                                    /* tv_id */
+    TV_NONE,                              /* tv_id */
     PROP_ssa,                             /* properties_required */
     0,                                    /* properties_provided */
     0,                                    /* properties_destroyed */
Index: gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
===================================================================
--- gcc/testsuite/gcc.dg/plugin/one_time_plugin.c	(revision 160389)
+++ gcc/testsuite/gcc.dg/plugin/one_time_plugin.c	(working copy)
@@ -37,7 +37,7 @@ struct gimple_opt_pass one_pass = 
   NULL,                                 /* sub */
   NULL,                                 /* next */
   0,                                    /* static_pass_number */
-  0,                                    /* tv_id */
+  TV_NONE,                              /* tv_id */
   PROP_gimple_any,                      /* properties_required */
   0,                                    /* properties_provided */
   0,                                    /* properties_destroyed */
Index: gcc/testsuite/gcc.dg/plugin/finish_unit_plugin.c
===================================================================
--- gcc/testsuite/gcc.dg/plugin/finish_unit_plugin.c	(revision 160389)
+++ gcc/testsuite/gcc.dg/plugin/finish_unit_plugin.c	(working copy)
@@ -12,6 +12,7 @@
 #include "tree.h"
 #include "tree-pass.h"
 #include "intl.h"
+#include "cgraph.h"
 
 int plugin_is_GPL_compatible;
 
Index: gcc/testsuite/g++.dg/plugin/selfassign.c
===================================================================
--- gcc/testsuite/g++.dg/plugin/selfassign.c	(revision 160389)
+++ gcc/testsuite/g++.dg/plugin/selfassign.c	(working copy)
@@ -275,7 +275,7 @@ static struct gimple_opt_pass pass_warn_
     NULL,                                 /* sub */
     NULL,                                 /* next */
     0,                                    /* static_pass_number */
-    0,                                    /* tv_id */
+    TV_NONE,                              /* tv_id */
     PROP_ssa,                             /* properties_required */
     0,                                    /* properties_provided */
     0,                                    /* properties_destroyed */
Index: gcc/testsuite/g++.dg/plugin/attribute_plugin.c
===================================================================
--- gcc/testsuite/g++.dg/plugin/attribute_plugin.c	(revision 160389)
+++ gcc/testsuite/g++.dg/plugin/attribute_plugin.c	(working copy)
@@ -8,6 +8,8 @@
 #include "tree.h"
 #include "tree-pass.h"
 #include "intl.h"
+#include "toplev.h"
+#include "plugin.h"
 
 int plugin_is_GPL_compatible;
 
Index: gcc/testsuite/g++.dg/plugin/dumb_plugin.c
===================================================================
--- gcc/testsuite/g++.dg/plugin/dumb_plugin.c	(revision 160389)
+++ gcc/testsuite/g++.dg/plugin/dumb_plugin.c	(working copy)
@@ -9,6 +9,7 @@
 #include "tree.h"
 #include "tree-pass.h"
 #include "intl.h"
+#include "toplev.h"
 
 int plugin_is_GPL_compatible;
 
@@ -65,7 +66,7 @@ static struct gimple_opt_pass pass_dumb_
     NULL,                                 /* sub */
     NULL,                                 /* next */
     0,                                    /* static_pass_number */
-    0,                                    /* tv_id */
+    TV_NONE,                              /* tv_id */
     PROP_cfg,                             /* properties_required */
     0,                                    /* properties_provided */
     0,                                    /* properties_destroyed */
Index: gcc/testsuite/g++.dg/plugin/pragma_plugin.c
===================================================================
--- gcc/testsuite/g++.dg/plugin/pragma_plugin.c	(revision 160389)
+++ gcc/testsuite/g++.dg/plugin/pragma_plugin.c	(working copy)
@@ -13,6 +13,7 @@
 #include "cpplib.h"
 #include "tree-pass.h"
 #include "intl.h"
+#include "toplev.h"
 
 int plugin_is_GPL_compatible;
 
Index: gcc/gcc-plugin.h
===================================================================
--- gcc/gcc-plugin.h	(revision 160389)
+++ gcc/gcc-plugin.h	(working copy)
@@ -147,4 +147,15 @@ extern int unregister_callback (const ch
    -iplugindir program argument to cc1.  */
 extern const char* default_plugin_dir_name (void);
 
+/* In case the C++ compiler does name mangling for globals, declare
+   plugin_is_GPL_compatible extern "C" so that a later definition
+   in a plugin file will have this linkage.  */
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern int plugin_is_GPL_compatible;
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* GCC_PLUGIN_H */
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 160389)
+++ gcc/Makefile.in	(working copy)
@@ -331,10 +331,10 @@ LTO_BINARY_READER = @LTO_BINARY_READER@
 LTO_USE_LIBELF = @LTO_USE_LIBELF@
 
 # Compiler needed for plugin support
-PLUGINCC = @CC@
+PLUGINCC = $(COMPILER)
 
 # Flags needed for plugin support
-PLUGINCFLAGS = @CFLAGS@
+PLUGINCFLAGS = $(COMPILER_FLAGS)
 
 # Libs and linker options needed for plugin support
 PLUGINLIBS = @pluginlibs@
