From a61737ed6e169c64c851dd9a6f9bbcf5d78f70b4 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 22 Oct 2022 11:18:23 +0200 Subject: [PATCH] add support for testing Miri on other targets, and do some cross-testing on CI --- src/bootstrap/test.rs | 16 +++++++++++++--- .../host-x86_64/x86_64-gnu-tools/checktools.sh | 4 ++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 8d491409778..7f63226a061 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -461,24 +461,30 @@ fn run(self, builder: &Builder<'_>) { pub struct Miri { stage: u32, host: TargetSelection, + target: TargetSelection, } impl Step for Miri { type Output = (); - const ONLY_HOSTS: bool = true; + const ONLY_HOSTS: bool = false; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/miri") } 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. fn run(self, builder: &Builder<'_>) { let stage = self.stage; let host = self.host; + let target = self.target; 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. // Except if we are at stage 2, the bootstrap loop is complete and we can stick with our current stage. @@ -495,7 +501,7 @@ fn run(self, builder: &Builder<'_>) { builder.ensure(compile::Std::new(compiler_std, host)); 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( builder, compiler, @@ -508,6 +514,7 @@ fn run(self, builder: &Builder<'_>) { ); cargo.add_rustc_lib_path(builder, compiler); cargo.arg("--").arg("miri").arg("setup"); + cargo.arg("--target").arg(target.rustc_target_arg()); // Tell `cargo miri setup` where to find the sources. cargo.env("MIRI_LIB_SRC", builder.src.join("library")); @@ -565,6 +572,9 @@ fn run(self, builder: &Builder<'_>) { 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()); let mut cargo = Command::from(cargo); diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh b/src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh index 3e1f39eaab5..086d04a178a 100755 --- a/src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh +++ b/src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh @@ -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/rustfmt 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