@@ -6,7 +6,7 @@ use std::ops::Not;
6
6
use anyhow:: { anyhow, bail, Context , Result } ;
7
7
use path_macro:: path;
8
8
use walkdir:: WalkDir ;
9
- use xshell:: cmd;
9
+ use xshell:: { cmd, Shell } ;
10
10
11
11
use crate :: util:: * ;
12
12
use crate :: Command ;
@@ -16,17 +16,25 @@ const JOSH_FILTER: &str =
16
16
":rev(75dd959a3a40eb5b4574f8d2e23aa6efbeb33573:prefix=src/tools/miri):/src/tools/miri" ;
17
17
18
18
impl MiriEnv {
19
- fn build_miri_sysroot ( & mut self ) -> Result < ( ) > {
19
+ fn build_miri_sysroot ( & mut self , quiet : bool ) -> Result < ( ) > {
20
20
if self . sh . var ( "MIRI_SYSROOT" ) . is_ok ( ) {
21
21
// Sysroot already set, use that.
22
22
return Ok ( ( ) ) ;
23
23
}
24
24
let manifest_path = path ! ( self . miri_dir / "cargo-miri" / "Cargo.toml" ) ;
25
25
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
+
26
31
let target = & match self . sh . var ( "MIRI_TEST_TARGET" ) {
27
32
Ok ( target) => vec ! [ "--target" . into( ) , target] ,
28
33
Err ( _) => vec ! [ ] ,
29
34
} ;
35
+ if !quiet {
36
+ eprintln ! ( "$ (buildig Miri sysroot)" ) ;
37
+ }
30
38
let output = cmd ! ( self . sh,
31
39
"cargo +{toolchain} --quiet run {cargo_extra_flags...} --manifest-path {manifest_path} --
32
40
miri setup --print-sysroot {target...}"
@@ -91,7 +99,7 @@ impl Command {
91
99
// Make sure rustup-toolchain-install-master is installed.
92
100
which:: which ( "rustup-toolchain-install-master" )
93
101
. context ( "Please install rustup-toolchain-install-master by running 'cargo install rustup-toolchain-install-master'" ) ?;
94
- let sh = shell ( ) ?;
102
+ let sh = Shell :: new ( ) ?;
95
103
sh. change_dir ( miri_dir ( ) ?) ;
96
104
let new_commit = Some ( sh. read_file ( "rust-version" ) ?. trim ( ) . to_owned ( ) ) ;
97
105
let current_commit = {
@@ -130,7 +138,7 @@ impl Command {
130
138
}
131
139
132
140
fn rustc_pull ( commit : Option < String > ) -> Result < ( ) > {
133
- let sh = shell ( ) ?;
141
+ let sh = Shell :: new ( ) ?;
134
142
sh. change_dir ( miri_dir ( ) ?) ;
135
143
let commit = commit. map ( Result :: Ok ) . unwrap_or_else ( || {
136
144
let rust_repo_head =
@@ -177,7 +185,7 @@ impl Command {
177
185
}
178
186
179
187
fn rustc_push ( github_user : String , branch : String ) -> Result < ( ) > {
180
- let sh = shell ( ) ?;
188
+ let sh = Shell :: new ( ) ?;
181
189
sh. change_dir ( miri_dir ( ) ?) ;
182
190
let base = sh. read_file ( "rust-version" ) ?. trim ( ) . to_owned ( ) ;
183
191
// Make sure the repo is clean.
@@ -265,7 +273,7 @@ impl Command {
265
273
let Some ( ( command_name, trailing_args) ) = command. split_first ( ) else {
266
274
bail ! ( "expected many-seeds command to be non-empty" ) ;
267
275
} ;
268
- let sh = shell ( ) ?;
276
+ let sh = Shell :: new ( ) ?;
269
277
for seed in seed_start..seed_end {
270
278
println ! ( "Trying seed: {seed}" ) ;
271
279
let mut miriflags = env:: var_os ( "MIRIFLAGS" ) . unwrap_or_default ( ) ;
@@ -293,7 +301,7 @@ impl Command {
293
301
// Make sure we have an up-to-date Miri installed and selected the right toolchain.
294
302
Self :: install ( vec ! [ ] ) ?;
295
303
296
- let sh = shell ( ) ?;
304
+ let sh = Shell :: new ( ) ?;
297
305
sh. change_dir ( miri_dir ( ) ?) ;
298
306
let benches_dir = "bench-cargo-miri" ;
299
307
let benches = if benches. is_empty ( ) {
@@ -365,9 +373,8 @@ impl Command {
365
373
fn test ( bless : bool , flags : Vec < OsString > ) -> Result < ( ) > {
366
374
Self :: auto_actions ( ) ?;
367
375
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 ) ?;
371
378
372
379
// Then test, and let caller control flags.
373
380
// Only in root project as `cargo-miri` has no tests.
@@ -393,12 +400,11 @@ impl Command {
393
400
let miriflags = e. sh . var ( "MIRIFLAGS" ) . unwrap_or_default ( ) ;
394
401
e. sh . set_var ( "MIRIFLAGS" , format ! ( "{miriflags} --target {target}" ) ) ;
395
402
}
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 ) ?;
400
405
401
406
// Then run the actual command.
407
+ let miri_manifest = path ! ( e. miri_dir / "Cargo.toml" ) ;
402
408
let miri_flags = e. sh . var ( "MIRIFLAGS" ) . unwrap_or_default ( ) ;
403
409
let miri_flags = flagsplit ( & miri_flags) ;
404
410
let toolchain = & e. toolchain ;
0 commit comments