[Development] CMake UNITY_BUILD ( QTBUG-109394 )
Shawn.Rutledge at qt.io
Tue Jan 17 10:44:09 CET 2023
> On 16 Jan 2023, at 13:49, Friedemann Kleint via Development <development at qt-project.org> wrote:
> I would like to propose considering making Qt suitable for CMake UNITY_BUILDs ( https://bugreports.qt.io/browse/QTBUG-109394 , https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD.html ) .
> This has originally been proposed for Qt for Python ( https://bugreports.qt.io/browse/PYSIDE-2155 ). It has greatly benefited from it; builds are much faster; particuarly for us in home-office where no distributed build environment exists.
> It is basically what webengine has been using for a long time: Source files are concatenated to jumbo files which are then compiled.
> For Qt for Python with its lots of generated files, the speed-up is drastic (~10x); for an average module (qttools), less so, but still:
> Initial build of qttools:
> Standard (675 files): real 3m26,016s / user 19m4,352s / sys 1m48,346s
> Unity (203 files) : real 2m2,557s / user 9m40,147s / sys 0m47,144s (CMAKE_UNITY_BUILD_BATCH_SIZE=16)
> with CCACHE/warmed up:
> Standard (675 files): real 1m50,605s / user 8m9,512s / sys 1m9,187s
> Unity (203 files) : real 1m30,990s / user 5m11,773s / sys 0m39,687s
Speaking of ccache, how stable is the selection of files that are concatenated? I suppose small changes will tend to invalidate more of the cache? Where before you could make a change in one cpp, and only one smaller cache object was invalidated, now it will invalidate the whole jumbo file’s cache, and after all rebuilding the jumbo file should take longer and produce a larger object than the smaller file that was changed. But I guess that’s the way it goes, since we are rebuilding Qt to test changes, not just rebuilding the same version over and over. I wonder if the ccache hit rate will actually go down though, so incremental rebuilding when you are just changing a line at a time could be slower.
Any trouble with icecream after this?
Otherwise it sounds like a win, mostly.
More information about the Development