← Back to Pull requests

fix(cmake): Avoid parent git dirty state invalidating downloaded source fingerprints #10185

Closed
unknown closed this pull request without merging on Nov 23, 2026 19:20 UTC
View on GitHub
unknown unknown commented on Nov 20, 2026 23:27 UTC
Author

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 to amd-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 .fprint file for each artifact. After modifying any tracked file (for example the artifact cache index), a re-configure deleted most of them, including amd-llvm_lib_generic.fprint. The artifact cache's lookup then 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 with git 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, so rev-parse finds TheRock's own .git and 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 .fprint files of the artifacts that depend on it. amd-llvm depends 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-dir becomes git 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 .smrev file, which is written when they are downloaded. Tracked directories and submodules behave as before.

  • amd-mesa (Windows and Linux) now sets FPRINT_SOURCE_DIR to its source directory (the mesa-fork submodule) and FPRINT_FILE_GLOBS to its own wrapper files. Its wrapper directory is tracked inside TheRock, so the ls-files change does not apply to it. Before, its fingerprint followed TheRock's commit and TheRock's dirty state.

  • Adds 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, fresh build/ each time. "Dirty" means one tracked file (the artifact cache index) was modified before configuring.

    | Run | Fix | .fprint files | amd-llvm_lib_generic.fprint |
    | --- | --- | --- | --- |
    | Clean tree | none | 78 | present |
    | Dirty tree | none | 7 | deleted |
    | Dirty tree | ls-files change only | 33 | present, identical hash |
    | Dirty tree | this PR | 35 | present, identical hash |

    The amd-llvm fingerprint is identical on the clean tree and on the dirty tree with the fix. artifact_cache.py lookup compares all five amd-llvm components again instead of finding no fingerprints.

    Linux workstation, same procedure (a blank line appended to TheRock/README.md made the tree dirty):

    | Run | Fix | .fprint files | 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):

  • a clean tree gives a valid fingerprint for a downloaded and a tracked source

  • editing an unrelated tracked file keeps the downloaded source's fingerprint

  • editing a file inside a tracked source still invalidates its fingerprint
  • Without the fix the second test fails (1 failed, 2 passed). With it, all three pass.

    Diff: 572 lines (+429 / -143) across 7 files Reviewer: ammallya Review duration: 4073m
    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
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.8% (MEDIUM) · Higher = larger blast radius
    49.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.5% · Safe to merge
    21.5%
    Repository