Skip to content

Commit a61737e

Browse files
committed
add support for testing Miri on other targets, and do some cross-testing on CI
1 parent 64f56d2 commit a61737e

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

Diff for: src/bootstrap/test.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -461,24 +461,30 @@ impl Step for RustDemangler {
461461
pub struct Miri {
462462
stage: u32,
463463
host: TargetSelection,
464+
target: TargetSelection,
464465
}
465466

466467
impl Step for Miri {
467468
type Output = ();
468-
const ONLY_HOSTS: bool = true;
469+
const ONLY_HOSTS: bool = false;
469470

470471
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
471472
run.path("src/tools/miri")
472473
}
473474

474475
fn make_run(run: RunConfig<'_>) {
475-
run.builder.ensure(Miri { stage: run.builder.top_stage, host: run.target });
476+
run.builder.ensure(Miri {
477+
stage: run.builder.top_stage,
478+
host: run.build_triple(),
479+
target: run.target,
480+
});
476481
}
477482

478483
/// Runs `cargo test` for miri.
479484
fn run(self, builder: &Builder<'_>) {
480485
let stage = self.stage;
481486
let host = self.host;
487+
let target = self.target;
482488
let compiler = builder.compiler(stage, host);
483489
// We need the stdlib for the *next* stage, as it was built with this compiler that also built Miri.
484490
// 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 {
495501
builder.ensure(compile::Std::new(compiler_std, host));
496502
let sysroot = builder.sysroot(compiler_std);
497503

498-
// # Run `cargo miri setup`.
504+
// # Run `cargo miri setup` for the given target.
499505
let mut cargo = tool::prepare_tool_cargo(
500506
builder,
501507
compiler,
@@ -508,6 +514,7 @@ impl Step for Miri {
508514
);
509515
cargo.add_rustc_lib_path(builder, compiler);
510516
cargo.arg("--").arg("miri").arg("setup");
517+
cargo.arg("--target").arg(target.rustc_target_arg());
511518

512519
// Tell `cargo miri setup` where to find the sources.
513520
cargo.env("MIRI_LIB_SRC", builder.src.join("library"));
@@ -565,6 +572,9 @@ impl Step for Miri {
565572
cargo.env("MIRI_BLESS", "Gesundheit");
566573
}
567574

575+
// Set the target.
576+
cargo.env("MIRI_TEST_TARGET", target.rustc_target_arg());
577+
// Forward test filters.
568578
cargo.arg("--").args(builder.config.cmd.test_args());
569579

570580
let mut cargo = Command::from(cargo);

Diff for: src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh

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

0 commit comments

Comments
 (0)