Makefile.in (REVISION_s): Always include quotes.
2009-04-17 Rafael Avila de Espindola <espindola@google.com> * Makefile.in (REVISION_s): Always include quotes. Change ifdef to use REVISION_c. (OBJS-common): Add plugin-version.o. (plugin-version.o): New. * gcc-plugin.h (plugin_gcc_version): New. (plugin_default_version_check): New. (plugin_init_func, plugin_init): Add version argument. * plugin-version.c: New. * plugin.c (str_plugin_gcc_version_name): New. (try_init_one_plugin): Read plugin_gcc_version from the plugin and pass it to the init function. (plugin_default_version_check): New. From-SVN: r146274
This commit is contained in:
parent
61e20b90d9
commit
cf8aba7f5a
@ -1,3 +1,18 @@
|
|||||||
|
2009-04-17 Rafael Avila de Espindola <espindola@google.com>
|
||||||
|
|
||||||
|
* Makefile.in (REVISION_s): Always include quotes. Change ifdef to use
|
||||||
|
REVISION_c.
|
||||||
|
(OBJS-common): Add plugin-version.o.
|
||||||
|
(plugin-version.o): New.
|
||||||
|
* gcc-plugin.h (plugin_gcc_version): New.
|
||||||
|
(plugin_default_version_check): New.
|
||||||
|
(plugin_init_func, plugin_init): Add version argument.
|
||||||
|
* plugin-version.c: New.
|
||||||
|
* plugin.c (str_plugin_gcc_version_name): New.
|
||||||
|
(try_init_one_plugin): Read plugin_gcc_version from the plugin and
|
||||||
|
pass it to the init function.
|
||||||
|
(plugin_default_version_check): New.
|
||||||
|
|
||||||
2009-04-17 Richard Guenther <rguenther@suse.de>
|
2009-04-17 Richard Guenther <rguenther@suse.de>
|
||||||
|
|
||||||
* tree-ssa-alias.c (refs_may_alias_p_1): Do not use TBAA
|
* tree-ssa-alias.c (refs_may_alias_p_1): Do not use TBAA
|
||||||
|
@ -780,7 +780,7 @@ BUGURL_TEXI := @REPORT_BUGS_TEXI@
|
|||||||
ifdef REVISION_c
|
ifdef REVISION_c
|
||||||
REVISION_s := "\"$(if $(DEVPHASE_c), $(REVISION_c))\""
|
REVISION_s := "\"$(if $(DEVPHASE_c), $(REVISION_c))\""
|
||||||
else
|
else
|
||||||
REVISION_s :=
|
REVISION_s := "\"\""
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Shorthand variables for dependency lists.
|
# Shorthand variables for dependency lists.
|
||||||
@ -1154,6 +1154,7 @@ OBJS-common = \
|
|||||||
params.o \
|
params.o \
|
||||||
passes.o \
|
passes.o \
|
||||||
plugin.o \
|
plugin.o \
|
||||||
|
plugin-version.o \
|
||||||
pointer-set.o \
|
pointer-set.o \
|
||||||
postreload-gcse.o \
|
postreload-gcse.o \
|
||||||
postreload.o \
|
postreload.o \
|
||||||
@ -2003,7 +2004,7 @@ gcc-options.o: options.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) opts.h intl
|
|||||||
|
|
||||||
dumpvers: dumpvers.c
|
dumpvers: dumpvers.c
|
||||||
|
|
||||||
ifdef REVISION_s
|
ifdef REVISION_c
|
||||||
version.o: version.c version.h $(REVISION) $(DATESTAMP) $(BASEVER) $(DEVPHASE)
|
version.o: version.c version.h $(REVISION) $(DATESTAMP) $(BASEVER) $(DEVPHASE)
|
||||||
else
|
else
|
||||||
version.o: version.c version.h $(DATESTAMP) $(BASEVER) $(DEVPHASE)
|
version.o: version.c version.h $(DATESTAMP) $(BASEVER) $(DEVPHASE)
|
||||||
@ -2473,6 +2474,12 @@ passes.o : passes.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
|
|||||||
plugin.o : plugin.c $(PLUGIN_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h \
|
plugin.o : plugin.c $(PLUGIN_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h \
|
||||||
errors.h $(TOPLEV_H) $(TREE_H) $(TREE_PASS_H) intl.h
|
errors.h $(TOPLEV_H) $(TREE_H) $(TREE_PASS_H) intl.h
|
||||||
|
|
||||||
|
plugin-version.o : plugin-version.c $(SYSTEM_H) gcc-plugin.h configargs.h
|
||||||
|
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) \
|
||||||
|
-DBASEVER=$(BASEVER_s) -DDATESTAMP=$(DATESTAMP_s) \
|
||||||
|
-DREVISION=$(REVISION_s) -DDEVPHASE=$(DEVPHASE_s) -c \
|
||||||
|
-DPLUGIN $(srcdir)/plugin-version.c $(OUTPUT_OPTION)
|
||||||
|
|
||||||
main.o : main.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TOPLEV_H)
|
main.o : main.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TOPLEV_H)
|
||||||
|
|
||||||
host-default.o : host-default.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
|
host-default.o : host-default.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
|
||||||
|
@ -67,22 +67,42 @@ struct plugin_info
|
|||||||
const char *help;
|
const char *help;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Represents the gcc version. Used to avoid using an incompatible plugin. */
|
||||||
|
|
||||||
|
struct plugin_gcc_version
|
||||||
|
{
|
||||||
|
const char *basever;
|
||||||
|
const char *datestamp;
|
||||||
|
const char *devphase;
|
||||||
|
const char *revision;
|
||||||
|
const char *configuration_arguments;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct plugin_gcc_version plugin_gcc_version;
|
||||||
|
|
||||||
|
/* The default version check. Compares every field in VERSION. */
|
||||||
|
|
||||||
|
extern bool plugin_default_version_check(struct plugin_gcc_version *version);
|
||||||
|
|
||||||
/* Function type for the plugin initialization routine. Each plugin module
|
/* Function type for the plugin initialization routine. Each plugin module
|
||||||
should define this as an externally-visible function with name
|
should define this as an externally-visible function with name
|
||||||
"plugin_init."
|
"plugin_init."
|
||||||
|
|
||||||
PLUGIN_NAME - name of the plugin (useful for error reporting)
|
PLUGIN_NAME - name of the plugin (useful for error reporting)
|
||||||
|
VERSION - the plugin_gcc_version symbol of the plugin itself.
|
||||||
ARGC - the size of the ARGV array
|
ARGC - the size of the ARGV array
|
||||||
ARGV - an array of key-value argument pair
|
ARGV - an array of key-value argument pair
|
||||||
|
|
||||||
Returns 0 if initialization finishes successfully. */
|
Returns 0 if initialization finishes successfully. */
|
||||||
|
|
||||||
typedef int (*plugin_init_func) (const char *plugin_name,
|
typedef int (*plugin_init_func) (const char *plugin_name,
|
||||||
|
struct plugin_gcc_version *version,
|
||||||
int argc, struct plugin_argument *argv);
|
int argc, struct plugin_argument *argv);
|
||||||
|
|
||||||
/* Declaration for "plugin_init" function so that it doesn't need to be
|
/* Declaration for "plugin_init" function so that it doesn't need to be
|
||||||
duplicated in every plugin. */
|
duplicated in every plugin. */
|
||||||
extern int plugin_init (const char *, int, struct plugin_argument *);
|
extern int plugin_init (const char *, struct plugin_gcc_version *version,
|
||||||
|
int, struct plugin_argument *);
|
||||||
|
|
||||||
/* Function type for a plugin callback routine.
|
/* Function type for a plugin callback routine.
|
||||||
|
|
||||||
|
36
gcc/plugin-version.c
Normal file
36
gcc/plugin-version.c
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/* Version information for plugins.
|
||||||
|
Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||||
|
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GCC.
|
||||||
|
|
||||||
|
GCC is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 3, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with GCC; see the file COPYING3. If not see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#include "system.h"
|
||||||
|
#include "gcc-plugin.h"
|
||||||
|
#include "configargs.h"
|
||||||
|
|
||||||
|
static char basever[] = BASEVER;
|
||||||
|
static char datestamp[] = DATESTAMP;
|
||||||
|
static char devphase[] = DEVPHASE;
|
||||||
|
static char revision[] = REVISION;
|
||||||
|
|
||||||
|
/* FIXME plugins: We should make the version information more precise.
|
||||||
|
One way to do is to add a checksum. */
|
||||||
|
|
||||||
|
struct plugin_gcc_version plugin_gcc_version = {basever, datestamp, devphase,
|
||||||
|
revision,
|
||||||
|
configuration_arguments};
|
32
gcc/plugin.c
32
gcc/plugin.c
@ -99,6 +99,7 @@ static struct pass_list_node *prev_added_pass_node;
|
|||||||
/* Each plugin should define an initialization function with exactly
|
/* Each plugin should define an initialization function with exactly
|
||||||
this name. */
|
this name. */
|
||||||
static const char *str_plugin_init_func_name = "plugin_init";
|
static const char *str_plugin_init_func_name = "plugin_init";
|
||||||
|
static const char *str_plugin_gcc_version_name = "plugin_gcc_version";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Helper function for the hash table that compares the base_name of the
|
/* Helper function for the hash table that compares the base_name of the
|
||||||
@ -566,8 +567,10 @@ try_init_one_plugin (struct plugin_name_args *plugin)
|
|||||||
{
|
{
|
||||||
void *dl_handle;
|
void *dl_handle;
|
||||||
plugin_init_func plugin_init;
|
plugin_init_func plugin_init;
|
||||||
|
struct plugin_gcc_version *version;
|
||||||
char *err;
|
char *err;
|
||||||
PTR_UNION_TYPE (plugin_init_func) plugin_init_union;
|
PTR_UNION_TYPE (plugin_init_func) plugin_init_union;
|
||||||
|
PTR_UNION_TYPE (struct plugin_gcc_version*) version_union;
|
||||||
|
|
||||||
dl_handle = dlopen (plugin->full_name, RTLD_NOW);
|
dl_handle = dlopen (plugin->full_name, RTLD_NOW);
|
||||||
if (!dl_handle)
|
if (!dl_handle)
|
||||||
@ -590,8 +593,12 @@ try_init_one_plugin (struct plugin_name_args *plugin)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PTR_UNION_AS_VOID_PTR (version_union) =
|
||||||
|
dlsym (dl_handle, str_plugin_gcc_version_name);
|
||||||
|
version = PTR_UNION_AS_CAST_PTR (version_union);
|
||||||
|
|
||||||
/* Call the plugin-provided initialization routine with the arguments. */
|
/* Call the plugin-provided initialization routine with the arguments. */
|
||||||
if ((*plugin_init) (plugin->base_name, plugin->argc, plugin->argv))
|
if ((*plugin_init) (plugin->base_name, version, plugin->argc, plugin->argv))
|
||||||
{
|
{
|
||||||
error ("Fail to initialize plugin %s", plugin->full_name);
|
error ("Fail to initialize plugin %s", plugin->full_name);
|
||||||
return false;
|
return false;
|
||||||
@ -805,3 +812,26 @@ debug_active_plugins (void)
|
|||||||
{
|
{
|
||||||
dump_active_plugins (stderr);
|
dump_active_plugins (stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The default version check. Compares every field in VERSION. */
|
||||||
|
|
||||||
|
bool
|
||||||
|
plugin_default_version_check(struct plugin_gcc_version *version)
|
||||||
|
{
|
||||||
|
/* version is NULL if the plugin was not linked with plugin-version.o */
|
||||||
|
if (!version)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (strcmp (version->basever, plugin_gcc_version.basever))
|
||||||
|
return false;
|
||||||
|
if (strcmp (version->datestamp, plugin_gcc_version.datestamp))
|
||||||
|
return false;
|
||||||
|
if (strcmp (version->devphase, plugin_gcc_version.devphase))
|
||||||
|
return false;
|
||||||
|
if (strcmp (version->revision, plugin_gcc_version.revision))
|
||||||
|
return false;
|
||||||
|
if (strcmp (version->configuration_arguments,
|
||||||
|
plugin_gcc_version.configuration_arguments))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user