Skip to main content

Module validate

Module validate 

Source
Expand description

Pre-flight environment check for the thin-rebuild pipeline.

Catches the “fat build was for one toolchain, the dev loop is now using another” class of breakage before subsecond::apply_patch runs and segfaults the device. The check is deliberately small — we only assert what’s necessary to keep the same captured rustc invocation viable:

  1. The current rustc still supports the target triple the fat build was for. If a rustup toolchain change between the fat build and the first edit dropped the Android target, we want a clear error here, not a cryptic linker failure later.

Things we deliberately do NOT validate:

  • Exact rustc version match. Patch dylibs survive across patch-level rustc bumps in practice (subsecond is pretty tolerant); demanding strict equality would break workflows where rustup update is a frequent occurrence. Major version regressions WILL be surfaced by the thin rebuild itself (rustc returns non-zero), so we let that path do the talking.

  • Sysroot stability. Same reasoning — rustc verifies its own sysroot at compile time. We don’t add a redundant probe.

Functions§

ensure_target_supported
Spawn rustc --print=target-list and verify triple shows up. Synchronous on purpose — runs once per dev-server boot, not per patch.
extract_target_triple
Pull the value passed to --target (or --target=...) out of a rustc argv. Pure helper — same shape as extract_crate_name in the shim.
validate_environment
Run the pre-flight checks. Returns Ok(()) if it’s safe to call thin_rebuild; otherwise Err with a message a human can act on.