Skip to content

Commit b390f2f

Browse files
committed
set miri sysroots inside Cargo::new
1 parent 871df0d commit b390f2f

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ impl Step for Miri {
595595
// This is for the tests so everything is done with the target compiler.
596596
let miri_sysroot = Miri::build_miri_sysroot(builder, target_compiler, target);
597597
builder.ensure(compile::Std::new(target_compiler, host));
598-
let sysroot = builder.sysroot(target_compiler);
598+
let host_sysroot = builder.sysroot(target_compiler);
599599

600600
// # Run `cargo test`.
601601
// This is with the Miri crate, so it uses the host compiler.
@@ -618,7 +618,7 @@ impl Step for Miri {
618618

619619
// miri tests need to know about the stage sysroot
620620
cargo.env("MIRI_SYSROOT", &miri_sysroot);
621-
cargo.env("MIRI_HOST_SYSROOT", &sysroot);
621+
cargo.env("MIRI_HOST_SYSROOT", &host_sysroot);
622622
cargo.env("MIRI", &miri);
623623

624624
// Set the target.
@@ -681,10 +681,6 @@ impl Step for Miri {
681681
}
682682
}
683683

684-
// Tell `cargo miri` where to find the sysroots.
685-
cargo.env("MIRI_SYSROOT", &miri_sysroot);
686-
cargo.env("MIRI_HOST_SYSROOT", sysroot);
687-
688684
// Finally, pass test-args and run everything.
689685
cargo.arg("--").args(builder.config.test_args());
690686
let mut cargo = Command::from(cargo);

src/bootstrap/src/core/builder.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,7 @@ impl<'a> Builder<'a> {
12351235
assert!(run_compiler.stage > 0, "miri can not be invoked at stage 0");
12361236
let build_compiler = self.compiler(run_compiler.stage - 1, self.build.build);
12371237

1238+
// Prepare the tools
12381239
let miri = self.ensure(tool::Miri {
12391240
compiler: build_compiler,
12401241
target: self.build.build,
@@ -1245,7 +1246,7 @@ impl<'a> Builder<'a> {
12451246
target: self.build.build,
12461247
extra_features: Vec::new(),
12471248
});
1248-
// Invoke cargo-miri, make sure we can find miri and cargo.
1249+
// Invoke cargo-miri, make sure it can find miri and cargo.
12491250
let mut cmd = Command::new(cargo_miri);
12501251
cmd.env("MIRI", &miri);
12511252
cmd.env("CARGO", &self.initial_cargo);
@@ -1711,6 +1712,15 @@ impl<'a> Builder<'a> {
17111712
cargo.env("RUSTC_WRAPPER_REAL", existing_wrapper);
17121713
}
17131714

1715+
// If this is for `miri-test`, prepare the sysroots.
1716+
if cmd == "miri-test" {
1717+
self.ensure(compile::Std::new(compiler, compiler.host));
1718+
let host_sysroot = self.sysroot(compiler);
1719+
let miri_sysroot = test::Miri::build_miri_sysroot(self, compiler, target);
1720+
cargo.env("MIRI_SYSROOT", &miri_sysroot);
1721+
cargo.env("MIRI_HOST_SYSROOT", &host_sysroot);
1722+
}
1723+
17141724
cargo.env(profile_var("STRIP"), self.config.rust_strip.to_string());
17151725

17161726
if let Some(stack_protector) = &self.config.rust_stack_protector {

0 commit comments

Comments
 (0)