Why is gcc 4.9 (trunk) so slow?

c++, c++11, clang, gcc4.9, linux

Solution

If the compiler is slower than expected, passing the `-ftime-report` flag can help figuring out what's going on.

Luckily, it also helped in this case: With `-ftime-report` GCC printed

'Extra diagnostic checks enabled; compiler may run slowly. Configure with --enable-checking=release to disable checks.'

Thomas has rebuilt the compiler from source accordingly and the problem is gone!

Problem

I have built an up-to-date vanilla GCC from svn with these flags: ``` ../configure \ --enable-languages=c,c++ \ --disable-nls \ --enable-multilib \ --prefix=/opt/other/gcc-svn \ --program-suffix=-svn \ --with-system-zlib ``` First with `clang 3.4`, then I thought it may be clang's fault (with a grain of salt) and rebuilt GCC once more with `GCC 4.8.1`, which led to the exact same result. The resulting GCC is about 17 seconds slower than GCC 4.8.1 when I try to compile a C++ project with approx. 150k lines of code. These are the build times I get (-O3): - `g++ 4.9`: 48 seconds - `g++ 4.8`: 31 seconds - `clang 3.4`: 13 seconds Did I miss a `configure` flag or is `GCC 4.9` really that much slower?!

Original source