[Development] Unity Build on CI for Qt Base for 3 Platforms

Friedrich W. H. Kossebau kossebau at kde.org
Mon Aug 14 12:47:34 CEST 2023


Hi,

Am Freitag, 11. August 2023, 22:14:13 CEST schrieb Marc Mutz via Development:
> All my -unity-build-batch-size 100'000 patches except for one are now
> merged: https://codereview.qt-project.org/q/topic:unity-build
> 
> I'm currently testing without the unmerged one, because it won't apply
> to 6.5, anyway, and the goal is to have unity-builds from 6.5 onwards.
> Maybe a few more TUs will have to be excluded, but you should be able to
> see the pattern. So far it looks like it's not needed.
> 
> Compile with -unity-build -unity-build-batch-size 100000 and add all TUs
> that create problems with a small comment as to what's breaking to
> NO_UNITY_BUILD_SOURCES.

Just a quick note/question given 100000 seems to be used to denote "all the 
sources!":

CMake actually supports "0" as value for that purpose of "all!", had that been 
considered in the design, to be consistent with CMake's approach?

>From https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD_BATCH_SIZE.html
--- 8< ---
Although strongly discouraged, the batch size may be set to a value of 0 to 
combine all the sources for the target into a single unity file, regardless of 
how many sources are involved. This runs the risk of creating an excessively 
large unity source file and negatively impacting the build performance, so a 
value of 0 is not generally recommended.
--- 8< ---

Curiousity:

While at it, I am curious what purpose unity builds of Qt are supposed to 
serve, i.e. in which cases would exclusive use of unity builds be recommended 
to be used? Are there some docs/notes somewhere, when to use and when not?
Personally had been very impressed by the speed up when I first learned about 
the concept decades ago (KDE's --enable-final flag with unsermake IIRC) and 
the compiler at that time having more options to optimize the generated code. 
But with LTO these days, by what I understood, that advantage/purpose is gone.
And while I made some own project recently work with cmake unity builds for 
curiousity (thus knew about that special value "0" for batch sizes :) ) I am 
still wondering when actually unity builds make sense to be used, especially 
in parallel with supporting non-unity builds.
So, for which use cases are Qt's unity builds done? Whom will the docs 
recommend to use that build option?

Cheers
Friedrich




More information about the Development mailing list