mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
Auto merge of #3413 - RalfJung:cargo-miri-misc, r=RalfJung
phase_rustdoc: add a heuristic to make us more certain that this is really rustdoc Also add anyhow to test-cargo-miri; it has a custom build probe and is widely used so let's make sure the build script does not fail.
This commit is contained in:
commit
c4611708bd
@ -11,10 +11,18 @@ use std::{env, iter};
|
||||
|
||||
use crate::phases::*;
|
||||
|
||||
/// Returns `true` if our flags look like they may be for rustdoc, i.e., this is cargo calling us to
|
||||
/// be rustdoc. It's hard to be sure as cargo does not have a RUSTDOC_WRAPPER or an env var that
|
||||
/// would let us get a clear signal.
|
||||
fn looks_like_rustdoc() -> bool {
|
||||
// The `--test-run-directory` flag only exists for rustdoc and cargo always passes it. Perfect!
|
||||
env::args().any(|arg| arg == "--test-run-directory")
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Rustc does not support non-UTF-8 arguments so we make no attempt either.
|
||||
// (We do support non-UTF-8 environment variables though.)
|
||||
let mut args = std::env::args();
|
||||
let mut args = env::args();
|
||||
// Skip binary name.
|
||||
args.next().unwrap();
|
||||
|
||||
@ -91,10 +99,16 @@ fn main() {
|
||||
// (see https://github.com/rust-lang/cargo/issues/10886).
|
||||
phase_rustc(args, RustcPhase::Build)
|
||||
}
|
||||
_ => {
|
||||
// Everything else must be rustdoc. But we need to get `first` "back onto the iterator",
|
||||
_ if looks_like_rustdoc() => {
|
||||
// This is probably rustdoc. But we need to get `first` "back onto the iterator",
|
||||
// it is some part of the rustdoc invocation.
|
||||
phase_rustdoc(iter::once(first).chain(args));
|
||||
}
|
||||
_ => {
|
||||
show_error!(
|
||||
"`cargo-miri` failed to recognize which phase of the build process this is, please report a bug.\nThe command-line arguments were: {:#?}",
|
||||
Vec::from_iter(env::args()),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -620,7 +620,7 @@ pub fn phase_rustdoc(mut args: impl Iterator<Item = String>) {
|
||||
|
||||
// The `--test-builder` and `--runtool` arguments are unstable rustdoc features,
|
||||
// which are disabled by default. We first need to enable them explicitly:
|
||||
cmd.arg("-Z").arg("unstable-options");
|
||||
cmd.arg("-Zunstable-options");
|
||||
|
||||
// rustdoc needs to know the right sysroot.
|
||||
cmd.arg("--sysroot").arg(env::var_os("MIRI_SYSROOT").unwrap());
|
||||
|
@ -2,6 +2,12 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.81"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
@ -24,6 +30,7 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||
name = "cargo-miri-test"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"autocfg",
|
||||
"byteorder 0.5.3",
|
||||
"byteorder 1.4.3",
|
||||
|
@ -22,6 +22,9 @@ issue_rust_86261 = { path = "issue-rust-86261" }
|
||||
byteorder_2 = { package = "byteorder", version = "0.5" } # to test dev-dependencies behave as expected, with renaming
|
||||
# Not actually used, but exercises some unique code path (`--extern` .so file).
|
||||
serde_derive = "1.0.185"
|
||||
# Not actually used, but uses a custom build probe so let's make sure that works.
|
||||
# (Ideally we'd check if the probe was successful, but that's not easily possible.)
|
||||
anyhow = "1.0"
|
||||
|
||||
[build-dependencies]
|
||||
autocfg = "1"
|
||||
|
Loading…
Reference in New Issue
Block a user