fix(cmake): Avoid parent git dirty state invalidating downloaded source fingerprints #10185
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.50) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 572 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.380
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #10185"
general
weight: 0.35
ammallya
Issue ID: #9525
Suggested by @ScottTodd while testing the artifact cache (https://github.com/ROCm/TheRock/pull/10026#discussion_r4636672203) on Windows.
Stop unrelated edits to tracked files in TheRock from invalidating the fingerprints of the third-party libraries that TheRock downloads at configure time (such as zlib and zstd), and of everything that depends on them, including
amd-llvm, which the artifact cache relies on. The same fix applies toamd-mesa, whose fingerprint now comes from its own source directory instead of its wrapper directory.Sources inside the TheRock repository itself are not changed here; scoping their dirty check is #9907.
Problem
With a clean tree, a configure writes a
.fprintfile for each artifact. After modifying any tracked file (for example the artifact cache index), a re-configure deleted most of them, includingamd-llvm_lib_generic.fprint. The artifact cache'slookupthen had nothing to compare.The libraries TheRock downloads at configure time are not part of the TheRock repository, but they sit inside its folder. The repo-wide dirty check is applied to them, so any tracked edit makes them look dirty, their fingerprints become invalid, and so do the fingerprints of everything that depends on them. See Root cause below.
Root cause
_therock_subproject_fprint_source_dir(cmake/therock_subproject.cmake) decides whether a source directory is a git source withgit rev-parse --git-dir. That succeeds in any directory under any repository.1. Downloaded sources such as zlib and zstd live in
build/third-party/.... Git ignores that directory, but it sits inside TheRock's work tree, sorev-parsefinds TheRock's own.gitand they are treated as git sources.2. The dirty check,
git diff --quiet --ignore-submodules HEAD, covers the whole repository it finds. Any modified tracked file anywhere in TheRock makes those sources look dirty, and their fingerprints are dropped.3. A subproject whose dependency has no fingerprint cannot compute one either. CMake then deletes the
.fprintfiles of the artifacts that depend on it.amd-llvmdepends on bundled sysdeps such as zlib, zstd and liblzma, which is how it lost its fingerprint although LLVM was unchanged.Changes
git rev-parse --git-dirbecomesgit ls-files --error-unmatch -- ., which succeeds only if git tracks files in the directory. Downloaded sources are not tracked, so they skip the dirty check and use the stable fingerprint from their.smrevfile, which is written when they are downloaded. Tracked directories and submodules behave as before.amd-mesa(Windows and Linux) now setsFPRINT_SOURCE_DIRto its source directory (themesa-forksubmodule) andFPRINT_FILE_GLOBSto its own wrapper files. Its wrapper directory is tracked inside TheRock, so thels-fileschange does not apply to it. Before, its fingerprint followed TheRock's commit and TheRock's dirty state.cmake/tests/therock_subproject_fprint_git_test.py, a regression test that needs no submodules, compiler, or bundled sysdeps.Testing
Windows 11,
-DTHEROCK_AMDGPU_FAMILIES=gfx110X-all, freshbuild/each time. "Dirty" means one tracked file (the artifact cache index) was modified before configuring.| Run | Fix |
.fprintfiles |amd-llvm_lib_generic.fprint|| --- | --- | --- | --- |
| Clean tree | none | 78 | present |
| Dirty tree | none | 7 | deleted |
| Dirty tree |
ls-fileschange only | 33 | present, identical hash || Dirty tree | this PR | 35 | present, identical hash |
The
amd-llvmfingerprint is identical on the clean tree and on the dirty tree with the fix.artifact_cache.py lookupcompares all fiveamd-llvmcomponents again instead of finding no fingerprints.Linux workstation, same procedure (a blank line appended to
TheRock/README.mdmade the tree dirty):| Run | Fix |
.fprintfiles |amd-llvm_lib_generic.fprint|| --- | --- | --- | --- |
| Clean tree | none | 206 | present |
| Dirty tree | none | 8 | deleted |
| Clean tree | this PR | 206 | present, same hash |
| Dirty tree | this PR | 77 | present, same hash |
New unit tests (
cmake/tests/therock_subproject_fprint_git_test.py):Without the fix the second test fails (1 failed, 2 passed). With it, all three pass.