@@ -6,7 +6,7 @@ use std::ops::Not;
66use anyhow:: { anyhow, bail, Context , Result } ;
77use path_macro:: path;
88use walkdir:: WalkDir ;
9- use xshell:: cmd;
9+ use xshell:: { cmd, Shell } ;
1010
1111use crate :: util:: * ;
1212use crate :: Command ;
@@ -16,17 +16,25 @@ const JOSH_FILTER: &str =
1616 ":rev(75dd959a3a40eb5b4574f8d2e23aa6efbeb33573:prefix=src/tools/miri):/src/tools/miri" ;
1717
1818impl MiriEnv {
19- fn build_miri_sysroot ( & mut self ) -> Result < ( ) > {
19+ fn build_miri_sysroot ( & mut self , quiet : bool ) -> Result < ( ) > {
2020 if self . sh . var ( "MIRI_SYSROOT" ) . is_ok ( ) {
2121 // Sysroot already set, use that.
2222 return Ok ( ( ) ) ;
2323 }
2424 let manifest_path = path ! ( self . miri_dir / "cargo-miri" / "Cargo.toml" ) ;
2525 let Self { toolchain, cargo_extra_flags, .. } = & self ;
26+
27+ // Make sure everything is built. Also Miri itself.
28+ self . build ( path ! ( self . miri_dir / "Cargo.toml" ) , & [ ] , quiet) ?;
29+ self . build ( & manifest_path, & [ ] , quiet) ?;
30+
2631 let target = & match self . sh . var ( "MIRI_TEST_TARGET" ) {
2732 Ok ( target) => vec ! [ "--target" . into( ) , target] ,
2833 Err ( _) => vec ! [ ] ,
2934 } ;
35+ if !quiet {
36+ eprintln ! ( "$ (buildig Miri sysroot)" ) ;
37+ }
3038 let output = cmd ! ( self . sh,
3139 "cargo +{toolchain} --quiet run {cargo_extra_flags...} --manifest-path {manifest_path} --
3240 miri setup --print-sysroot {target...}"
@@ -91,7 +99,7 @@ impl Command {
9199 // Make sure rustup-toolchain-install-master is installed.
92100 which:: which ( "rustup-toolchain-install-master" )
93101 . context ( "Please install rustup-toolchain-install-master by running 'cargo install rustup-toolchain-install-master'" ) ?;
94- let sh = shell ( ) ?;
102+ let sh = Shell :: new ( ) ?;
95103 sh. change_dir ( miri_dir ( ) ?) ;
96104 let new_commit = Some ( sh. read_file ( "rust-version" ) ?. trim ( ) . to_owned ( ) ) ;
97105 let current_commit = {
@@ -130,7 +138,7 @@ impl Command {
130138 }
131139
132140 fn rustc_pull ( commit : Option < String > ) -> Result < ( ) > {
133- let sh = shell ( ) ?;
141+ let sh = Shell :: new ( ) ?;
134142 sh. change_dir ( miri_dir ( ) ?) ;
135143 let commit = commit. map ( Result :: Ok ) . unwrap_or_else ( || {
136144 let rust_repo_head =
@@ -177,7 +185,7 @@ impl Command {
177185 }
178186
179187 fn rustc_push ( github_user : String , branch : String ) -> Result < ( ) > {
180- let sh = shell ( ) ?;
188+ let sh = Shell :: new ( ) ?;
181189 sh. change_dir ( miri_dir ( ) ?) ;
182190 let base = sh. read_file ( "rust-version" ) ?. trim ( ) . to_owned ( ) ;
183191 // Make sure the repo is clean.
@@ -265,7 +273,7 @@ impl Command {
265273 let Some ( ( command_name, trailing_args) ) = command. split_first ( ) else {
266274 bail ! ( "expected many-seeds command to be non-empty" ) ;
267275 } ;
268- let sh = shell ( ) ?;
276+ let sh = Shell :: new ( ) ?;
269277 for seed in seed_start..seed_end {
270278 println ! ( "Trying seed: {seed}" ) ;
271279 let mut miriflags = env:: var_os ( "MIRIFLAGS" ) . unwrap_or_default ( ) ;
@@ -293,7 +301,7 @@ impl Command {
293301 // Make sure we have an up-to-date Miri installed and selected the right toolchain.
294302 Self :: install ( vec ! [ ] ) ?;
295303
296- let sh = shell ( ) ?;
304+ let sh = Shell :: new ( ) ?;
297305 sh. change_dir ( miri_dir ( ) ?) ;
298306 let benches_dir = "bench-cargo-miri" ;
299307 let benches = if benches. is_empty ( ) {
@@ -365,9 +373,8 @@ impl Command {
365373 fn test ( bless : bool , flags : Vec < OsString > ) -> Result < ( ) > {
366374 Self :: auto_actions ( ) ?;
367375 let mut e = MiriEnv :: new ( ) ?;
368- // First build, and get a sysroot.
369- e. build ( path ! ( e. miri_dir / "Cargo.toml" ) , & [ ] , /* quiet */ true ) ?;
370- e. build_miri_sysroot ( ) ?;
376+ // Prepare a sysroot.
377+ e. build_miri_sysroot ( /* quiet */ false ) ?;
371378
372379 // Then test, and let caller control flags.
373380 // Only in root project as `cargo-miri` has no tests.
@@ -393,12 +400,11 @@ impl Command {
393400 let miriflags = e. sh . var ( "MIRIFLAGS" ) . unwrap_or_default ( ) ;
394401 e. sh . set_var ( "MIRIFLAGS" , format ! ( "{miriflags} --target {target}" ) ) ;
395402 }
396- // First build, and get a sysroot.
397- let miri_manifest = path ! ( e. miri_dir / "Cargo.toml" ) ;
398- e. build ( & miri_manifest, & [ ] , /* quiet */ true ) ?;
399- e. build_miri_sysroot ( ) ?;
403+ // Prepare a sysroot.
404+ e. build_miri_sysroot ( /* quiet */ true ) ?;
400405
401406 // Then run the actual command.
407+ let miri_manifest = path ! ( e. miri_dir / "Cargo.toml" ) ;
402408 let miri_flags = e. sh . var ( "MIRIFLAGS" ) . unwrap_or_default ( ) ;
403409 let miri_flags = flagsplit ( & miri_flags) ;
404410 let toolchain = & e. toolchain ;
0 commit comments