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: gcc version against which a plugin is compiled - documentation?


> A small documenation patch is attached.
>
> ### gcc/ChangeLog
> 2009-11-11 ÂBasile Starynkevitch Â<basile@starynkevitch.net>
> Â Â Â Â* doc/plugins.texi (Plugin initialization): Added advices for
> Â Â Â Âretrieving the version of GCC at plugin compilation and loading
> Â Â Â Âtimes.
> ###
>
> Is that ok?

Sorry for taking so long. Was busy on the lto side.
The documentation is really incomplete. Thanks for pointing it out. I
also noticed that the testcases were incorrectly trying to check the
version :-(

I added testcase fixes to the patch and changed the documentation a
bit. I think it is probably better to include plugin-version.h even
when not using plugin_default_version_check. The user do any checks it
wants to with the individual fields without the need for extra macros.

Basile, Diego, do you guys think the patch is OK? Tested with make
info and make check-gcc RUNTESTFLAGS="plugin.exp".

gcc/
2009-11-17  Basile Starynkevitch  <basile@starynkevitch.net>
            Rafael Avila de Espindola  <espindola@google.com>

        * doc/plugins.texi (Plugin initialization): Added advices for
        retrieving the version of GCC at plugin compilation and loading
        times.

gcc/testsuite/
2009-11-17  Rafael Avila de Espindola  <espindola@google.com>

	* g++.dg/plugin/selfassign.c: Include plugin-version.h.
	(plugin_init): Pass correct version to plugin_default_version_check.
	* gcc.dg/plugin/ggcplug.c: Include plugin-version.h.
	(plugin_init): Pass correct version to plugin_default_version_check.
	* gcc.dg/plugin/selfassign.c: Include plugin-version.h.
	(plugin_init): Pass correct version to plugin_default_version_check.


> Regards.
>
>
> --
> Basile STARYNKEVITCH Â Â Â Â http://starynkevitch.net/Basile/
> email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
> 8, rue de la Faiencerie, 92340 Bourg La Reine, France
> *** opinions {are only mines, sont seulement les miennes} ***
>


Cheers,
-- 
Rafael Ãvila de EspÃndola
diff --git a/gcc/doc/plugins.texi b/gcc/doc/plugins.texi
index 6639a4e..44b172d 100644
--- a/gcc/doc/plugins.texi
+++ b/gcc/doc/plugins.texi
@@ -105,6 +105,25 @@ The function @code{plugin_default_version_check} takes two pointers to
 such structure and compare them field by field. It can be used by the
 plugin's @code{plugin_init} function.
 
+The version of gcc used to compile the plugin can be found in the symbol
+@code{gcc_version} defined in the header @file{plugin-version.h}. The
+recomended version check looks like
+
+@smallexample
+#include "plugin-version.h"
+...
+
+int
+plugin_init (struct plugin_name_args *plugin_info,
+             struct plugin_gcc_version *version)
+@{
+  if (!plugin_default_version_check (version, &gcc_version))
+    return 1;
+
+@}
+@end smallexample
+
+but you can also check the individual fields if you want a less strict check.
 
 @subsection Plugin callbacks
 
diff --git a/gcc/testsuite/g++.dg/plugin/selfassign.c b/gcc/testsuite/g++.dg/plugin/selfassign.c
index 6dade30..8d76301 100644
--- a/gcc/testsuite/g++.dg/plugin/selfassign.c
+++ b/gcc/testsuite/g++.dg/plugin/selfassign.c
@@ -13,6 +13,7 @@
 #include "tree.h"
 #include "tree-pass.h"
 #include "intl.h"
+#include "plugin-version.h"
 
 int plugin_is_GPL_compatible;
 
@@ -305,7 +306,7 @@ plugin_init (struct plugin_name_args *plugin_info,
   bool enabled = true;
   int i;
 
-  if (!plugin_default_version_check (version, version))
+  if (!plugin_default_version_check (version, &gcc_version))
     return 1;
 
   /* Self-assign detection should happen after SSA is constructed.  */
diff --git a/gcc/testsuite/gcc.dg/plugin/ggcplug.c b/gcc/testsuite/gcc.dg/plugin/ggcplug.c
index 49b5c95..03bd563 100644
--- a/gcc/testsuite/gcc.dg/plugin/ggcplug.c
+++ b/gcc/testsuite/gcc.dg/plugin/ggcplug.c
@@ -12,6 +12,7 @@
 #include "tree-pass.h"
 #include "intl.h"
 #include "gcc-plugin.h"
+#include "plugin-version.h"
 
 int plugin_is_GPL_compatible;
 
@@ -43,7 +44,7 @@ plugin_init (struct plugin_name_args *plugin_info,
   int argc = plugin_info->argc;
   int i = 0;
   struct plugin_argument *argv = plugin_info->argv;
-  if (!plugin_default_version_check (version, version))
+  if (!plugin_default_version_check (version, &gcc_version))
     return 1;
   /* Process the plugin arguments. This plugin takes the following arguments:
      count-ggc-start count-ggc-end count-ggc-mark */
diff --git a/gcc/testsuite/gcc.dg/plugin/selfassign.c b/gcc/testsuite/gcc.dg/plugin/selfassign.c
index f804222..8d76301 100644
--- a/gcc/testsuite/gcc.dg/plugin/selfassign.c
+++ b/gcc/testsuite/gcc.dg/plugin/selfassign.c
@@ -13,7 +13,7 @@
 #include "tree.h"
 #include "tree-pass.h"
 #include "intl.h"
-
+#include "plugin-version.h"
 
 int plugin_is_GPL_compatible;
 
@@ -306,7 +306,7 @@ plugin_init (struct plugin_name_args *plugin_info,
   bool enabled = true;
   int i;
 
-  if (!plugin_default_version_check (version, version))
+  if (!plugin_default_version_check (version, &gcc_version))
     return 1;
 
   /* Self-assign detection should happen after SSA is constructed.  */

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