set miri sysroots inside Cargo::new

This commit is contained in:
Ralf Jung 2024-04-01 23:55:50 +02:00
parent 871df0d13a
commit b390f2f458
2 changed files with 13 additions and 7 deletions

View file

@ -595,7 +595,7 @@ impl Step for Miri {
// This is for the tests so everything is done with the target compiler.
let miri_sysroot = Miri::build_miri_sysroot(builder, target_compiler, target);
builder.ensure(compile::Std::new(target_compiler, host));
let sysroot = builder.sysroot(target_compiler);
let host_sysroot = builder.sysroot(target_compiler);
// # Run `cargo test`.
// This is with the Miri crate, so it uses the host compiler.
@ -618,7 +618,7 @@ impl Step for Miri {
// miri tests need to know about the stage sysroot
cargo.env("MIRI_SYSROOT", &miri_sysroot);
cargo.env("MIRI_HOST_SYSROOT", &sysroot);
cargo.env("MIRI_HOST_SYSROOT", &host_sysroot);
cargo.env("MIRI", &miri);
// Set the target.
@ -681,10 +681,6 @@ impl Step for Miri {
}
}
// Tell `cargo miri` where to find the sysroots.
cargo.env("MIRI_SYSROOT", &miri_sysroot);
cargo.env("MIRI_HOST_SYSROOT", sysroot);
// Finally, pass test-args and run everything.
cargo.arg("--").args(builder.config.test_args());
let mut cargo = Command::from(cargo);

View file

@ -1235,6 +1235,7 @@ impl<'a> Builder<'a> {
assert!(run_compiler.stage > 0, "miri can not be invoked at stage 0");
let build_compiler = self.compiler(run_compiler.stage - 1, self.build.build);
// Prepare the tools
let miri = self.ensure(tool::Miri {
compiler: build_compiler,
target: self.build.build,
@ -1245,7 +1246,7 @@ impl<'a> Builder<'a> {
target: self.build.build,
extra_features: Vec::new(),
});
// Invoke cargo-miri, make sure we can find miri and cargo.
// Invoke cargo-miri, make sure it can find miri and cargo.
let mut cmd = Command::new(cargo_miri);
cmd.env("MIRI", &miri);
cmd.env("CARGO", &self.initial_cargo);
@ -1711,6 +1712,15 @@ impl<'a> Builder<'a> {
cargo.env("RUSTC_WRAPPER_REAL", existing_wrapper);
}
// If this is for `miri-test`, prepare the sysroots.
if cmd == "miri-test" {
self.ensure(compile::Std::new(compiler, compiler.host));
let host_sysroot = self.sysroot(compiler);
let miri_sysroot = test::Miri::build_miri_sysroot(self, compiler, target);
cargo.env("MIRI_SYSROOT", &miri_sysroot);
cargo.env("MIRI_HOST_SYSROOT", &host_sysroot);
}
cargo.env(profile_var("STRIP"), self.config.rust_strip.to_string());
if let Some(stack_protector) = &self.config.rust_stack_protector {