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]

Configure-time testing for GCC plugins to determine C vs C++? (Was Re: status of GCC & C++)


On Sun, 2012-03-25 at 22:10 +0200, Basile Starynkevitch wrote:
> On Sun, 25 Mar 2012 20:30:31 +0200
> Basile Starynkevitch <basile@starynkevitch.net> wrote:
> > 
> > How can a plugin know that cc1 was compiled with C++ or just with
> > plain C? I don't really know (we do have GCCPLUGIN_VERSION, but should a plugin use
> > ENABLE_BUILD_WITH_CXX)?
> 
[...snip discussion of various ways to try to "ask" GCC  whether it was
built with a C or a C++ compiler...]

> Since 4.7 is probably the only release of GCC which can be compiled by C and by C++ I
> believe it is a bug specific to that release.
> 
> I'm sure this bug affect several GCC plugins. It does affect GCC MELT for instance.
> https://groups.google.com/forum/?fromgroups#!topic/gcc-melt/PRWr28sQExk

As noted in another thread, it also affects the Python plugin:
https://fedorahosted.org/pipermail/gcc-python-plugin/2012-March/000202.html
https://fedorahosted.org/pipermail/gcc-python-plugin/2012-March/000204.html

> My feeling is that it is not only the plugins' fault (so it is not only a MELT plugin
> bug, but a GCC one)
> 
> 
> What do you think? Should 4.7.1 provide a fix to correct that? How? Testing simply
> ENABLE_BUILD_WITH_GCC makes me feel unhappy; that name is really confusing, if we
> understand and use it as GCC_IS_BUILT_WITH_CXX

Presumably a fix would be for the plugin's configuration phase to have a
test that tries to build a test plugin and run it, first building with a
C compiler, then a C++ compiler, and decides what compiler the real
plugin should be built with accordingly.

Presumably the only APIs that are guaranteed for use by plugins so far
are the ones directly relating to plugins themselves:
  * plugin_default_version_check
  * register_callback

I'd hoped that a suitable feature test might be a minimal test plugin
that simply tries to call plugin_default_version_check() in its init
function: that way the plugin_init can only run if the dynamic link
succeeds, and you've got the correct compiler.

However, annoyingly, in gcc-plugin.h
http://gcc.gnu.org/viewcvs/trunk/gcc/gcc-plugin.h?revision=184997&view=markup
'extern "C"' guards are present around the relevant declarations, making
these symbols unsuitable for use in a configure-time test.

So are there any plugin-visible symbols that aren't yet wrapped in an
extern "C"?

(FWIW I've been working on a possible plugin API for GCC, similar to the
one I posted in my earlier mail, trying to get my python plugin to
compile against it, but I don't have anything working yet)

> My wish would be to add, perhaps in gcc/configure.ac of GCC 4.7.1, something which
> defines GCCPLUGIN_IN_CXX in e.g.  $(gcc-4.7 -print-file-name=plugin)/plugin-version.h
> when gcc-4.7 have been built with a C++ compiler so its plugins need to be compiled with
> a C++ compiler. That information should also be accessible (e.g. for plugin makers) thru
> some invocation of GCC (perhaps gcc -v).



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