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
This commit is contained in:
parent
3600f67820
commit
fca5bb5ca8
@ -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.
|
||||
|
@ -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
|
||||
|
11
gcc/plugin.c
11
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);
|
||||
|
@ -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.
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "tree-pass.h"
|
||||
#include "intl.h"
|
||||
|
||||
int plugin_is_GPL_compatible;
|
||||
|
||||
/* Attribute handler callback */
|
||||
|
||||
static tree
|
||||
|
@ -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. */
|
||||
|
||||
|
@ -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. */
|
||||
|
@ -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
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "tree-pass.h"
|
||||
#include "intl.h"
|
||||
|
||||
int plugin_is_GPL_compatible;
|
||||
|
||||
static bool one_pass_gate (void)
|
||||
{
|
||||
return true;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user