Dealing with compilers that pretend to be GCC
Duncan Sands
baldrick@free.fr
Thu Jan 19 14:58:00 GMT 2012
Hi Ludo,
> 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.
this suggests that you shouldn't be testing for GCC, and instead should be
testing for support for particular features. For example, to know if nested
functions are supported you would have your configure script compile a mini
program that uses nested functions.
Ciao, Duncan.
>
> 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â.
More information about the Gcc
mailing list