bump rustc-build-sysroot

This commit is contained in:
Ralf Jung 2022-11-06 19:59:28 +01:00
parent 724c1a0c4d
commit 1f0a6725d3
3 changed files with 22 additions and 14 deletions

View File

@ -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",

View File

@ -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`

View File

@ -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")