This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch][plugins] Check the gcc version


On Mon, Apr 27, 2009 at 5:34 AM, Rafael Espindola <espindola@google.com> wrote:
>
> It is attached. I works by creating plugin-version.h while building
> gcc. That header file contains
>
> -------------------------------------------------------
> ...
> static char basever[] = "4.5.0";
> static char datestamp[] = " 20090427";
> static char devphase[] = " (experimental)";
> static char revision[] = "" "FOO";
> static struct plugin_gcc_version plugin_gcc_version = {basever, datestamp,
> ? ? ? ? ? ? devphase, revision,
> ? ? ? ? ? ? configuration_arguments};
> ------------------------------------------------
>
> It is included by plugins.c and should also be included by any plugin
> that wants to know the gcc version it is being build for.

Sounds good.


>
> At runtime, gcc passes its version to the plugin. The plugin can do
> any checks it wants with it. In particular, it can check that the
> running gcc is the one the plugin was compiled for.
>
> One problem with the patch is that plugin-version.h is created by
> running "gcc -E -P". This will not work if gcc is being compiled by
> another compiler. What is the portable way to run the preprocessor?
>

Another possibility is to generate plugin-version.h in
gcc/configure{.ac}, similar to how GCC generates configargs.h.


> +++ b/gcc/gcc-plugin.h
>
 > /* The default version check. Compares every field in VERSION. */
 >
> -extern bool plugin_default_version_check(struct plugin_gcc_version *version);
> +extern bool plugin_default_version_check(struct plugin_gcc_version *,
> +                                        struct plugin_gcc_version *);

Need a space between plugin_default_version_check and '('.


> +++ b/gcc/plugin-version.h.in
>
> +static struct plugin_gcc_version plugin_gcc_version = {basever, datestamp,
> +                                                      devphase, revision,
> +                                                      configuration_arguments};

It is a bit confusing that the struct and the variable have the same
name (at least to me :-)). Maybe the variable name can be simply
gcc_version?


> +++ b/gcc/plugin.c
>
> +plugin_default_version_check(struct plugin_gcc_version *gcc_version,
> +                            struct plugin_gcc_version *plugin_version)

Need a space between plugin_default_version_check and '('.

Also on the plugins branch, you will need to change the plugin test
support to not link against the plugin-version.o and call
plugin_default_version_check with the new signature.

Thanks,

Le-chun


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]