1
Fork 0

add support for testing Miri on other targets, and do some cross-testing on CI

This commit is contained in:
Ralf Jung 2022-10-22 11:18:23 +02:00
parent 64f56d238c
commit a61737ed6e
2 changed files with 17 additions and 3 deletions

View file

@ -461,24 +461,30 @@ impl Step for RustDemangler {
pub struct Miri { pub struct Miri {
stage: u32, stage: u32,
host: TargetSelection, host: TargetSelection,
target: TargetSelection,
} }
impl Step for Miri { impl Step for Miri {
type Output = (); type Output = ();
const ONLY_HOSTS: bool = true; const ONLY_HOSTS: bool = false;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/tools/miri") run.path("src/tools/miri")
} }
fn make_run(run: RunConfig<'_>) { fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Miri { stage: run.builder.top_stage, host: run.target }); run.builder.ensure(Miri {
stage: run.builder.top_stage,
host: run.build_triple(),
target: run.target,
});
} }
/// Runs `cargo test` for miri. /// Runs `cargo test` for miri.
fn run(self, builder: &Builder<'_>) { fn run(self, builder: &Builder<'_>) {
let stage = self.stage; let stage = self.stage;
let host = self.host; let host = self.host;
let target = self.target;
let compiler = builder.compiler(stage, host); let compiler = builder.compiler(stage, host);
// We need the stdlib for the *next* stage, as it was built with this compiler that also built Miri. // We need the stdlib for the *next* stage, as it was built with this compiler that also built Miri.
// Except if we are at stage 2, the bootstrap loop is complete and we can stick with our current stage. // Except if we are at stage 2, the bootstrap loop is complete and we can stick with our current stage.
@ -495,7 +501,7 @@ impl Step for Miri {
builder.ensure(compile::Std::new(compiler_std, host)); builder.ensure(compile::Std::new(compiler_std, host));
let sysroot = builder.sysroot(compiler_std); let sysroot = builder.sysroot(compiler_std);
// # Run `cargo miri setup`. // # Run `cargo miri setup` for the given target.
let mut cargo = tool::prepare_tool_cargo( let mut cargo = tool::prepare_tool_cargo(
builder, builder,
compiler, compiler,
@ -508,6 +514,7 @@ impl Step for Miri {
); );
cargo.add_rustc_lib_path(builder, compiler); cargo.add_rustc_lib_path(builder, compiler);
cargo.arg("--").arg("miri").arg("setup"); cargo.arg("--").arg("miri").arg("setup");
cargo.arg("--target").arg(target.rustc_target_arg());
// Tell `cargo miri setup` where to find the sources. // Tell `cargo miri setup` where to find the sources.
cargo.env("MIRI_LIB_SRC", builder.src.join("library")); cargo.env("MIRI_LIB_SRC", builder.src.join("library"));
@ -565,6 +572,9 @@ impl Step for Miri {
cargo.env("MIRI_BLESS", "Gesundheit"); cargo.env("MIRI_BLESS", "Gesundheit");
} }
// Set the target.
cargo.env("MIRI_TEST_TARGET", target.rustc_target_arg());
// Forward test filters.
cargo.arg("--").args(builder.config.cmd.test_args()); cargo.arg("--").args(builder.config.cmd.test_args());
let mut cargo = Command::from(cargo); let mut cargo = Command::from(cargo);

View file

@ -25,3 +25,7 @@ python3 "$X_PY" test --stage 2 check-tools
python3 "$X_PY" test --stage 2 src/tools/clippy python3 "$X_PY" test --stage 2 src/tools/clippy
python3 "$X_PY" test --stage 2 src/tools/rustfmt python3 "$X_PY" test --stage 2 src/tools/rustfmt
python3 "$X_PY" test --stage 2 src/tools/miri python3 "$X_PY" test --stage 2 src/tools/miri
# We natively run this script on x86_64-unknown-linux-gnu and x86_64-pc-windows-msvc.
# Also cover some other targets (on both of these hosts) via cross-testing.
python3 "$X_PY" test --stage 2 src/tools/miri --target i686-pc-windows-msvc
python3 "$X_PY" test --stage 2 src/tools/miri --target aarch64-apple-darwin