@@ -5,7 +5,7 @@ use std::ffi::OsStr;
55use std:: path:: PathBuf ;
66use std:: process:: { self , Command } ;
77
8- use rustc_build_sysroot:: { BuildMode , Sysroot , SysrootConfig } ;
8+ use rustc_build_sysroot:: { BuildMode , SysrootBuilder , SysrootConfig } ;
99use rustc_version:: VersionMeta ;
1010
1111use crate :: util:: * ;
@@ -67,9 +67,11 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta
6767 let sysroot_config = if std:: env:: var_os ( "MIRI_NO_STD" ) . is_some ( ) {
6868 SysrootConfig :: NoStd
6969 } else {
70- SysrootConfig :: WithStd { std_features : & [ "panic_unwind" , "backtrace" ] }
70+ SysrootConfig :: WithStd {
71+ std_features : [ "panic_unwind" , "backtrace" ] . into_iter ( ) . map ( Into :: into) . collect ( ) ,
72+ }
7173 } ;
72- let cargo_cmd = || {
74+ let cargo_cmd = {
7375 let mut command = cargo ( ) ;
7476 // Use Miri as rustc to build a libstd compatible with us (and use the right flags).
7577 // 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
103105 command. stdout ( process:: Stdio :: null ( ) ) ;
104106 command. stderr ( process:: Stdio :: null ( ) ) ;
105107 }
106- // Disable debug assertions in the standard library -- Miri is already slow enough.
107- // But keep the overflow checks, they are cheap. This completely overwrites flags
108- // the user might have set, which is consistent with normal `cargo build` that does
109- // not apply `RUSTFLAGS` to the sysroot either.
110- let rustflags = vec ! [ "-Cdebug-assertions=off" . into( ) , "-Coverflow-checks=on" . into( ) ] ;
111- ( command, rustflags)
108+
109+ command
112110 } ;
111+ // Disable debug assertions in the standard library -- Miri is already slow enough.
112+ // But keep the overflow checks, they are cheap. This completely overwrites flags
113+ // the user might have set, which is consistent with normal `cargo build` that does
114+ // not apply `RUSTFLAGS` to the sysroot either.
115+ let rustflags = & [ "-Cdebug-assertions=off" , "-Coverflow-checks=on" ] ;
113116 // Make sure all target-level Miri invocations know their sysroot.
114117 std:: env:: set_var ( "MIRI_SYSROOT" , sysroot_dir) ;
115118
@@ -121,8 +124,13 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta
121124 // We want to be quiet, but still let the user know that something is happening.
122125 eprint ! ( "Preparing a sysroot for Miri (target: {target})... " ) ;
123126 }
124- Sysroot :: new ( sysroot_dir, target)
125- . build_from_source ( & rust_src, BuildMode :: Check , sysroot_config, rustc_version, cargo_cmd)
127+ SysrootBuilder :: new ( sysroot_dir, target)
128+ . build_mode ( BuildMode :: Check )
129+ . rustc_version ( rustc_version. clone ( ) )
130+ . sysroot_config ( sysroot_config)
131+ . rustflags ( rustflags)
132+ . cargo ( cargo_cmd)
133+ . build_from_source ( & rust_src)
126134 . unwrap_or_else ( |_| {
127135 if only_setup {
128136 show_error ! ( "failed to build sysroot, see error details above" )
0 commit comments