One way to reduce compile time

GCC has been the de-facto standard compiler on Linux and most other platforms for compiling open-source software (e.g. apache, firefox, mysql etc.) for quite a while.  A standard complaint though is that the compiler has been getting steadily slower over time.  I’ve found this anecdotally true, and while for small projects it doesn’t really matter, when compiling Firefox takes upwards of an hour, it starts to be a more significant concern.

So here’s what happens when you compile an older version of GCC’s C compiler (3.4.6), with typical settings (-O2 -g) on a fairly modern machine using current compilers.

Compiler Time Notes
gcc 4.7.2 130.0 Current released version of gcc.
gcc dev 133.8 Current development sources of gcc. Build from svn source with debug checks disabled
clang 3.1 74.6 Current version of clang (C front-end for LLVM). Generally produces code that runs slightly slower than gcc.
pcc dev 47.2 Current development version of pcc, the portable C compiler. Note that pcc does not perform many optimizations.
icc 13.0 140.2 Current released version of the Intel C/C++ compiler.

Clearly, if you can except a modest difference in runtime performance (in most situations), you can get dramatically faster build times simply by switching out gcc for the newer clang compiler.

(You can get even faster builds with pcc, but your code will run substantially slower, and pcc doesn’t do C++, limiting use for many newer builds). 

Comments are closed.