@@ -46,6 +46,7 @@ pub struct Std {
4646 /// but we need to use the downloaded copy of std for linking to rustdoc. Allow this to be overriden by `builder.ensure` from other steps.
4747 force_recompile : bool ,
4848 extra_rust_args : & ' static [ & ' static str ] ,
49+ is_for_mir_opt_tests : bool ,
4950}
5051
5152impl Std {
@@ -56,6 +57,7 @@ impl Std {
5657 crates : Default :: default ( ) ,
5758 force_recompile : false ,
5859 extra_rust_args : & [ ] ,
60+ is_for_mir_opt_tests : false ,
5961 }
6062 }
6163
@@ -66,6 +68,18 @@ impl Std {
6668 crates : Default :: default ( ) ,
6769 force_recompile : true ,
6870 extra_rust_args : & [ ] ,
71+ is_for_mir_opt_tests : false ,
72+ }
73+ }
74+
75+ pub fn new_for_mir_opt_tests ( compiler : Compiler , target : TargetSelection ) -> Self {
76+ Self {
77+ target,
78+ compiler,
79+ crates : Default :: default ( ) ,
80+ force_recompile : false ,
81+ extra_rust_args : & [ ] ,
82+ is_for_mir_opt_tests : true ,
6983 }
7084 }
7185
@@ -80,6 +94,7 @@ impl Std {
8094 crates : Default :: default ( ) ,
8195 force_recompile : false ,
8296 extra_rust_args,
97+ is_for_mir_opt_tests : false ,
8398 }
8499 }
85100}
@@ -109,6 +124,7 @@ impl Step for Std {
109124 crates,
110125 force_recompile : false ,
111126 extra_rust_args : & [ ] ,
127+ is_for_mir_opt_tests : false ,
112128 } ) ;
113129 }
114130
@@ -206,11 +222,19 @@ impl Step for Std {
206222 }
207223 }
208224
209- let mut cargo = builder. cargo ( compiler, Mode :: Std , SourceType :: InTree , target, "build" ) ;
210- std_cargo ( builder, target, compiler. stage , & mut cargo) ;
211- for krate in & * self . crates {
212- cargo. arg ( "-p" ) . arg ( krate) ;
213- }
225+ let mut cargo = if self . is_for_mir_opt_tests {
226+ let mut cargo = builder. cargo ( compiler, Mode :: Std , SourceType :: InTree , target, "rustc" ) ;
227+ cargo. arg ( "-p" ) . arg ( "std" ) . arg ( "--crate-type=lib" ) ;
228+ std_cargo ( builder, target, compiler. stage , & mut cargo) ;
229+ cargo
230+ } else {
231+ let mut cargo = builder. cargo ( compiler, Mode :: Std , SourceType :: InTree , target, "build" ) ;
232+ std_cargo ( builder, target, compiler. stage , & mut cargo) ;
233+ for krate in & * self . crates {
234+ cargo. arg ( "-p" ) . arg ( krate) ;
235+ }
236+ cargo
237+ } ;
214238
215239 // See src/bootstrap/synthetic_targets.rs
216240 if target. is_synthetic ( ) {
0 commit comments