Skip to main content

Module rustc_shim

Module rustc_shim 

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

  1. 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).
  2. 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§

CapturedRustcInvocation
One captured rustc invocation. The dev-server-side wrapper module deserialises one of these per crate to reconstruct the thin-rebuild command line.

Functions§

capture
Build a CapturedRustcInvocation from a rustc argv slice. Pure aside from reading the system clock for the timestamp.
extract_crate_name
Find the value passed to --crate-name in 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 invocation under cache_dir/<filename>.json. Creates cache_dir if missing.