On Wed, Jul 06, 2011 at 04:02:48PM +0200, Richard Guenther wrote:
> On Wed, Jul 6, 2011 at 3:46 PM, Basile Starynkevitch
> <bas...@starynkevitch.net> wrote:
> > On Wed, Jul 06, 2011 at 03:21:47PM +0200, Richard Guenther wrote:
> >> On Wed, Jul 6, 2011 at 2:50 PM, Basile Starynkevitch
> >> <bas...@starynkevitch.net> wrote:
> >> >
> >> > I beleive it can help to make plugin code more robust.
> 
> I'm not sure using cut is portable enough - for bversion.h generation
> we use sed instead (see Makefile.in), so I suppose copying that
> would be better.
> 
> I can't approve the configury changes but the change itself looks
> reasonable to me

I am attaching an improved patch to trunk rev 175920

#### gcc/ChangeLog entry #####

2011-07-06  Basile Starynkevitch  <bas...@starynkevitch.net>

        * configure.ac (plugin-version.h): Generate
        GCCPLUGIN_VERSION_MAJOR, GCCPLUGIN_VERSION_MINOR,
        GCCPLUGIN_VERSION_PATCHLEVEL, GCCPLUGIN_VERSION constant integer
        macros.

        * configure: Regenerate.

        * doc/plugins.texi (Building GCC plugins): Mention
        GCCPLUGIN_VERSION ... constant macros in plugin-version.h.

#### end of gcc/ChangeLog entry #####

Ok for trunk?

Cheers.
-- 
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} ***
Index: gcc/doc/plugins.texi
===================================================================
--- gcc/doc/plugins.texi	(revision 175920)
+++ gcc/doc/plugins.texi	(working copy)
@@ -417,6 +417,17 @@ invoking @command{gcc -print-file-name=plugin} (re
 Inside plugins, this @code{plugin} directory name can be queried by
 calling @code{default_plugin_dir_name ()}.
 
+Plugins may know, when they are compiled, the GCC version for which
+@file{plugin-version.h} is provided. The constant macros
+@code{GCCPLUGIN_VERSION_MAJOR}, @code{GCCPLUGIN_VERSION_MINOR},
+@code{GCCPLUGIN_VERSION_PATCHLEVEL}, @code{GCCPLUGIN_VERSION} are
+integer numbers, so a plugin could ensure it is built for GCC 4.7 with 
+@smallexample
+#if GCCPLUGIN_VERSION != 4007
+#error this GCC plugin is for GCC 4.7
+#endif
+@end smallexample
+
 The following GNU Makefile excerpt shows how to build a simple plugin:
 
 @smallexample
Index: gcc/configure
===================================================================
--- gcc/configure	(revision 175920)
+++ gcc/configure	(working copy)
@@ -11072,6 +11072,11 @@ fi
 cat > plugin-version.h <<EOF
 #include "configargs.h"
 
+#define GCCPLUGIN_VERSION_MAJOR   `echo $gcc_BASEVER | sed -e 's/^\([0-9]*\).*$/\1/'`
+#define GCCPLUGIN_VERSION_MINOR   `echo $gcc_BASEVER | sed -e 's/^[0-9]*\.\([0-9]*\).*$/\1/'`
+#define GCCPLUGIN_VERSION_PATCHLEVEL   `echo $gcc_BASEVER | sed -e 's/^[0-9]*\.[0-9]*\.\([0-9]*\)$/\1/'`
+#define GCCPLUGIN_VERSION  (GCCPLUGIN_VERSION_MAJOR*1000 + GCCPLUGIN_VERSION_MINOR)
+
 static char basever[] = "$gcc_BASEVER";
 static char datestamp[] = "$gcc_DATESTAMP";
 static char devphase[] = "$gcc_DEVPHASE";
@@ -17623,7 +17628,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17626 "configure"
+#line 17631 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -17729,7 +17734,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17732 "configure"
+#line 17737 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 175920)
+++ gcc/configure.ac	(working copy)
@@ -1511,6 +1511,11 @@ fi
 cat > plugin-version.h <<EOF
 #include "configargs.h"
 
+#define GCCPLUGIN_VERSION_MAJOR   `echo $gcc_BASEVER | sed -e 's/^\([0-9]*\).*$/\1/'`
+#define GCCPLUGIN_VERSION_MINOR   `echo $gcc_BASEVER | sed -e 's/^[0-9]*\.\([0-9]*\).*$/\1/'`
+#define GCCPLUGIN_VERSION_PATCHLEVEL   `echo $gcc_BASEVER | sed -e 's/^[0-9]*\.[0-9]*\.\([0-9]*\)$/\1/'`
+#define GCCPLUGIN_VERSION  (GCCPLUGIN_VERSION_MAJOR*1000 + GCCPLUGIN_VERSION_MINOR)
+
 static char basever[] = "$gcc_BASEVER";
 static char datestamp[] = "$gcc_DATESTAMP";
 static char devphase[] = "$gcc_DEVPHASE";

Reply via email to