From 1f0a6725d38b163ea4f1e11b80f247e73a1f5442 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 6 Nov 2022 19:59:28 +0100 Subject: [PATCH] bump rustc-build-sysroot --- src/tools/miri/cargo-miri/Cargo.lock | 4 ++-- src/tools/miri/cargo-miri/Cargo.toml | 2 +- src/tools/miri/cargo-miri/src/setup.rs | 30 ++++++++++++++++---------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/tools/miri/cargo-miri/Cargo.lock b/src/tools/miri/cargo-miri/Cargo.lock index 2beb6e1f1a46..3e5d388668b3 100644 --- a/src/tools/miri/cargo-miri/Cargo.lock +++ b/src/tools/miri/cargo-miri/Cargo.lock @@ -175,9 +175,9 @@ dependencies = [ [[package]] name = "rustc-build-sysroot" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec5f3689b6c560d6a3a17fcbe54204cd870b4fcf46342d60de16715b660d2c92" +checksum = "20c4b4625eeb148cccf82d5e9b90ad7fab3b11a0204cf75cc7fa04981a0fdffd" dependencies = [ "anyhow", "rustc_version", diff --git a/src/tools/miri/cargo-miri/Cargo.toml b/src/tools/miri/cargo-miri/Cargo.toml index fcdd122747da..ce8457469e7c 100644 --- a/src/tools/miri/cargo-miri/Cargo.toml +++ b/src/tools/miri/cargo-miri/Cargo.toml @@ -18,7 +18,7 @@ directories = "4" rustc_version = "0.4" serde_json = "1.0.40" cargo_metadata = "0.15.0" -rustc-build-sysroot = "0.3.3" +rustc-build-sysroot = "0.4" # A noop dependency that changes in the Rust repository, it's a bit of a hack. # See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust` diff --git a/src/tools/miri/cargo-miri/src/setup.rs b/src/tools/miri/cargo-miri/src/setup.rs index 72d8ef2f7522..eb7d6b38a9e7 100644 --- a/src/tools/miri/cargo-miri/src/setup.rs +++ b/src/tools/miri/cargo-miri/src/setup.rs @@ -5,7 +5,7 @@ use std::ffi::OsStr; use std::path::PathBuf; use std::process::{self, Command}; -use rustc_build_sysroot::{BuildMode, Sysroot, SysrootConfig}; +use rustc_build_sysroot::{BuildMode, SysrootBuilder, SysrootConfig}; use rustc_version::VersionMeta; use crate::util::*; @@ -67,9 +67,11 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta let sysroot_config = if std::env::var_os("MIRI_NO_STD").is_some() { SysrootConfig::NoStd } else { - SysrootConfig::WithStd { std_features: &["panic_unwind", "backtrace"] } + SysrootConfig::WithStd { + std_features: ["panic_unwind", "backtrace"].into_iter().map(Into::into).collect(), + } }; - let cargo_cmd = || { + let cargo_cmd = { let mut command = cargo(); // Use Miri as rustc to build a libstd compatible with us (and use the right flags). // However, when we are running in bootstrap, we cannot just overwrite `RUSTC`, @@ -103,13 +105,14 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta command.stdout(process::Stdio::null()); command.stderr(process::Stdio::null()); } - // Disable debug assertions in the standard library -- Miri is already slow enough. - // But keep the overflow checks, they are cheap. This completely overwrites flags - // the user might have set, which is consistent with normal `cargo build` that does - // not apply `RUSTFLAGS` to the sysroot either. - let rustflags = vec!["-Cdebug-assertions=off".into(), "-Coverflow-checks=on".into()]; - (command, rustflags) + + command }; + // Disable debug assertions in the standard library -- Miri is already slow enough. + // But keep the overflow checks, they are cheap. This completely overwrites flags + // the user might have set, which is consistent with normal `cargo build` that does + // not apply `RUSTFLAGS` to the sysroot either. + let rustflags = &["-Cdebug-assertions=off", "-Coverflow-checks=on"]; // Make sure all target-level Miri invocations know their sysroot. std::env::set_var("MIRI_SYSROOT", sysroot_dir); @@ -121,8 +124,13 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta // We want to be quiet, but still let the user know that something is happening. eprint!("Preparing a sysroot for Miri (target: {target})... "); } - Sysroot::new(sysroot_dir, target) - .build_from_source(&rust_src, BuildMode::Check, sysroot_config, rustc_version, cargo_cmd) + SysrootBuilder::new(sysroot_dir, target) + .build_mode(BuildMode::Check) + .rustc_version(rustc_version.clone()) + .sysroot_config(sysroot_config) + .rustflags(rustflags) + .cargo(cargo_cmd) + .build_from_source(&rust_src) .unwrap_or_else(|_| { if only_setup { show_error!("failed to build sysroot, see error details above")