This commit is contained in:
Ralf Jung 2020-05-21 11:32:12 +02:00
parent c4c7463aa5
commit 254fc50bc1

View File

@ -1,12 +1,12 @@
#![feature(inner_deref)]
use std::env;
use std::ffi::OsString;
use std::fs::{self, File};
use std::io::{self, BufRead, Write};
use std::ops::Not;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::ffi::OsString;
use rustc_version::VersionMeta;
@ -265,7 +265,8 @@ fn setup(subcommand: MiriCommand) {
let sysroot = std::str::from_utf8(&sysroot).unwrap();
let sysroot = Path::new(sysroot.trim_end_matches('\n'));
// Check for `$SYSROOT/lib/rustlib/src/rust/src`; test if that contains `libstd/lib.rs`.
let rustup_src = sysroot.join("lib").join("rustlib").join("src").join("rust").join("src");
let rustup_src =
sysroot.join("lib").join("rustlib").join("src").join("rust").join("src");
if !rustup_src.join("libstd").join("lib.rs").exists() {
// Ask the user to install the `rust-src` component, and use that.
let mut cmd = Command::new("rustup");
@ -363,8 +364,7 @@ path = "lib.rs"
let sysroot = if target == &host { dir.join("HOST") } else { PathBuf::from(dir) };
std::env::set_var("MIRI_SYSROOT", &sysroot); // pass the env var to the processes we spawn, which will turn it into "--sysroot" flags
// Figure out what to print.
let print_sysroot = subcommand == MiriCommand::Setup
&& has_arg_flag("--print-sysroot"); // whether we just print the sysroot path
let print_sysroot = subcommand == MiriCommand::Setup && has_arg_flag("--print-sysroot"); // whether we just print the sysroot path
if print_sysroot {
// Print just the sysroot and nothing else; this way we do not need any escaping.
println!("{}", sysroot.display());
@ -564,6 +564,8 @@ fn main() {
// dependencies get dispatched to `rustc`, the final test/binary to `miri`.
inside_cargo_rustc();
} else {
show_error(format!("`cargo-miri` must be called with either `miri` or `rustc` as first argument."))
show_error(format!(
"`cargo-miri` must be called with either `miri` or `rustc` as first argument."
))
}
}