Skip to content

[cmake] Drop CMake's cached DEPFILE list after generating a dictionary - #23876

Merged
dpiparo merged 1 commit into
root-project:masterfrom
guitargeek:dict-depfile-makefiles
Oct 28, 2026
Merged

dpiparo merged 1 commit into
root-project:masterfrom
guitargeek:dict-depfile-makefiles

Conversation

@guitargeek

@guitargeek guitargeek commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

The Makefile generators of CMake < 4.0 merge the entries of a custom command's DEPFILE into CMakeFiles/.dir/compiler_depend.internal instead of replacing them (CMake issue 26399 [1], fixed in 4.0 only). Every file rootcling ever recorded therefore stays a prerequisite of the dictionary for the life of the build tree. Once one of them disappears, e.g. because a CI job restores a master build tree and then checks out a PR whose base predates a header or LinkDef that master had added, the stale entry becomes an empty rule for a missing file, which make treats as always updated: the dictionary is regenerated on every build.

That is what the "Check for spurious rebuilds" CI step has been reporting for test/Tetris on every Linux job with CMake 3.x since Oct 24: Tetris loads Gui.pcm, Gui had just gained ASImageUtils and ROOTPadPainter in master, and the PR trees did not have those LinkDefs yet. Dictionaries that are OBJECT libraries only escaped because CMake re-ran in the same build, which wipes their cache; without a re-run they regenerate forever as well.

Remove the cached list right after rootcling has written the fresh depfile, which is what CMake itself does for library targets whenever it regenerates. The next dependency scan then starts from the depfile alone. Only done for Makefile generators with CMake < 4.0, where the problem exists; Ninja and CMake 4 are unaffected.

[1] https://gitlab.kitware.com/cmake/cmake/-/work_items/26399

🤖 Done with the help of AI

Should fix CI failures like in #23840

The Makefile generators of CMake < 4.0 merge the entries of a custom
command's DEPFILE into CMakeFiles/<target>.dir/compiler_depend.internal
instead of replacing them (CMake issue 26399 [1], fixed in 4.0 only). Every
file rootcling ever recorded therefore stays a prerequisite of the
dictionary for the life of the build tree. Once one of them disappears,
e.g. because a CI job restores a master build tree and then checks out a
PR whose base predates a header or LinkDef that master had added, the
stale entry becomes an empty rule for a missing file, which make treats
as always updated: the dictionary is regenerated on every build.

That is what the "Check for spurious rebuilds" CI step has been reporting
for test/Tetris on every Linux job with CMake 3.x since Oct 24: Tetris
loads Gui.pcm, Gui had just gained ASImageUtils and ROOTPadPainter in
master, and the PR trees did not have those LinkDefs yet. Dictionaries
that are OBJECT libraries only escaped because CMake re-ran in the same
build, which wipes their cache; without a re-run they regenerate forever
as well.

Remove the cached list right after rootcling has written the fresh
depfile, which is what CMake itself does for library targets whenever it
regenerates. The next dependency scan then starts from the depfile alone.
Only done for Makefile generators with CMake < 4.0, where the problem
exists; Ninja and CMake 4 are unaffected.

[1] https://gitlab.kitware.com/cmake/cmake/-/work_items/26399

🤖 Done with the help of AI
@guitargeek guitargeek self-assigned this Oct 28, 2026
@guitargeek
guitargeek requested a review from bellenot as a code owner October 28, 2026 10:07
@guitargeek guitargeek added this to the 6.42.00-rc1 milestone Oct 28, 2026

@bellenot bellenot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I trust you...

@github-actions

Copy link
Copy Markdown

Test Results

    24 files      24 suites   3d 22h 55m 6s ⏱️
 3 900 tests  3 900 ✅ 0 💤 0 ❌
83 504 runs  83 504 ✅ 0 💤 0 ❌

Results for commit 79c3077.

@dpiparo
dpiparo merged commit 4fc3f40 into root-project:master Oct 28, 2026
36 checks passed
@guitargeek
guitargeek deleted the dict-depfile-makefiles branch October 28, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants