fix(build): stop no-change rebuilds from recompiling every TU#956
Conversation
Two staleness-check defects made every rebuild a full recompile (#951, ~108s per no-op rebuild of NightDriverStrip): 1. Compiles run with cwd = the project workspace (zccache compile-cwd normalization), so gcc -MMD depfiles list workspace-relative prerequisites — but dependency_is_newer_than_object stat'ed them against the daemon's process cwd, failed, and .unwrap_or(true) marked every TU stale. Resolve relative prerequisites against zccache::compile_cwd_from_output(object). 2. compile_c/compile_cpp apply build_unflags before hashing the written .cmdhash, but both rebuild_signature impls (trait default + Esp32Compiler) hashed the raw flags, so any project with build_unflags (NightDriverStrip sets -std=gnu++11) mismatched on every file. Apply the same filter on the check side. Validated in the #942 Docker harness: steady-state no-change rebuild drops 108s -> 2.1s (compile-sketch 92s -> 0.48s stat walk, compile-core-variant 10.7s -> 0.2s). The first rebuild after a cold build still recompiles once (signature drift between mid-cold and steady-state flag assembly) — tracked separately. Closes #951 Part of #942 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR fixes rebuild-signature computation to apply build_unflags filtering to extra_flags in both Compiler and Esp32Compiler, and updates GCC depfile prerequisite staleness checks to resolve relative dependency paths against the compile working directory instead of the process cwd, with added regression tests. ChangesRebuild signature and depfile staleness fixes
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
The #942 baseline showed a no-change rebuild of NightDriverStrip demo taking ~108 s —
compile-sketch(92 s) andcompile-core-variant(10.7 s) re-ran in full every build. Two staleness-check defects:/in path args so cc1 spec-file pass works on Windows #890), so gcc-MMDdepfiles list workspace-relative prerequisites.dependency_is_newer_than_objectstat'ed them against the long-lived daemon's process cwd, every stat failed, and.unwrap_or(true)marked every TU stale. Fixed by resolving relative prerequisites againstzccache::compile_cwd_from_output(object)— the same workspace the compile actually ran from. Absolute prerequisites are untouched.build_unflags.compile_c/compile_cppapplybuild_unflagsbefore hashing the written.cmdhash, but bothrebuild_signatureimpls (trait default +Esp32Compiler) hashed the raw flags. Any project withbuild_unflags(NightDriverStrip's[env]sets-std=gnu++11) mismatched on every file. The check side now applies the identical filter (apply_compile_unflagspromoted topub(crate)).Validation
test_needs_rebuild_resolves_relative_depfile_deps_against_workspace(relative deps must not force rebuilds when current, and must still trigger one when genuinely newer) andrebuild_signature_matches_write_path_with_unflags(check-side signature must equal the write-path signature underbuild_unflags). Fullfbuild-build --lib: 717 passed.compile-sketch92 s → 0.48 s stat walk,compile-core-variant10.7 s → 0.2 s,link-convert-size4.4 s → 1 ms).Known residual (tracked separately, not a regression): the first rebuild after a cold build still recompiles once — the
.cmdhashwritten mid-cold-build reflects a different flag/include assembly than steady state. Every rebuild after that is 2.1 s.Closes #951
Part of #942
🤖 Generated with Claude Code
Summary by CodeRabbit