[Development] Qt Compilation Speed
Thiago Macieira
thiago.macieira at intel.com
Mon Jan 3 15:10:24 CET 2022
On Monday, 3 January 2022 10:40:42 -03 Lars Knoll wrote:
> One other possible solution to improve compile times is the hack we used 15
> years ago in KDE, where we grouped many .cpp files into one compilation
> unit. There’s however a balance needed here, as it reduces the efficiency
> of -j, but maybe compiling 4-8 .cpp files as one unit could help.
I think CMake has that as a built-in mode, doesn't it?
Anyway, while this is great for reducing the number of build files, it's not a
complete solution. It does point to one simple thing we should all do:
includemoc. I think I've kept QtCore this way: all .cpp #include their
headers' moc output. This not only good for build time, it enables some extra
warnings by Clang when it sees the entire implementation of a given class.
So this is a low-hanging fruit and we should apply to all modules. Once a
year, we should check if there's any build out of a moc_*.cpp file left.
The second thing it points to is LTO. When you build thin LTO, the compilation
steps are much shorter because it's basically preprocessing and then creating
an AST (or equivalent) dump of what it read. The actual code gen is much
later. It still gets the benefit of removing <algorithm> though.
Anyway, this may help building Qt, but not our users. I think the
QGLOBAL_LEAN_AND_MEAN might be an interesting thing to explore.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel DPG Cloud Engineering
More information about the Development
mailing list