Skip to content

feat: fast-path fingerprint coherence, diagnostic warning, cxx_scan restat#35

Merged
Sunrisepeak merged 2 commits into
mainfrom
feat/fastpath-restat-diagnostic
May 15, 2026
Merged

feat: fast-path fingerprint coherence, diagnostic warning, cxx_scan restat#35
Sunrisepeak merged 2 commits into
mainfrom
feat/fastpath-restat-diagnostic

Conversation

@Sunrisepeak
Copy link
Copy Markdown
Member

Summary

Three incremental build experience improvements:

  • P1 — fast-path fingerprint coherence: .build_cache now stores fingerprint hex (4th line). try_fast_build validates consistency; if fingerprint doesn't match outputDir, cache is invalidated immediately instead of silently falling through to a stale directory
  • P1.5 — diagnostic warning: run_build_plan prints warning: fingerprint changed (old → new), full rebuild when outputDir differs from cached, so users see WHY a full rebuild happened
  • P2 — cxx_scan restat: scan rule writes .ddi to $out.tmp first, compares with cmp -s, keeps old file if identical. With restat = 1, downstream edges are not dirtied when source mtime changed but module deps didn't

Test plan

  • mcpp build compiles successfully
  • mcpp test — 12/12 pass
  • .build_cache now has 4 lines (fingerprint hex on line 4)
  • Old 3-line .build_cache files handled gracefully (empty fingerprint = skip check)
  • CI passes

P1: .build_cache now stores fingerprint hex (4th line). try_fast_build
validates that the cached fingerprint matches the outputDir basename;
if inconsistent (e.g. switched mcpp installation), the cache is
invalidated immediately instead of silently falling through to a
different fingerprint directory.

P1.5: run_build_plan prints a warning when the outputDir fingerprint
differs from the previous .build_cache entry, so users immediately
see why a full rebuild is happening instead of getting a silent 26s.

P2: cxx_scan rule now writes .ddi to $out.tmp first, then compares
with existing $out via cmp -s. If content is identical, old $out is
kept (preserving mtime). Combined with restat = 1, this prevents
downstream dyndep/compile edges from being marked dirty when a source
file's mtime changed but its module dependencies didn't.
The $out.tmp + cmp -s approach for content-stable .ddi writes caused
linker failures in the CI self-host smoke step. GCC's -fdeps-file=
interacts with ninja's depfile tracking in ways that make the temp-file
approach fragile. Revert to direct -fdeps-file=$out for now.

P1 (fingerprint coherence) and P1.5 (diagnostic warning) are retained.
P2 needs a different approach — possibly ninja's built-in restat alone
without temp-file wrappers.
@Sunrisepeak Sunrisepeak merged commit 2e7fe50 into main May 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant