makefilecmakestracecallgrind

CMake 3.16 orders of magnitude slower in the Generate phase for Makefiles compared to older versions


I'm consulting a company on how to speed up their builds and I immediately pointed them to precompiled headers and unity builds - the 10 minute full build could easily drop to 2-3 minutes. Luckily CMake 3.16 was recently released and it supports both of those, so I told them to upgrade.

The problem is the following: once they switched from CMake 2.6 to 3.16 the time it took to run CMake jumped from about 20 seconds to more than 10 minutes. Most of the time is spent in the generate phase. It does complete successfully if you gave it enough time and the code compiled successfully with unity builds, but this CMake time is unacceptable.

Here is their setup:

Here is what we observed:

I couldn't find any reports of anyone else having the same problem on the internet... Any ideas what to try next? Perhaps profile using Perf? Try with Ninja as a backend (report of that being faster)?


Solution

  • Great analysis. This will be helpful for the developers of CMake. But I doubt you will find much help here. Please open an issue.

    Bonus points if you can provide a minimal example showcasing your problem. You might get this with generating tons of files.