@@ -1063,6 +1063,19 @@ fn main() {
1063
1063
// Skip binary name.
1064
1064
args. next ( ) . unwrap ( ) ;
1065
1065
1066
+ // Dispatch to `cargo-miri` phase. There are four phases:
1067
+ // - When we are called via `cargo miri`, we run as the frontend and invoke the underlying
1068
+ // cargo. We set RUSTDOC, RUSTC_WRAPPER and CARGO_TARGET_RUNNER to ourselves.
1069
+ // - When we are executed due to RUSTDOC, we run rustdoc and set both `--test-builder` and
1070
+ // `--runtool` to ourselves.
1071
+ // - When we are executed due to RUSTC_WRAPPER (or as the rustdoc test builder), we build crates
1072
+ // or store the flags of binary crates for later interpretation.
1073
+ // - When we are executed due to CARGO_TARGET_RUNNER (or as the rustdoc runtool), we start
1074
+ // interpretation based on the flags that were stored earlier.
1075
+ //
1076
+ // Additionally, we also set ourselves as RUSTC when calling xargo to build the sysroot, which
1077
+ // has to be treated slightly differently than when we build regular crates.
1078
+
1066
1079
// Dispatch running as part of sysroot compilation.
1067
1080
if env:: var_os ( "MIRI_CALLED_FROM_XARGO" ) . is_some ( ) {
1068
1081
phase_rustc ( args, RustcPhase :: Setup ) ;
@@ -1094,14 +1107,6 @@ fn main() {
1094
1107
return ;
1095
1108
}
1096
1109
1097
- // Dispatch to `cargo-miri` phase. There are three phases:
1098
- // - When we are called via `cargo miri`, we run as the frontend and invoke the underlying
1099
- // cargo. We set RUSTC_WRAPPER and CARGO_TARGET_RUNNER to ourselves.
1100
- // - When we are executed due to RUSTC_WRAPPER, we build crates or store the flags of
1101
- // binary crates for later interpretation.
1102
- // - When we are executed due to CARGO_TARGET_RUNNER, we start interpretation based on the
1103
- // flags that were stored earlier.
1104
- // On top of that, we are also called as RUSTDOC, but that is just a stub currently.
1105
1110
match args. next ( ) . as_deref ( ) {
1106
1111
Some ( "miri" ) => phase_cargo_miri ( args) ,
1107
1112
Some ( "rustc" ) => phase_rustc ( args, RustcPhase :: Build ) ,
0 commit comments