fix: Scope source fingerprints to Git trees and additional inputs #9907
<!-- therock-pr-bot-policy-check -->
✅ All Checks Passed — Ready for Review
| Check | Status | Details |
|---|:---:|---|
| 📝 PR Description | ✅ Pass | — |
| ⛔ Forbidden Files | ✅ Pass | — |
| 🧪 Unit Test | ✅ Pass | — |
| 🔎 pre-commit | ✅ Pass | — |
| 🚫 Draft PR | 🔜 To Be Enabled | — |
| 🚩 Feature Flag | 🔜 To Be Enabled | — |
| 📊 Code Coverage | 🔜 To Be Enabled | — |
| 🤖 therock-pr-bot | ✅ Pass | — |
🎉 All checks passed! This PR is ready for review.
📖 Need help? See the Policy FAQ for details on every check and how to fix failures.
<!-- therock-pr-bot-fix-policies -->
🎉 All checks passed! This PR is ready for review.
Tree-scoped identity a good call, and the source-identity tests are solid.
Locally tested and reverified the change
Missing/invalid declared input silently disables caching
I think this goes with the discussed design plan and RFC, the test cases pass and the new fprint generation also works I think in my opinion it is ready
Approved these changes.
This should be fine but it might be better to make it a configure error
I understand the concern. I prefer to keep configuration running because an invalid source identity can also result from local tracked edits. Those should prevent cache reuse without blocking development builds.
I removed the THEROCK_VERBOSE guard so configuration always reports the affected input and explains that fingerprint-based cache reuse is unavailable. Would that address your concern?
We'll need to at least follow up on other subprojects that will also need this. Just adding to amd-llvm will not be sufficient and stopping there on this PR weakens the fprint calculations for other subprojects.
Can you check across the codebase for how many subprojects will need ADDITIONAL_SOURCE_INPUTS?
I want to know
1. How many changes total will be needed
2. If any changes will be especially large or complicated -- so if this mechanism is actually sufficient for all uses or if we'll need a different design
Depending on the answers to those questions we may want to make all the changes in this PR itself and not just start with amd-llvm.
Please split this into a separate PR from the ADDITIONAL_SOURCE_INPUTS and git rev-parse changes. Both need careful review on their own. One PR for git trees, one for CMake args.
Here, this is looking at literal arguments and _not_ evaluating expressions.
Agent finding with more context:
### BLOCKING: Hashing generator-expression text can reuse a fingerprint for different effective arguments
> Location: cmake/therock_subproject.cmake:970–981.
>string(SHA256 ...)runs during configuration and hashes the unevaluated argument.add_custom_command()evaluates generator expressions when generating the build command. Values consulted by an unchanged expression can change without changing any argument text or fingerprinted file.
> Reproduced against the unmodified PR implementation, using its existing argument-test fixture with this constant argument:
>> CMAKE_ARGS "-DVALUE=$<TARGET_PROPERTY:args_source,TEST_ARG_VALUE>" >
> The fixture assigns that property from an outerTEST_ARG_VALUEcache entry. Changing the entry fromfirsttosecond, reconfiguring, and invokingargs_source+configurechanges the generated output fromfirst\ntosecond\n. Both the project and consumer retain exactly the same fingerprints:
>> args_source 98318c3629e491734a7eea8303c81946bd298020ef56352ebff7c40508659927 > args_consumer 32ccd5d542bb795b95eba275a8ebca94c67b5782be03a32c64f01a4ff30edf5c >
> No source or declaration text changed between configurations, and the inner configure really ran with the changed value. The control fingerprint stayed unchanged as expected. Reproduction and results:probe_genex.py,genex-result.jsonin the scratch directory below.
> The existing generator-expression test changes$<BOOL:1>to$<BOOL:0>, so the literal text changes too. That establishes text sensitivity and correct command evaluation, but does not establish effective-argument coverage.
> Required action: Represent effective argument values in the identity, constrain the argument interface so it can be evaluated reliably before fingerprint production, or conservatively invalidate fingerprints for expressions whose effective values cannot be represented. Do not accept their literal text as sufficient identity. Add the constant-expression/changing-value regression. Existing configure-expanded values inside expressions are a different, narrower case.
Let's split this into two PRs and resolve bugs on each independently. Too risky to land both at the same time.
Split this PR as below:
https://github.com/ROCm/TheRock/pull/10268
https://github.com/ROCm/TheRock/pull/10338
Closing
ammallya
erman-gurses
Description:
Implements the simpler source-identity approach discussed in #9732. Repository-wide commit changes currently invalidate fingerprints even when a subproject’s sources are unchanged. This change uses the selected directory’s Git tree and explicitly records additional source directories.
Changes:
git rev-parse HEAD:./for Git source identity and scope the tracked-file dirty check to the same directory. Preserve.smrevpriority.ADDITIONAL_SOURCE_INPUTS, using the existing source-identity helper for each directory. Missing or invalid inputs invalidate the subproject fingerprint.-Add baseline tests for existing subproject behavior, covering configure/build/stage ordering, dependency discovery, unchanged rebuilds, duplicate declarations and package providers, distribution contents, custom install destinations, and excluded targets. Share fixture setup through
therock_fingerprint_test_utils.py.Testing:
Fingerprint tests cover source identity, scoped dirty-source invalidation,
source restoration, CMake arguments and overrides, additional source inputs,
dependency propagation, and repeat stability.
Baseline subproject tests cover existing configuration, build, and staging
behavior independently of fingerprint assertions.
Run from the repository root:
Validation findings and follow-ups
Addressed by this PR
.smrevpriority. Unrelated commits and tracked edits outside that directory no longer invalidate its identity.ADDITIONAL_SOURCE_INPUTSin fingerprints, including LLVM’s SPIR-V translator and non-Windows HSA headers.Resolved separately
OUTPUT_STRIP_TRAILING_WHITESPACEprevents the timestamp from changing when CMake saves and reloads its cache. This fixes initial-versus-repeated configuration differences, but fresh builds can still produce different timestamps.MLIR_INSTALL_AGGREGATE_OBJECTStoOFF CACHE BOOL ... FORCEkeeps its effective and cached values consistentlyOFF. Previously, the effective value could change from1on initial configuration toOFFon repeated configuration, changing generated MLIR exports.Remaining work
Accepted behavior or outside the current CI scope
Note:
Fingerprint calculations occur during configuration; input changes require reconfiguration before building.
Local tests related files:
Test Results
README
Test Script