fix(incremental): compile tests and binaries whose link bypasses the cache incrementally #1041
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 591 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.382
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1041"
general
weight: 0.35
jdx
A workspace test binary, binary, example, or proc macro whose native link mbx cannot cache used to recompile from scratch on every edit. mbx turns off Cargo's own incremental mode, and learned incremental state was only given to units the cache could key, or to
staticlib/cdylib/dyliblibraries (#695). So a link bypass also turned off incremental compilation.Reported in #1039: inside a nixpkgs dev shell on macOS,
SDKROOTpoints at the Nixapple-sdk,xcruncannot describe it, and every native link bypasses asunportable-native-link. The reporter's library-test binary took about 9.4 s per edit there, against 2–3 s with the Xcode SDK, where the same unit is cacheable and gets learned incremental state.Such units now keep private incremental state when the cache declined them only because of the link. That covers these bypass reasons:
unportable-native-link: an unidentified linker or SDK, or an option such as-C rpathor-C split-debuginfo=packedunmodeled-link-argumentnative-library,missing-native-library, andcustom-target-native-libraryrustc's front end and code generation for these units are the same as for a cacheable unit, and the link always runs again, so incremental state is as safe here as it is in plain Cargo. The result still stays out of the shared store, and
mbx explainstill reports the bypass. As with bypassed libraries, the state is keyed on the full rustc argument list, it covers only workspace sources, and build scripts are left out.learned_incremental = false(MBX_LEARNED_INCREMENTAL=0),MBX_VERIFY, an explicit-C incremental, and an optimized build with local ThinLTO each turn it off.Example:
This does not make links against the Nix Apple SDK cacheable. That would need mbx to identify the SDK without
xcrunand is not part of this PR.Validation. A new end-to-end test builds a binary with
-C rpath, edits it, and checks that the binary keeps its own incremental state and reuses it. It fails without the change and passes with it. A unit test covers which bypassed units get state.mise run cipasses. I did not test on macOS in a Nix dev shell or re-measure the reporter's build.Refs #1039
AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: unavailable.
🤖 Generated with Claude Code
<!-- CURSOR_SUMMARY -->
---
<!-- /CURSOR_SUMMARY -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
New Features
Incremental compilation state is now retained for eligible binaries, tests, examples, and procedural macros when only their linking bypasses caching. Linking for these units remains uncached.
Documentation
Clarified which units can use incremental state when linking bypasses caching, and noted that build scripts are excluded and the behavior can be disabled with
learned_incremental.<!-- end of auto-generated comment: release notes by coderabbit.ai -->