@@ -5,7 +5,7 @@ use std::ffi::OsStr;
5
5
use std:: path:: PathBuf ;
6
6
use std:: process:: { self , Command } ;
7
7
8
- use rustc_build_sysroot:: { BuildMode , Sysroot , SysrootConfig } ;
8
+ use rustc_build_sysroot:: { BuildMode , SysrootBuilder , SysrootConfig } ;
9
9
use rustc_version:: VersionMeta ;
10
10
11
11
use crate :: util:: * ;
@@ -67,9 +67,11 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta
67
67
let sysroot_config = if std:: env:: var_os ( "MIRI_NO_STD" ) . is_some ( ) {
68
68
SysrootConfig :: NoStd
69
69
} 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
+ }
71
73
} ;
72
- let cargo_cmd = || {
74
+ let cargo_cmd = {
73
75
let mut command = cargo ( ) ;
74
76
// Use Miri as rustc to build a libstd compatible with us (and use the right flags).
75
77
// 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
103
105
command. stdout ( process:: Stdio :: null ( ) ) ;
104
106
command. stderr ( process:: Stdio :: null ( ) ) ;
105
107
}
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
112
110
} ;
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" ] ;
113
116
// Make sure all target-level Miri invocations know their sysroot.
114
117
std:: env:: set_var ( "MIRI_SYSROOT" , sysroot_dir) ;
115
118
@@ -121,8 +124,13 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta
121
124
// We want to be quiet, but still let the user know that something is happening.
122
125
eprint ! ( "Preparing a sysroot for Miri (target: {target})... " ) ;
123
126
}
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)
126
134
. unwrap_or_else ( |_| {
127
135
if only_setup {
128
136
show_error ! ( "failed to build sysroot, see error details above" )
0 commit comments