OSDN Git Service

* doc/plugins.texi: Document plugin_is_GPL_compatible.
authordnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Jun 2009 19:48:35 +0000 (19:48 +0000)
committerdnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Jun 2009 19:48:35 +0000 (19:48 +0000)
* plugin.c (str_license): Declare.
(try_init_one_plugin): Assert that the symbol
'plugin_is_GPL_compatible' exists.

testsuite/ChangeLog

* gcc.dg/plugin/selfassign.c: Declare plugin_is_GPL_compatible.
* gcc.dg/plugin/ggcplug.c: Likewise.
* gcc.dg/plugin/one_time_plugin.c: Likewise.
* g++.dg/plugin/selfassign.c: Likewise.
* g++.dg/plugin/attribute_plugin.c: Likewise.
* g++.dg/plugin/dumb_plugin.c: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148667 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/doc/plugins.texi
gcc/plugin.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/plugin/attribute_plugin.c
gcc/testsuite/g++.dg/plugin/dumb_plugin.c
gcc/testsuite/g++.dg/plugin/selfassign.c
gcc/testsuite/gcc.dg/plugin/ggcplug.c
gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
gcc/testsuite/gcc.dg/plugin/selfassign.c

index 967cbbf..af65356 100644 (file)
@@ -1,3 +1,10 @@
+2009-06-18  Diego Novillo  <dnovillo@google.com>
+
+       * doc/plugins.texi: Document plugin_is_GPL_compatible.
+       * plugin.c (str_license): Declare.
+       (try_init_one_plugin): Assert that the symbol
+       'plugin_is_GPL_compatible' exists.
+
 2009-06-18  Sergei Dyshel  <sergeid@il.ibm.com>
 
        * see.c: Remove.
index 9ae0a18..791e04b 100644 (file)
@@ -32,6 +32,26 @@ address of the callback function that will handle that event.
 
 The header @file{gcc-plugin.h} must be the first gcc header to be included.
 
+@subsection Plugin license check
+
+Every plugin should define the global symbol @code{plugin_is_GPL_compatible}
+to assert that it has been licensed under a GPL-compatible license.
+If this symbol does not exist, the compiler will emit a fatal error
+and exit with the error message:
+
+@smallexample
+fatal error: plugin <name> is not licensed under a GPL-compatible license
+<name>: undefined symbol: plugin_is_GPL_compatible
+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:
+
+@smallexample
+int plugin_is_GPL_compatible;
+@end smallexample
+
 @subsection Plugin initialization
 
 Every plugin should export a function called @code{plugin_init} that
index 93151f8..396850a 100644 (file)
@@ -25,7 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* If plugin support is not enabled, do not try to execute any code
    that may reference libdl.  The generic code is still compiled in to
-   avoid including to many conditional compilation paths in the rest
+   avoid including too many conditional compilation paths in the rest
    of the compiler.  */
 #ifdef ENABLE_PLUGIN
 #include <dlfcn.h>
@@ -95,6 +95,10 @@ static struct pass_list_node *prev_added_pass_node;
 /* Each plugin should define an initialization function with exactly
    this name.  */
 static const char *str_plugin_init_func_name = "plugin_init";
+
+/* Each plugin should define this symbol to assert that it is
+   distributed under a GPL-compatible license.  */
+static const char *str_license = "plugin_is_GPL_compatible";
 #endif
 
 /* Helper function for the hash table that compares the base_name of the
@@ -595,6 +599,11 @@ try_init_one_plugin (struct plugin_name_args *plugin)
   /* Clear any existing error.  */
   dlerror ();
 
+  /* Check the plugin license.  */
+  if (dlsym (dl_handle, str_license) == NULL)
+    fatal_error ("plugin %s is not licensed under a GPL-compatible license\n"
+                "%s", plugin->full_name, dlerror ());
+
   PTR_UNION_AS_VOID_PTR (plugin_init_union) =
       dlsym (dl_handle, str_plugin_init_func_name);
   plugin_init = PTR_UNION_AS_CAST_PTR (plugin_init_union);
index caf69f5..b6a6fe1 100644 (file)
@@ -1,3 +1,12 @@
+2009-06-18  Diego Novillo  <dnovillo@google.com>
+
+       * gcc.dg/plugin/selfassign.c: Declare plugin_is_GPL_compatible.
+       * gcc.dg/plugin/ggcplug.c: Likewise.
+       * gcc.dg/plugin/one_time_plugin.c: Likewise.
+       * g++.dg/plugin/selfassign.c: Likewise.
+       * g++.dg/plugin/attribute_plugin.c: Likewise.
+       * g++.dg/plugin/dumb_plugin.c: Likewise.
+
 2009-06-18  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        * gcc.dg/cpp/arith-3.c: Add column info.
index 16b3496..deaebf1 100644 (file)
@@ -9,6 +9,8 @@
 #include "tree-pass.h"
 #include "intl.h"
 
+int plugin_is_GPL_compatible;
+
 /* Attribute handler callback */
 
 static tree
index 24da544..18f42c0 100644 (file)
@@ -10,6 +10,7 @@
 #include "tree-pass.h"
 #include "intl.h"
 
+int plugin_is_GPL_compatible;
 
 /* Callback function to invoke after GCC finishes parsing a struct.  */
 
index 2bc1d86..75b6161 100644 (file)
@@ -14,6 +14,7 @@
 #include "tree-pass.h"
 #include "intl.h"
 
+int plugin_is_GPL_compatible;
 
 /* Indicate whether to check overloaded operator '=', which is performed by
    default. To disable it, use -fplugin-arg-NAME-no-check-operator-eq.  */
index f90e77b..49b5c95 100644 (file)
@@ -13,7 +13,7 @@
 #include "intl.h"
 #include "gcc-plugin.h"
 
-
+int plugin_is_GPL_compatible;
 
 /* our callback is the same for all PLUGIN_GGC_START,
    PLUGIN_GGC_MARKING, PLUGIN_GGC_END events; it just increments the
index 8ae327a..635776f 100644 (file)
@@ -9,6 +9,8 @@
 #include "tree-pass.h"
 #include "intl.h"
 
+int plugin_is_GPL_compatible;
+
 static bool one_pass_gate (void)
 {
   return true;
index 2bc1d86..52a03bf 100644 (file)
@@ -15,6 +15,8 @@
 #include "intl.h"
 
 
+int plugin_is_GPL_compatible;
+
 /* Indicate whether to check overloaded operator '=', which is performed by
    default. To disable it, use -fplugin-arg-NAME-no-check-operator-eq.  */
 bool check_operator_eq = true;