For my tests I need to compile some thousand C++ files which have a lot of code in common. Because not all compilers are conformant (or more permissive) I execute all my tests with g++, clang++ and msvc on windows and linux.
To improve compile times I use already precompiled headers for common code. Additionally I wrote a small preprocessor app to allow "unity builds" (combine *.cpp files into a single *.cpp file).
Currently I get the following compile times (random test case):
- MSVC with PCH: 0.573 secs
- MSVC without PCH: 5.367 secs
(approx 10 times)
- Clang with PCH: 5.221 secs
- Clang without PCH: 7.225 secs
(approx 1.4 times)
- G++ with PCH: 3.099 secs
- G++ without PCH: 5.826 secs
(approx 1.9 times)
Unfortunately my code contains a lot of templates / template instantiations which seem to be only "saved" in the Microsoft PCH.
Do you know any way to get similar compile times for g++ and clang++? Do you have any suggestion how to improve my compile times?
Here you can see the chrome/clang trace (-ftime-trace and pch):
