autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_PROG_CC wrongly setting $GCC=yes while clang is used


From: David A. Wheeler
Subject: Re: AC_PROG_CC wrongly setting $GCC=yes while clang is used
Date: Mon, 08 Sep 2014 18:05:52 -0400 (EDT)

Bastien Chevreux <address@hidden>
> OK, before this duck thing gets a bit out of hand...

Oh, it's *way* too late for that :-).

> I would need to test whether the compiler accepts ?-OMG? 
> AND
> I would need a way to test whether the compiler is specifically GCC (not 
> clang, not icc) between 3.2.0 and 3.4.2
> as I would need to disable -OMG on GCC version 3.2.0 to 3.4.2 because of user 
> report of miscompilations and/or buggy code there.
...

Marko Lindqvist <address@hidden>:
> I'm ginving theoretical autoconf-way answer. I admit that in some
> individual cases the Right Thing(tm) might be too much work in
> practice, and the "check version number" hack is justifiable.
> 
> > I would need to test whether the compiler accepts ?-OMG?
> 
>  Test if compiler accepts "-OMG"
> 
> > AND
> > I would need a way to test whether the compiler is specifically GCC (not 
> > clang, not icc) between 3.2.0 and 3.4.2
> > as I would need to disable -OMG on GCC version 3.2.0 to 3.4.2 because of 
> > user report of miscompilations and/or buggy code there.
> 
>  Test if compiler miscompiles with "-OMG"

I agree with Marko Lindqvist's answer; if possible, it's better to directly 
detect if the miscompile happens. Sometimes it's too hard, but typically you 
can have a short-and-simple test case.  Version testing is a bad idea, even in 
this case.  Many Linux distributions backport "important" bug fixes, so 
comparing version numbers doesn't always work anyway!

However, compiler flags are special.  Unknown compiler flags can be tricky to 
detect. E.G.:
  gcc -o hello -IS_DUCK hello.c
will silently work, and report no error code.

Portably adding compiler flags is one of the nice features of Dale Visser's 
recent proposed patch (e.g., it adds AC_APPEND_FLAG_IFVALID), which I hope will 
be added.

--- David A. Wheeler



reply via email to

[Prev in Thread] Current Thread [Next in Thread]