From cca3dea37974a8f624a41c603e0ec5ca6a450299 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 7 Jun 2022 13:59:47 -0400 Subject: [PATCH] update and move cargo-miri operational description --- cargo-miri/bin.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cargo-miri/bin.rs b/cargo-miri/bin.rs index ba885d307a85f..8b11016ca1be0 100644 --- a/cargo-miri/bin.rs +++ b/cargo-miri/bin.rs @@ -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); @@ -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),