Expand description
whisker-rustc-shim binary’s logic.
Cargo invokes the binary as:
whisker-rustc-shim <rustc-path> <rustc-args...>when RUSTC_WORKSPACE_WRAPPER=whisker-rustc-shim is set. We do two
things, in order:
- Dump the rustc invocation (full argv + crate name + timestamp)
to JSON at
$WHISKER_RUSTC_CACHE_DIR/<crate>-<microseconds>.json. The dev server reads these later to drive thin rebuilds (I4g-5). - Spawn the real rustc with the original args and exit with the same status code — to cargo, the wrapper is invisible.
If WHISKER_RUSTC_CACHE_DIR is unset, step 1 is skipped. That way a
stray RUSTC_WORKSPACE_WRAPPER=whisker-rustc-shim (left over from a
crashed whisker run) doesn’t break ordinary cargo build.
Structs§
- Captured
Rustc Invocation - One captured rustc invocation. The dev-server-side
wrappermodule deserialises one of these per crate to reconstruct the thin-rebuild command line.
Functions§
- capture
- Build a
CapturedRustcInvocationfrom a rustc argv slice. Pure aside from reading the system clock for the timestamp. - extract_
crate_ name - Find the value passed to
--crate-namein a rustc argv slice. rustc’s CLI guarantees--crate-name <name>(separate args) when cargo invokes it; the equals form (--crate-name=foo) isn’t used in practice but we handle it defensively. - invocation_
filename - Filesystem-safe filename for a captured invocation. Same crate may be compiled multiple times in one fat build (e.g. lib + test + bin targets, build-script vs. main); the timestamp avoids collisions.
- run
- Entry point called from
src/bin/whisker_rustc_shim.rs. - save_
invocation - Persist
invocationundercache_dir/<filename>.json. Createscache_dirif missing.