Skip to content

Commit

Permalink
Auto merge of rust-lang#2212 - RalfJung:cargo-miri, r=RalfJung
Browse files Browse the repository at this point in the history
update and move cargo-miri operational description
  • Loading branch information
bors committed Jun 7, 2022
2 parents 4d72580 + cca3dea commit ba15da4
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions cargo-miri/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,19 @@ fn main() {
// Skip binary name.
args.next().unwrap();

// Dispatch to `cargo-miri` phase. There are four phases:
// - When we are called via `cargo miri`, we run as the frontend and invoke the underlying
// cargo. We set RUSTDOC, RUSTC_WRAPPER and CARGO_TARGET_RUNNER to ourselves.
// - When we are executed due to RUSTDOC, we run rustdoc and set both `--test-builder` and
// `--runtool` to ourselves.
// - When we are executed due to RUSTC_WRAPPER (or as the rustdoc test builder), we build crates
// or store the flags of binary crates for later interpretation.
// - When we are executed due to CARGO_TARGET_RUNNER (or as the rustdoc runtool), we start
// interpretation based on the flags that were stored earlier.
//
// Additionally, we also set ourselves as RUSTC when calling xargo to build the sysroot, which
// has to be treated slightly differently than when we build regular crates.

// Dispatch running as part of sysroot compilation.
if env::var_os("MIRI_CALLED_FROM_XARGO").is_some() {
phase_rustc(args, RustcPhase::Setup);
Expand Down Expand Up @@ -1094,14 +1107,6 @@ fn main() {
return;
}

// Dispatch to `cargo-miri` phase. There are three phases:
// - When we are called via `cargo miri`, we run as the frontend and invoke the underlying
// cargo. We set RUSTC_WRAPPER and CARGO_TARGET_RUNNER to ourselves.
// - When we are executed due to RUSTC_WRAPPER, we build crates or store the flags of
// binary crates for later interpretation.
// - When we are executed due to CARGO_TARGET_RUNNER, we start interpretation based on the
// flags that were stored earlier.
// On top of that, we are also called as RUSTDOC, but that is just a stub currently.
match args.next().as_deref() {
Some("miri") => phase_cargo_miri(args),
Some("rustc") => phase_rustc(args, RustcPhase::Build),
Expand Down

0 comments on commit ba15da4

Please sign in to comment.