Auto merge of #103392 - RalfJung:miri, r=oli-obk · rust-lang/rust@85d089b (original) (raw)

`@@ -461,24 +461,30 @@ impl Step for RustDemangler {

`

461

461

`pub struct Miri {

`

462

462

`stage: u32,

`

463

463

`host: TargetSelection,

`

``

464

`+

target: TargetSelection,

`

464

465

`}

`

465

466

``

466

467

`impl Step for Miri {

`

467

468

`type Output = ();

`

468

``

`-

const ONLY_HOSTS: bool = true;

`

``

469

`+

const ONLY_HOSTS: bool = false;

`

469

470

``

470

471

`fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {

`

471

472

` run.path("src/tools/miri")

`

472

473

`}

`

473

474

``

474

475

`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

`+

});

`

476

481

`}

`

477

482

``

478

483

`` /// Runs cargo test for miri.

``

479

484

`fn run(self, builder: &Builder<'_>) {

`

480

485

`let stage = self.stage;

`

481

486

`let host = self.host;

`

``

487

`+

let target = self.target;

`

482

488

`let compiler = builder.compiler(stage, host);

`

483

489

`// We need the stdlib for the next stage, as it was built with this compiler that also built Miri.

`

484

490

`// 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 {

`

495

501

` builder.ensure(compile::Std::new(compiler_std, host));

`

496

502

`let sysroot = builder.sysroot(compiler_std);

`

497

503

``

498

``

`` -

// # Run cargo miri setup.

``

``

504

`` +

// # Run cargo miri setup for the given target.

``

499

505

`let mut cargo = tool::prepare_tool_cargo(

`

500

506

` builder,

`

501

507

` compiler,

`

`@@ -508,6 +514,7 @@ impl Step for Miri {

`

508

514

`);

`

509

515

` cargo.add_rustc_lib_path(builder, compiler);

`

510

516

` cargo.arg("--").arg("miri").arg("setup");

`

``

517

`+

cargo.arg("--target").arg(target.rustc_target_arg());

`

511

518

``

512

519

`` // Tell cargo miri setup where to find the sources.

``

513

520

` cargo.env("MIRI_LIB_SRC", builder.src.join("library"));

`

`@@ -556,17 +563,54 @@ impl Step for Miri {

`

556

563

` cargo.add_rustc_lib_path(builder, compiler);

`

557

564

``

558

565

`// miri tests need to know about the stage sysroot

`

559

``

`-

cargo.env("MIRI_SYSROOT", miri_sysroot);

`

``

566

`+

cargo.env("MIRI_SYSROOT", &miri_sysroot);

`

560

567

` cargo.env("MIRI_HOST_SYSROOT", sysroot);

`

561

568

` cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));

`

562

``

`-

cargo.env("MIRI", miri);

`

``

569

`+

cargo.env("MIRI", &miri);

`

563

570

`// propagate --bless

`

564

571

`if builder.config.cmd.bless() {

`

565

572

` cargo.env("MIRI_BLESS", "Gesundheit");

`

566

573

`}

`

567

574

``

``

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

`

568

604

` cargo.arg("--").args(builder.config.cmd.test_args());

`

569

605

``

``

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

+

570

614

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

`

571

615

` builder.run(&mut cargo);

`

572

616

`}

`