* 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
+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.
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
/* 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>
/* 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
/* 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);
+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.
#include "tree-pass.h"
#include "intl.h"
+int plugin_is_GPL_compatible;
+
/* Attribute handler callback */
static tree
#include "tree-pass.h"
#include "intl.h"
+int plugin_is_GPL_compatible;
/* Callback function to invoke after GCC finishes parsing a struct. */
#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. */
#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
#include "tree-pass.h"
#include "intl.h"
+int plugin_is_GPL_compatible;
+
static bool one_pass_gate (void)
{
return true;
#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;