Skip to content

Commit 8787db4

Browse files
authored
Unrolled build for rust-lang#123055
Rollup merge of rust-lang#123055 - onur-ozkan:miri-rustdoc, r=RalfJung enable cargo miri test doctests This was the cleanest solution that came to my mind so far. cc `@RalfJung` Resolves rust-lang#123028
2 parents 47ecded + 69af113 commit 8787db4

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/bootstrap/src/core/build_steps/test.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,13 @@ impl Step for Miri {
680680
.arg("--manifest-path")
681681
.arg(builder.src.join("src/tools/miri/test-cargo-miri/Cargo.toml"));
682682
cargo.arg("--target").arg(target.rustc_target_arg());
683-
cargo.arg("--tests"); // don't run doctests, they are too confused by the staging
684683
cargo.arg("--").args(builder.config.test_args());
685684

685+
// `prepare_tool_cargo` sets RUSTDOC to the bootstrap wrapper and RUSTDOC_REAL to a dummy path as this is a "run", not a "test".
686+
// Also, we want the rustdoc from the "next" stage for the same reason that we build a std from the next stage.
687+
// So let's just set that here, and bypass bootstrap's RUSTDOC (just like cargo-miri already ignores bootstrap's RUSTC_WRAPPER).
688+
cargo.env("RUSTDOC", builder.rustdoc(compiler_std));
689+
686690
// Tell `cargo miri` where to find things.
687691
cargo.env("MIRI_SYSROOT", &miri_sysroot);
688692
cargo.env("MIRI_HOST_SYSROOT", sysroot);

src/tools/miri/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ binaries, and as such worth documenting:
505505
* `MIRI_LOCAL_CRATES` is set by `cargo-miri` to tell the Miri driver which
506506
crates should be given special treatment in diagnostics, in addition to the
507507
crate currently being compiled.
508+
* `MIRI_ORIG_RUSTDOC` is set and read by different phases of `cargo-miri` to remember the
509+
value of `RUSTDOC` from before it was overwritten.
508510
* `MIRI_VERBOSE` when set to any value tells the various `cargo-miri` phases to
509511
perform verbose logging.
510512
* `MIRI_HOST_SYSROOT` is set by bootstrap to tell `cargo-miri` which sysroot to use for *host*

src/tools/miri/cargo-miri/src/phases.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
202202
cmd.env("MIRI_BE_RUSTC", "target"); // we better remember to *unset* this in the other phases!
203203

204204
// Set rustdoc to us as well, so we can run doctests.
205+
if let Some(orig_rustdoc) = env::var_os("RUSTDOC") {
206+
cmd.env("MIRI_ORIG_RUSTDOC", orig_rustdoc);
207+
}
205208
cmd.env("RUSTDOC", &cargo_miri_path);
206209

207210
cmd.env("MIRI_LOCAL_CRATES", local_crates(&metadata));
@@ -581,9 +584,10 @@ pub fn phase_rustdoc(mut args: impl Iterator<Item = String>) {
581584
let verbose = std::env::var("MIRI_VERBOSE")
582585
.map_or(0, |verbose| verbose.parse().expect("verbosity flag must be an integer"));
583586

584-
// phase_cargo_miri sets the RUSTDOC env var to ourselves, so we can't use that here;
585-
// just default to a straight-forward invocation for now:
586-
let mut cmd = Command::new("rustdoc");
587+
// phase_cargo_miri sets the RUSTDOC env var to ourselves, and puts a backup
588+
// of the old value into MIRI_ORIG_RUSTDOC. So that's what we have to invoke now.
589+
let rustdoc = env::var("MIRI_ORIG_RUSTDOC").unwrap_or("rustdoc".to_string());
590+
let mut cmd = Command::new(rustdoc);
587591

588592
let extern_flag = "--extern";
589593
let runtool_flag = "--runtool";

0 commit comments

Comments
 (0)