Re: Compiler warnings while compiling gcc with clang‏ -- clang compilation speed on building GCC

Vladimir Makarov
Tue May 5 14:40:00 GMT 2015

On 05/05/2015 12:42 AM, Aditya K wrote:
> I was able to successfully bootstrap gcc by using clang as the stage 1 compiler. I configured gcc using the following arguments.
> ../configure --disable-multilib --enable-bootstrap --enable-languages=c,c++ CC=/work/llvm/install-release/bin/clang CXX=/work/llvm/install-release/bin/clang++
> And the bootstrap was successful. One useful thing I got to see was clang warnings. Clang produced several warnings (> 1000 unique ones). I have attached two files with this email.
I also recently interested in building GCC by LLVM.   Although I was 
interesting in compilation speed of LLVM.

So I built GCC-5 sources with LLVM-3.6 and GCC-5 using 
--disable-bootstrap --enable-languages=c to minimize time spent by built 
GCC to compile libraries (or GCC-5 sources again for bootstrap).  Here 
are the results of make -j1 on E5-2997v3 (default -O2 was used by the 
both compilers):

       GCC-5   LLVM-3.6
real  20m44s  20m31s
user  15m35s  15m56s

Another interesting thing I found on SPEC2006 (only C/C++ benchmarks 
were used for FP) for -O1 (the machine is 4.2Ghz i7-4790K).

x86-64 SPEC rates (more is better):
INT:          LLVM    GCC
-O1:          34.9   39.8   14%

FP:           LLVM    GCC
-O1:          35.7   48.5   36%

x86-64 Compilation time in seconds (cpu time):
INT:            LLVM     GCC
-O1:          196.46  153.66   -22%

FP:             LLVM     GCC
-O1:          110.22   86.83   -21%

So GCC-5 in -O1 mode generates 20% better code and spent 15-30% less 
time on compilation than LLVM-3.6.

LLVM is popular for JITing but I believe GCC has much bigger potential 
for this and recommend JIT developers to try it.

I think it helps to see alternative point of view on LLVM as "a faster 
compiler than GCC".

More information about the Gcc mailing list