Skip to content

Commit 85d089b

Browse files
committedOct 25, 2022
Auto merge of #103392 - RalfJung:miri, r=oli-obk
update Miri I had to use a hacked version of josh to create this, so let's be careful with merging this and maybe wait a bit to see if the josh issue becomes more clear. But the history looks good to me, we are not adding duplicates of rustc commits that were previously mirrored to Miri. Also I want to add some cross-testing of Miri in x.py.
2 parents c6bd7e2 + a157e0e commit 85d089b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1522
-470
lines changed
 

‎Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -2262,6 +2262,7 @@ dependencies = [
22622262
"rand 0.8.5",
22632263
"regex",
22642264
"rustc-workspace-hack",
2265+
"rustc_version",
22652266
"shell-escape",
22662267
"smallvec",
22672268
"ui_test",

‎src/bootstrap/test.rs

+49-5
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"));
@@ -556,17 +563,54 @@ impl Step for Miri {
556563
cargo.add_rustc_lib_path(builder, compiler);
557564

558565
// miri tests need to know about the stage sysroot
559-
cargo.env("MIRI_SYSROOT", miri_sysroot);
566+
cargo.env("MIRI_SYSROOT", &miri_sysroot);
560567
cargo.env("MIRI_HOST_SYSROOT", sysroot);
561568
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
562-
cargo.env("MIRI", miri);
569+
cargo.env("MIRI", &miri);
563570
// propagate --bless
564571
if builder.config.cmd.bless() {
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.
578+
cargo.arg("--").args(builder.config.cmd.test_args());
579+
580+
let mut cargo = Command::from(cargo);
581+
builder.run(&mut cargo);
582+
583+
// # Run `cargo miri test`.
584+
// This is just a smoke test (Miri's own CI invokes this in a bunch of different ways and ensures
585+
// that we get the desired output), but that is sufficient to make sure that the libtest harness
586+
// itself executes properly under Miri.
587+
let mut cargo = tool::prepare_tool_cargo(
588+
builder,
589+
compiler,
590+
Mode::ToolRustc,
591+
host,
592+
"run",
593+
"src/tools/miri/cargo-miri",
594+
SourceType::Submodule,
595+
&[],
596+
);
597+
cargo.add_rustc_lib_path(builder, compiler);
598+
cargo.arg("--").arg("miri").arg("test");
599+
cargo
600+
.arg("--manifest-path")
601+
.arg(builder.src.join("src/tools/miri/test-cargo-miri/Cargo.toml"));
602+
cargo.arg("--target").arg(target.rustc_target_arg());
603+
cargo.arg("--tests"); // don't run doctests, they are too confused by the staging
568604
cargo.arg("--").args(builder.config.cmd.test_args());
569605

606+
// Tell `cargo miri` where to find things.
607+
cargo.env("MIRI_SYSROOT", &miri_sysroot);
608+
cargo.env("MIRI_HOST_SYSROOT", sysroot);
609+
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
610+
cargo.env("MIRI", &miri);
611+
// Debug things.
612+
cargo.env("RUST_BACKTRACE", "1");
613+
570614
let mut cargo = Command::from(cargo);
571615
builder.run(&mut cargo);
572616
}

0 commit comments

Comments
 (0)