aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>2009-06-18 15:48:35 -0400
committerDiego Novillo <dnovillo@gcc.gnu.org>2009-06-18 15:48:35 -0400
commitfca5bb5ca8ce5e4b01d524cca7ae2455577ceda0 (patch)
tree79b33d246f25f2bed1420ec88101b2b444ad38fd /gcc
parent3600f67820b56b1083b1b5719e2be55b5bc8b775 (diff)
downloadgcc-fca5bb5ca8ce5e4b01d524cca7ae2455577ceda0.zip
gcc-fca5bb5ca8ce5e4b01d524cca7ae2455577ceda0.tar.gz
gcc-fca5bb5ca8ce5e4b01d524cca7ae2455577ceda0.tar.bz2
plugins.texi: Document plugin_is_GPL_compatible.
* 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. 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. From-SVN: r148667
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/doc/plugins.texi20
-rw-r--r--gcc/plugin.c11
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/g++.dg/plugin/attribute_plugin.c2
-rw-r--r--gcc/testsuite/g++.dg/plugin/dumb_plugin.c1
-rw-r--r--gcc/testsuite/g++.dg/plugin/selfassign.c1
-rw-r--r--gcc/testsuite/gcc.dg/plugin/ggcplug.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/one_time_plugin.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/selfassign.c2
10 files changed, 55 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 967cbbf..af65356 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/doc/plugins.texi b/gcc/doc/plugins.texi
index 9ae0a18..791e04b 100644
--- a/gcc/doc/plugins.texi
+++ b/gcc/doc/plugins.texi
@@ -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
diff --git a/gcc/plugin.c b/gcc/plugin.c
index 93151f8..396850a 100644
--- a/gcc/plugin.c
+++ b/gcc/plugin.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index caf69f5..b6a6fe1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/g++.dg/plugin/attribute_plugin.c b/gcc/testsuite/g++.dg/plugin/attribute_plugin.c
index 16b3496..deaebf1 100644
--- a/gcc/testsuite/g++.dg/plugin/attribute_plugin.c
+++ b/gcc/testsuite/g++.dg/plugin/attribute_plugin.c
@@ -9,6 +9,8 @@
#include "tree-pass.h"
#include "intl.h"
+int plugin_is_GPL_compatible;
+
/* Attribute handler callback */
static tree
diff --git a/gcc/testsuite/g++.dg/plugin/dumb_plugin.c b/gcc/testsuite/g++.dg/plugin/dumb_plugin.c
index 24da544..18f42c0 100644
--- a/gcc/testsuite/g++.dg/plugin/dumb_plugin.c
+++ b/gcc/testsuite/g++.dg/plugin/dumb_plugin.c
@@ -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. */
diff --git a/gcc/testsuite/g++.dg/plugin/selfassign.c b/gcc/testsuite/g++.dg/plugin/selfassign.c
index 2bc1d86..75b6161 100644
--- a/gcc/testsuite/g++.dg/plugin/selfassign.c
+++ b/gcc/testsuite/g++.dg/plugin/selfassign.c
@@ -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. */
diff --git a/gcc/testsuite/gcc.dg/plugin/ggcplug.c b/gcc/testsuite/gcc.dg/plugin/ggcplug.c
index f90e77b..49b5c95 100644
--- a/gcc/testsuite/gcc.dg/plugin/ggcplug.c
+++ b/gcc/testsuite/gcc.dg/plugin/ggcplug.c
@@ -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
diff --git a/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c b/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
index 8ae327a..635776f 100644
--- a/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
+++ b/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
@@ -9,6 +9,8 @@
#include "tree-pass.h"
#include "intl.h"
+int plugin_is_GPL_compatible;
+
static bool one_pass_gate (void)
{
return true;
diff --git a/gcc/testsuite/gcc.dg/plugin/selfassign.c b/gcc/testsuite/gcc.dg/plugin/selfassign.c
index 2bc1d86..52a03bf 100644
--- a/gcc/testsuite/gcc.dg/plugin/selfassign.c
+++ b/gcc/testsuite/gcc.dg/plugin/selfassign.c
@@ -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;