[LLVMdev] Just got bitten by accidentally using the wrong gcc

Gonsolo gonsolo at gmail.com
Fri Mar 21 17:00:30 PDT 2008


Joachim Durchholz schrieb:
> Am Freitag, den 21.03.2008, 06:56 -0700 schrieb Shantonu Sen:
>> I recommend you don't parse version strings. In fact I switch the  
>> check to use AC_COMPILE precisely for the reason that gcc --version is  
>> totally unreliable and vendor specific. For example, what's the  
>> regular expression that tells you what the GCC version is:
>> i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5470)  
>> (Aspen 5470.3)
> 
> Rrright. -v isn't very helpful; I'd have thought it would.
> 
> Alternatives would be
>   gcc -dumpversion
> or __GNUC__, __GNUC_MINOR__, and __GNUC_PATCHLEVEL__ from inside a C
> program. (I just checked, __GNUC_PATCHLEVEL is documented to be
> available since 3.0, -dumpversion since 3.0.4 or possibly earlier.)

The Linux kernel uses a script called gcc-version that returns "0402" 
for gcc-4.2. It can be found at http://tinyurl.com/3xvbhh .
It is essentially a call to echo __GNUC__ | gcc -E -xc - | tail -n1 .

g




More information about the llvm-dev mailing list