100%

build-caching

Goal

Attack the dominant test-all.sh wall-clock cost: compilation. The compiler is rebuilt debug AND release every run with NO compilation cache and the default (slow) linker. Add sccache + a fast linker (mold/lld) without changing what artifacts are produced.

Implementation Sketch

Wire BOTH the build cache and the fast linker into compiler_repo/test-all.sh’s Phase 1 pre-build region (the section’s mission target — “dominant test-all.sh wall-clock cost”), NOT the global compiler_repo/.cargo/config.toml. A .cargo/config.toml [target].rustflags block changes how EVERY cargo invocation links (and .cargo/config.toml carries codegen-affecting potential, so the completion gate scopes any touch of it as compiler-rigor); scoping both wirings to test-all.sh keeps the change contained to this runner’s builds and on the tooling tier. Both are runtime-guarded so absence degrades cleanly: command -v sccacheexport RUSTC_WRAPPER=sccache plus CARGO_INCREMENTAL=0 (sccache cannot cache incrementally-compiled crates — without it the wrapper caches nothing); command -v mold → append -C link-arg=-fuse-ld=mold to RUSTFLAGS (-fuse-ld=mold ERRORS at link when mold is absent, so the flag is added ONLY when mold is detected — absent ⇒ default linker). Then MEASURE the effect — a cold-cache build (sccache --zero-stats then full cargo build, a cargo clean -p oric between passes so rustc re-runs and sccache can serve from cache) followed by a warm-cache rebuild, asserting sccache reports a non-zero cache-hit count on the warm pass and recording the warm-vs-cold wall-clock delta. This measurement IS the section’s mission contribution; a guard-only probe that emits ok whether the cache is active, broken, or absent does NOT discharge it.

Spec References

compiler_repo/test-all.sh (Phase 1 pre-build — the SINGLE home for both the sccache RUSTC_WRAPPER+CARGO_INCREMENTAL=0 guard and the mold -fuse-ld RUSTFLAGS guard; runtime-detected, degrade-clean); CLAUDE.md build commands; .claude/rules/cargo.md (consulted — .cargo/config.toml is deliberately NOT edited: a global [target].rustflags block changes every cargo build’s link + scopes the section to compiler-rigor, so the wiring stays contained to test-all.sh on the tooling tier).

Work Items

  • Wire a fast linker (mold) into compiler_repo/test-all.sh’s Phase 1 pre-build guard — NOT .cargo/config.toml (a global [target].rustflags block changes every cargo build’s link + scopes the section to compiler-rigor; test-all.sh keeps it contained to this runner’s builds on the tooling tier). Guard on command -v mold: detected → export RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }-C link-arg=-fuse-ld=mold"; absent → leave RUSTFLAGS untouched (default linker). -C link-arg=-fuse-ld=mold ERRORS at link (cc: error: cannot find ld) when mold is absent, so the flag is added ONLY when mold is detected — this is the detect-before-use discipline (the shell analogue of Ori’s own LinkerDetection in compiler_repo/compiler/ori_llvm/src/aot/linker/detect.rs, which probes cc/lld/clang via check_program before committing; the section’s command -v mold is its own probe, not a reuse of LinkerDetection).
  • Wire sccache as RUSTC_WRAPPER in compiler_repo/test-all.sh Phase 1 pre-build, guarded on command -v sccache so a missing binary never fails the build. When sccache is present set RUSTC_WRAPPER=sccache AND CARGO_INCREMENTAL=0 (sccache cannot cache incrementally-compiled crates — debug builds default to incremental, so without this the wrapper records compile requests executed = 0 and caches nothing); absent → both unset, build proceeds unwrapped.

Acceptance

This is a tooling-tier section (per mission.md: “Per-section rigor is the tooling tier (SRP/SSOT + runtime pytest), not the compiler matrix/dual-exec tier”). The compiler L1-L11 layer matrix is N/A — config-file + harness-wiring work emits no compiler artifacts and runs no Ori program. The one binding layer is L12 (production entry point per .claude/rules/layer-coverage.md §1.3): the live compiler_repo/test-all.sh warm-vs-cold build, exercised on the real harness, not a seam-injected stub.

The section’s success criterion (sc-174e2ec3 in plan.json) MUST measure a real cache effect, not merely that sccache is installed. The current guard-only probe (command -v sccache && sccache --show-stats && echo ok || echo ok) emits ok on both branches and so verifies nothing — it passes whether the cache is active, broken, or absent. Strengthen it to a cache-hit measurement that fails when the cache is present-but-not-working:

  • Cache-active path: sccache --zero-stats, run a full cargo build of oric, run a second identical build, then assert sccache --show-stats reports a non-zero Cache hits count on the warm pass.
  • Cache-absent path: command -v sccache fails → the BUILD degrades cleanly (proceeds unwrapped, never fails — the build guard in w-3a531116). This is distinct from the CRITERION: on a sccache-absent host the criterion probe emits degraded-sccache-absent (NOT ok), recording that the speedup was NOT delivered on this host. Build-graceful-degrade does NOT mean criterion-satisfied — the two are separate. Completion on a sccache-absent host therefore requires an explicit recorded N/A justification (“speedup not delivered — sccache absent on host”), distinguishing a genuine cache-hit delivery from a tool-absent skip. This is the anti-silent-pass guarantee: an absent tool is an explicit recorded non-delivery, never a quiet ok.
  • Record the warm-vs-cold wall-clock delta from the live test-all.sh run as the L12 production-entry-point evidence.

depends_on is [] — this test-all.sh harness-wiring work has no predecessor section; it is a standalone, independently-workable slice of the umbrella mission.

HISTORY

  • 2026-06-14 — linker + cache home moved to test-all.sh (not .cargo/config.toml): implementation grounded against host reality (mold present, sccache installable) and the completion-scope classifier. A .cargo/config.toml [target].rustflags block (a) changes how EVERY cargo build links and (b) makes the verify-and-complete-v7 scope classifier treat the section as compiler-rigor scope (a .cargo/config.toml touch can carry codegen-affecting flags). Both sccache and mold are instead wired into test-all.sh’s Phase 1 guard — the section’s mission target (“test-all.sh wall-clock”), the tooling-tier home, runtime-detected + degrade-clean. This supersedes the earlier review’s .cargo/config.toml preference; the TPR-cited LinkerDetection precedent still informs the detect-before-use discipline. The CARGO_INCREMENTAL=0 requirement (sccache cannot cache incremental crates) was surfaced by the sc-174e2ec3 cache-hit probe failing with compile requests executed = 0.