views:

301

answers:

3

I'm currently using GCC, but I discovered Clang recently and I'm pondering switching. There is one deciding factor though - quality (speed, memory footprint, reliability) of binaries it produces - if gcc -O3can produce a binary that runs 1% faster or takes 1% less memory, it's a deal-breaker.

Clang boasts better compile speeds and lower compile-time memory footprint than GCC, but I'm really interested in benchmarks/comparisons of resulting compiled software - could you point me to some or describe your experiences?

+4  A: 

The only way to determine this is to try it. FWIW I have seen some really good improvements using Apple's LLVM gcc 4.2 compared to the regular gcc 4.2 (for x86-64 code with quite a lot of SSE), but YMMV for different code bases. Assuming you're working with x86/x86-64 and that you really do care about the last few percent then you ought to try Intel's ICC too, as this can often beat gcc - you can get a 30 day evaluation license from intel.com and try it.

Paul R
+8  A: 

Phoronix did some benchmarks about this, but it is about a snapshot version of Clang/LLVM from a few months back. The results being that things were more-or-less a push; neither GCC nor Clang is definitively better in all cases.

Since you'd use the latest Clang, it's maybe a little less relevant. Then again, GCC 4.6 is slated to have some major optimizations for Core 2 and i7, apparently.

I figure Clang's faster compilation speed will be nicer for original developers, and then when you push the code out into the world, Linux distro/BSD/etc. end-users will use GCC for the faster binaries.

Cirno de Bergerac
Ha, beat me by a few seconds.
mcandre
Just today i run a few benchmarks on Clang compilation speed and it's very disappointing for pure C. Compiling 35 C files with 270 KLOC clang was only 25% faster. When i see how fast tinycc is on linux it is a bad result for a new written compiler. It gets better when using optimizations -O2/-O3 but since they are used for release build the compiler performance does not matter in this cases.
Lothar
+5  A: 

The fact that Clang compiles code faster may not be as important as the speed of the resulting binary. However, here is a series of benchmarks.

mcandre
@mcandre: Actually it does. During development the compilation time (and the consumption of resources due to compilation) are much more of a bottleneck than the binary performance. After all, we compile in Debug mode at this stage. It's only when comes the stage to test and ship that you switch to Release mode and try to get as fast possible a binary.
Matthieu M.