This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Dealing with compilers that pretend to be GCC
- From: ludovic dot courtes at inria dot fr (Ludovic Courtès)
- To: gcc at gcc dot gnu dot org, bug-autoconf at gnu dot org
- Date: Thu, 19 Jan 2012 15:24:48 +0100
- Subject: Dealing with compilers that pretend to be GCC
Hello,
A number of compilers claim to be GCC, without actually being GCC. This
has come to a point where they can hardly be distinguishedâuntil one
actually tries to use them.
I had the following macro to determine whether plug-in support is
available:
https://gforge.inria.fr/scm/viewvc.php/trunk/m4/gcc.m4?view=markup&revision=5169&root=starpu&pathrev=5202
The macro is fairly elaborate. Yet, ICC 12.0.1 and Clang 3.4 both pass
the test, because:
- They support â--versionâ;
- They define â__GNUC__â, which defeats Autoconfâs
â_AC_LANG_COMPILER_GNUâ.
- They support â-print-file-nameâ, and have â-print-file-name=pluginâ
return GCCâs (!) plug-in header directory. To that end, ICC simply
runs âgcc -print-file-name=pluginâ, while Clang appears to be doing
some guesswork.
It turns out that ICC manages to build a working GCC plug-in, so after
all, it may be âentitledâ to define â__GNUC__â, in a broad sense.
Conversely, Clang doesnât support several GNU extensions, such as nested
functions, so it quickly fails to compile code.
Based on that, I modified my feature test like this:
https://gforge.inria.fr/scm/viewvc.php/trunk/m4/gcc.m4?root=starpu&r1=5169&r2=5203
I donât see what can be done on âourâ side (perhaps Autoconfâs feature
test could be strengthened, but how?), but I wanted to document this
state of affairs.
Thanks,
Ludoâ.