On Sun, 25 Mar 2012 20:30:31 +0200 Basile Starynkevitch <bas...@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)?
Actually, I tend to believe that this is really a bug in GCC 4.7 (specifically). I think that A) gcc-4.7 -v should obviously tell if it was compiled in C++ mode or in C mode, since this information is crucial to plugins. On Debian/Sid I don't have a simple way to get that information. % /usr/bin/gcc-4.7 -v Using built-in specs. COLLECT_GCC=/usr/bin/gcc-4.7 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.0-1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c+ +,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c+ +/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.7.0 (Debian 4.7.0-1) Nothing above tell me about GCC being compiled in C++ flavor B) the $(gcc-4.7 -print-file-name=plugin)/ directory should have a header file with something telling if it was compiled in C++ or C mode. (Perhaps ENABLE_BUILD_WITH_GCC might have that role in auto-host.h, but then I think it is grossly misnamed). 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 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 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). Cheers PS. Compatibility with C++ plugins was already discussed, but I forgot when... Here I focus on a possible bug of GCC 4.7. -- 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} ***