Skip to main content

Module wrapper

Module wrapper 

Source
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:

  1. Spawns the fat build — a normal cargo build with RUSTC_WORKSPACE_WRAPPER=whisker-rustc-shim set, so the cache fills up.
  2. 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.
  3. (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§

CapturedLinkerInvocation
Mirrors whisker_cli::linker_shim::CapturedLinkerInvocation exactly. Same duplication rationale as CapturedRustcInvocation.
CapturedRustcInvocation
Mirrors whisker_cli::rustc_shim::CapturedRustcInvocation exactly. 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.
LinkerCaptureConfig
Optional linker-shim wiring for run_fat_build. Provide all three when you want the linker invocation captured (Tier 1 needs it); leave this None for 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_dir for 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 as keep_newest, but the key is the output filename rather than a crate name.
load_captured_args
Walk cache_dir, deserialise every *.json produced by whisker-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-shim cache dir and collapse duplicates per output filename, keeping the most-recent timestamp. Same shape as load_captured_args but 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 cargo build for the given target with RUSTC_WORKSPACE_WRAPPER pointed at shim_path and WHISKER_RUSTC_CACHE_DIR pointed at cache_dir. Inherits stdout/stderr so cargo’s progress is visible. After the build completes successfully, load_captured_args can read the cache.