[CI] Re-assert the ccache timestamp sloppiness after configure

CMakeLists.txt sets sloppiness=pch_defines,time_macros at configure
time, and ccache --set-config replaces the whole list rather than
extending it. Setting the four entries before cmake would therefore
leave the build with only two, so the entries CI needs have to be
written after the configure step and before the build.

The mtime and ctime entries cover files created during the build
itself: moc/uic/rcc output and protobuf headers are generated after
ccache starts, so without them every TU that includes one is read as
a race and never cached. Checked-out sources are older than the
compile that follows them and do not trip the check.
This commit is contained in:
Lukas Brübach 2026-11-04 09:14:34 +01:00
parent ed119cc940
commit ce0746d77f

View file

@ -185,9 +185,6 @@ if [[ $MAKE_COVERAGE ]]; then
fi fi
if [[ $USE_CCACHE ]]; then if [[ $USE_CCACHE ]]; then
flags+=("-DUSE_CCACHE=1") flags+=("-DUSE_CCACHE=1")
# PCH-aware caching is required or ccache refuses to cache any TU that
# consumes a precompiled header, silently recompiling everything on every run.
ccache --set-config sloppiness=pch_defines,time_macros
if [[ $CCACHE_SIZE ]]; then if [[ $CCACHE_SIZE ]]; then
# note, this setting persists after running the script # note, this setting persists after running the script
ccache --max-size "$CCACHE_SIZE" ccache --max-size "$CCACHE_SIZE"
@ -378,6 +375,21 @@ echo "Running cmake with flags: ${flags[*]}"
cmake .. "${flags[@]}" cmake .. "${flags[@]}"
echo "::endgroup::" echo "::endgroup::"
if [[ $USE_CCACHE ]]; then
# PCH-aware caching is required or ccache refuses to cache any TU that consumes a
# precompiled header, silently recompiling everything on every run. The mtime and ctime
# entries cover files created during the build itself: the moc/uic/rcc output and the
# protobuf headers are generated after ccache starts, so without them every TU including
# one is read as a race and never cached. Checked-out sources are older than the compile
# that follows them and do not trip the check.
#
# This has to run after configure: CMakeLists.txt sets sloppiness=pch_defines,time_macros
# at configure time, and --set-config replaces the whole list rather than extending it, so
# setting it earlier would leave the build below with two entries. Re-asserting all four
# here is what actually reaches the compiler; the order is the point.
ccache --set-config sloppiness=pch_defines,time_macros,include_file_mtime,include_file_ctime
fi
echo "::group::Build project" echo "::group::Build project"
cpuinfo cpuinfo
echo "Running cmake --build with flags: ${buildflags[*]}" echo "Running cmake --build with flags: ${buildflags[*]}"