This is the mail archive of the
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
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
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
- 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
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:
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.