This is the mail archive of the gcc@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]

GCCPLUGIN_VERSION and plugin-version.h


Hello All,

I was and I am still in favor of providing macros like GCCPLUGIN_VERSION in plugin
header files. And in the generated and installed plugin-version.h we rightly have

#################### generated gcc/plugin-version.h ######################
#include "configargs.h"

#define GCCPLUGIN_VERSION_MAJOR   4
#define GCCPLUGIN_VERSION_MINOR   7
#define GCCPLUGIN_VERSION_PATCHLEVEL   0
#define GCCPLUGIN_VERSION  (GCCPLUGIN_VERSION_MAJOR*1000 + GCCPLUGIN_VERSION_MINOR)

static char basever[] = "4.7.0";
static char datestamp[] = "20120121";
static char devphase[] = "experimental";
static char revision[] = "[trunk revision 183369]";

/* FIXME plugins: We should make the version information more precise.
   One way to do is to add a checksum. */

static struct plugin_gcc_version gcc_version = {basever, datestamp,
						devphase, revision,
						configuration_arguments};
#################### end of gcc/plugin-version.h ######################



And the generated configargs.h has (sorry for the wrong :
###################### generated gcc/configargs.h ########################
/* Generated automatically. */
static const char configuration_arguments[] = "/usr/src/Lang/gcc-trunk-bstarynk/configure
--program-suffix=-trunk --libdir=/usr/local/lib/gcc-trunk
--libexecdir=/usr/local/libexec/gcc-trunk
--with-gxx-include-dir=/usr/local/lib/gcc-trunk/include/c++/ --enable-maintainer-mode
--enable-plugins --disable-bootstrap --enable-lto LIBS=-L/usr/lib/x86_64-linux-gnu/
--enable-languages=c,c++,lto CC='gcc -g' CXX='g++ -g' :
(reconfigured) /usr/src/Lang/gcc-trunk-bstarynk/configure --program-suffix=-trunk
--libdir=/usr/local/lib/gcc-trunk --libexecdir=/usr/local/libexec/gcc-trunk
--with-gxx-include-dir=/usr/local/lib/gcc-trunk/include/c++/ --enable-maintainer-mode
--enable-plugins --disable-bootstrap --enable-lto LIBS=-L/usr/lib/x86_64-linux-gnu/
--enable-languages=c,c++,lto CC='gcc -g' CXX='g++ -g'"; 
static const char thread_model[] = "posix";

static const struct {
  const char *name, *value;
} configure_default_options[] = { { "cpu", "generic" }, { "arch", "x86-64" } };
#################### end gcc/configargs.h ####################

(BTW, the configuration_arguments is on one big line which might have been broken by
copy/pasting here)


However, I find something troublesome. A plugin can obviously be made of several files
sharing a common plugin-specific header (which is melt-run.h for MELT). And that header
wants to #include "plugin-version.h" quite early to precisely get the GCCPLUGIN_VERSION
macro quite early (and it could do conditional preprocessing like e.g. #if
GCCPLUGIN_VERSION>4007 etc).

In that case, all the files compiled by the plugin would contain the static constants
configuration_arguments,  thread_model, configure_default_options, basever, datestamp,
devphase, revision, which I find quite bad, first because of unintended name clash (a
plugin would easily use the identifier revision), and because the same static data would
be in every object file of that plugin.

I believe it is a bug (albeit a minor one) to be improved before releasing 4.7

We could improve it 
   first, by generating constant names starting with a common prefix, perhaps gcc_, so we
would generate gcc_configuration_arguments, ... gcc_revision which minimize name clashes
with plugin code.

   second, by generating the pre-processor macros (and only them) in a separate file,
perhaps gcc/plugin-version-info.h, which would be #include-d from gcc/plugin-version.h,
and which should be documented as includable early from plugin headers, and containing
something like

###################### proposed generated gcc/plugin-version-info.h ########################
#ifndef GCCPLUGIN_VERSION
/* generated file for GCC plugins - DO NOT EDIT */
#define GCCPLUGIN_VERSION_MAJOR   4
#define GCCPLUGIN_VERSION_MINOR   7
#define GCCPLUGIN_VERSION_PATCHLEVEL   0
#define GCCPLUGIN_VERSION  (GCCPLUGIN_VERSION_MAJOR*1000 + GCCPLUGIN_VERSION_MINOR)
#endif /*GCCPLUGIN_VERSION*/
####################### end of gcc/plugin-version-info.h ###################################

Notice that there are no static data in the above file; then we would have 

###################### proposed generated gcc/plugin-version.h ############################
#include "plugin-version-info.h"
#include "configargs.h"

static char gcc_basever[] = "4.7.0";
static char gcc_datestamp[] = "20120121";
static char gcc_devphase[] = "experimental";
static char gcc_revision[] = "[trunk revision 183369]";

/* FIXME plugins: We should make the version information more precise.
   One way to do is to add a checksum. */

static struct plugin_gcc_version gcc_version = {gcc_basever, gcc_datestamp,
						gcc_devphase, gcc_revision,
						gcc_configuration_arguments};
############## end of gcc/plugin-version.h ####################

and the generated configargs.h would define identifiers like gcc_configuration_arguments
and gcc_thread_model and gcc_configure_default_options

Another possibility could be to leave the name as before, and wrap all the static
definitions with #ifndef GCC_NO_STATIC_PLUGIN_INFO #endif

What do you think? 

I really think it is a small bug which should be corrected before 4.7 release. Should I
open a bug report? Or propose a patch?

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 mine, sont seulement les miennes} ***


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