I remember years ago reading about some C++ developers who use GCC using LLVM instead for local development, because it was way faster and gave better error mesages. Then continue to use GCC for production builds.
Today in the Rust world there is discussion on using Crane Lift for development builds, and LLVM for production builds. The history of Rust's slow compile times is heavily entangled by LLVM. To the point that LLVM is basically the main issue now.
It's crazy how the tables have turned from LLVM being known for being fast, to being known for being slow.
We happen to dual compile our C++ code with GCC and Clang at work: given how fiddly C++ is, it's better when the two major compilers for Linux agree on the legality and meaning of code.
I remember years ago reading about some C++ developers who use GCC using LLVM instead for local development, because it was way faster and gave better error mesages. Then continue to use GCC for production builds.
Still true: better error messages, faster to compile.
It's crazy how the tables have turned from LLVM being known for being fast, to being known for being slow.
It's still a fast C++ compiler, faster than GCC, and AFAIK faster than MSVC.
But... C++ compile-time are some of the worst you can experience, so it's slow compared to everything else.
Still true: better error messages, faster to compile.
Not in my experience. GCC has more or less caught up with clang for error messages, and clang has been slower to compile code for quite a while, since every company has been putting their pet optimizations in to it. (As a result, it's also caught up with GCC in terms of code quality.)
Interesting. In our setup we still see the same divide:
Clang is faster to compile.
GCC produces faster code.
The former is easy to see: the Clang CI builds are slightly faster.
With that said, I should probably mention that we use a slightly old build of GCC (7.3), vs Clang 9. Unfortunately GCC 8.x changed the inline heuristics, and it's been hell trying to regain the performance so we abandoned the effort, and GCC 9.x still miscompiles our code as far as I know. Crossing fingers for GCC 10.x.
C++ compile times can get ridiculously and hilariously bad, yes, but you can also fix most of this keeping #includes out of headers where possible, trying to avoid using templates where possible, and using precpmpiled headers. I know, because I just took a personal project from pushing 5 mins down to under 15 seconds.
I'm using msvc though, have no reason to ever touch a non Windows compiler
We do not use precompiled headers. I've personally found them to be too finicky, with bizarre and sometimes silent failure modes, so I prefer to steer clear of them.
Instead, we use Docker + Bazel:
Docker to provide a common base: same system headers and dependencies for everyone.
Bazel for its distributed caching abilities.
Most incremental builds are relatively fast, as long as you stick to the leaves or only re-compile for a small subset life is good.
Distributed caching + CI builds populating the cache means that pulling HEAD generally means pulling from the distributed cache, rather compiling, which helps quite a bit. Although, in these days of pandemic, we've realized that pulling from home is quite sluggish.
31
u/jl2352 May 11 '20
I remember years ago reading about some C++ developers who use GCC using LLVM instead for local development, because it was way faster and gave better error mesages. Then continue to use GCC for production builds.
Today in the Rust world there is discussion on using Crane Lift for development builds, and LLVM for production builds. The history of Rust's slow compile times is heavily entangled by LLVM. To the point that LLVM is basically the main issue now.
It's crazy how the tables have turned from LLVM being known for being fast, to being known for being slow.