Expand description
Fat-build runner + captured-args loader.
The other half of the rustc/linker hijack started in I4g-4a.
whisker-rustc-shim writes a JSON file per rustc invocation into a
cache dir; this module:
- Spawns the fat build — a normal cargo build with
RUSTC_WORKSPACE_WRAPPER=whisker-rustc-shimset, so the cache fills up. - Loads those JSON files back into a
HashMap<String, CapturedRustcInvocation>keyed by crate name, picking the most recent timestamp when a crate was rebuilt mid-session. - (Future, I4g-5) hands the captured args to a thin-rebuild driver that only recompiles the changed crate and re-links.
CapturedRustcInvocation is currently defined here, not in
whisker-cli, so that the shim binary doesn’t need to pull in the
whole dev-server dep tree (tokio / axum / notify / object). The
shim has its own copy of the struct shape; serde keeps the wire
format compatible. A future cleanup will extract a tiny
whisker-hotpatch-types crate and dedupe both sides — see TODO.
Structs§
- Captured
Linker Invocation - Mirrors
whisker_cli::linker_shim::CapturedLinkerInvocationexactly. Same duplication rationale asCapturedRustcInvocation. - Captured
Rustc Invocation - Mirrors
whisker_cli::rustc_shim::CapturedRustcInvocationexactly. Kept duplicated (rather than imported) so the shim binary stays dep-light. JSON wire format is what binds them — both sides go through serde, so a field rename in one without the other will trip the deserialize step at run time and emit a clear error. - Linker
Capture Config - Optional linker-shim wiring for
run_fat_build. Provide all three when you want the linker invocation captured (Tier 1 needs it); leave thisNonefor plain Tier 2 / Tier 0 fat builds.
Functions§
- default_
cache_ dir - Convenience: best-effort default cache dir under the workspace’s
target/.whisker/rustc-args/. Created on demand. - default_
linker_ cache_ dir - Counterpart of
default_cache_dirfor the linker side:target/.whisker/linker-args/. Created on demand. - keep_
newest - Pure helper for the load loop’s “keep most-recent per crate” decision. Pulled out so unit tests don’t have to write JSON to disk to exercise the merge.
- keep_
newest_ linker - Pure helper for
load_captured_linker_args— same “keep most-recent per key” pattern askeep_newest, but the key is the output filename rather than a crate name. - load_
captured_ args - Walk
cache_dir, deserialise every*.jsonproduced bywhisker-rustc-shim, and collapse duplicates per crate by keeping the most-recent timestamp. Empty / unparseable files are skipped with a warning rather than aborting the whole load — a partial fat build shouldn’t take the dev loop down. - load_
captured_ linker_ args - Walk a
whisker-linker-shimcache dir and collapse duplicates per output filename, keeping the most-recent timestamp. Same shape asload_captured_argsbut for the linker side. Empty / unparseable files get a warning, not an abort. - resolve_
host_ linker - Resolve the system linker driver we want to forward to from the shim. Same logic the integration test uses, lifted into one place so production and tests agree:
- run_
fat_ build - Spawn a
cargobuild for the given target withRUSTC_WORKSPACE_WRAPPERpointed atshim_pathandWHISKER_RUSTC_CACHE_DIRpointed atcache_dir. Inherits stdout/stderr so cargo’s progress is visible. After the build completes successfully,load_captured_argscan read the cache.