@@ -37,11 +37,12 @@ use crate::{
3737 debug, trace,
3838} ;
3939
40- /// Build a standard library for the given `target` using the given `compiler `.
40+ /// Build a standard library for the given `target` using the given `build_compiler `.
4141#[ derive( Debug , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
4242pub struct Std {
4343 pub target : TargetSelection ,
44- pub compiler : Compiler ,
44+ /// Compiler that builds the standard library.
45+ pub build_compiler : Compiler ,
4546 /// Whether to build only a subset of crates in the standard library.
4647 ///
4748 /// This shouldn't be used from other steps; see the comment on [`Rustc`].
@@ -54,10 +55,10 @@ pub struct Std {
5455}
5556
5657impl Std {
57- pub fn new ( compiler : Compiler , target : TargetSelection ) -> Self {
58+ pub fn new ( build_compiler : Compiler , target : TargetSelection ) -> Self {
5859 Self {
5960 target,
60- compiler ,
61+ build_compiler ,
6162 crates : Default :: default ( ) ,
6263 force_recompile : false ,
6364 extra_rust_args : & [ ] ,
@@ -121,7 +122,7 @@ impl Step for Std {
121122 trace ! ( force_recompile) ;
122123
123124 run. builder . ensure ( Std {
124- compiler : run. builder . compiler ( run. builder . top_stage , run. build_triple ( ) ) ,
125+ build_compiler : run. builder . compiler ( run. builder . top_stage , run. build_triple ( ) ) ,
125126 target : run. target ,
126127 crates,
127128 force_recompile,
@@ -152,19 +153,20 @@ impl Step for Std {
152153 let target = self . target ;
153154
154155 // We already have std ready to be used for stage 0.
155- if self . compiler . stage == 0 {
156- let compiler = self . compiler ;
156+ if self . build_compiler . stage == 0 {
157+ let compiler = self . build_compiler ;
157158 builder. ensure ( StdLink :: from_std ( self , compiler) ) ;
158159
159160 return ;
160161 }
161162
162- let compiler = if builder. download_rustc ( ) && self . force_recompile {
163+ let build_compiler = if builder. download_rustc ( ) && self . force_recompile {
163164 // When there are changes in the library tree with CI-rustc, we want to build
164165 // the stageN library and that requires using stageN-1 compiler.
165- builder. compiler ( self . compiler . stage . saturating_sub ( 1 ) , builder. config . host_target )
166+ builder
167+ . compiler ( self . build_compiler . stage . saturating_sub ( 1 ) , builder. config . host_target )
166168 } else {
167- self . compiler
169+ self . build_compiler
168170 } ;
169171
170172 // When using `download-rustc`, we already have artifacts for the host available. Don't
@@ -173,7 +175,8 @@ impl Step for Std {
173175 && builder. config . is_host_target ( target)
174176 && !self . force_recompile
175177 {
176- let sysroot = builder. ensure ( Sysroot { compiler, force_recompile : false } ) ;
178+ let sysroot =
179+ builder. ensure ( Sysroot { compiler : build_compiler, force_recompile : false } ) ;
177180 cp_rustc_component_to_ci_sysroot (
178181 builder,
179182 & sysroot,
@@ -182,65 +185,70 @@ impl Step for Std {
182185 return ;
183186 }
184187
185- if builder. config . keep_stage . contains ( & compiler . stage )
186- || builder. config . keep_stage_std . contains ( & compiler . stage )
188+ if builder. config . keep_stage . contains ( & build_compiler . stage )
189+ || builder. config . keep_stage_std . contains ( & build_compiler . stage )
187190 {
188191 trace ! ( keep_stage = ?builder. config. keep_stage) ;
189192 trace ! ( keep_stage_std = ?builder. config. keep_stage_std) ;
190193
191194 builder. info ( "WARNING: Using a potentially old libstd. This may not behave well." ) ;
192195
193- builder. ensure ( StartupObjects { compiler, target } ) ;
196+ builder. ensure ( StartupObjects { compiler : build_compiler , target } ) ;
194197
195- self . copy_extra_objects ( builder, & compiler , target) ;
198+ self . copy_extra_objects ( builder, & build_compiler , target) ;
196199
197- builder. ensure ( StdLink :: from_std ( self , compiler ) ) ;
200+ builder. ensure ( StdLink :: from_std ( self , build_compiler ) ) ;
198201 return ;
199202 }
200203
201- let mut target_deps = builder. ensure ( StartupObjects { compiler, target } ) ;
204+ let mut target_deps = builder. ensure ( StartupObjects { compiler : build_compiler , target } ) ;
202205
203- let compiler_to_use = builder. compiler_for ( compiler. stage , compiler. host , target) ;
206+ let compiler_to_use =
207+ builder. compiler_for ( build_compiler. stage , build_compiler. host , target) ;
204208 trace ! ( ?compiler_to_use) ;
205209
206- if compiler_to_use != compiler
210+ if compiler_to_use != build_compiler
207211 // Never uplift std unless we have compiled stage 1; if stage 1 is compiled,
208212 // uplift it from there.
209213 //
210214 // FIXME: improve `fn compiler_for` to avoid adding stage condition here.
211- && compiler . stage > 1
215+ && build_compiler . stage > 1
212216 {
213- trace ! ( ?compiler_to_use, ?compiler, "compiler != compiler_to_use, uplifting library" ) ;
217+ trace ! (
218+ ?compiler_to_use,
219+ ?build_compiler,
220+ "compiler != compiler_to_use, uplifting library"
221+ ) ;
214222
215223 builder. std ( compiler_to_use, target) ;
216224 let msg = if compiler_to_use. host == target {
217225 format ! (
218226 "Uplifting library (stage{} -> stage{})" ,
219- compiler_to_use. stage, compiler . stage
227+ compiler_to_use. stage, build_compiler . stage
220228 )
221229 } else {
222230 format ! (
223231 "Uplifting library (stage{}:{} -> stage{}:{})" ,
224- compiler_to_use. stage, compiler_to_use. host, compiler . stage, target
232+ compiler_to_use. stage, compiler_to_use. host, build_compiler . stage, target
225233 )
226234 } ;
227235 builder. info ( & msg) ;
228236
229237 // Even if we're not building std this stage, the new sysroot must
230238 // still contain the third party objects needed by various targets.
231- self . copy_extra_objects ( builder, & compiler , target) ;
239+ self . copy_extra_objects ( builder, & build_compiler , target) ;
232240
233241 builder. ensure ( StdLink :: from_std ( self , compiler_to_use) ) ;
234242 return ;
235243 }
236244
237245 trace ! (
238246 ?compiler_to_use,
239- ?compiler ,
247+ ?build_compiler ,
240248 "compiler == compiler_to_use, handling not-cross-compile scenario"
241249 ) ;
242250
243- target_deps. extend ( self . copy_extra_objects ( builder, & compiler , target) ) ;
251+ target_deps. extend ( self . copy_extra_objects ( builder, & build_compiler , target) ) ;
244252
245253 // We build a sysroot for mir-opt tests using the same trick that Miri does: A check build
246254 // with -Zalways-encode-mir. This frees us from the need to have a target linker, and the
@@ -249,7 +257,7 @@ impl Step for Std {
249257 trace ! ( "building special sysroot for mir-opt tests" ) ;
250258 let mut cargo = builder:: Cargo :: new_for_mir_opt_tests (
251259 builder,
252- compiler ,
260+ build_compiler ,
253261 Mode :: Std ,
254262 SourceType :: InTree ,
255263 target,
@@ -262,7 +270,7 @@ impl Step for Std {
262270 trace ! ( "building regular sysroot" ) ;
263271 let mut cargo = builder:: Cargo :: new (
264272 builder,
265- compiler ,
273+ build_compiler ,
266274 Mode :: Std ,
267275 SourceType :: InTree ,
268276 target,
@@ -285,29 +293,29 @@ impl Step for Std {
285293
286294 let _guard = builder. msg (
287295 Kind :: Build ,
288- compiler . stage ,
296+ build_compiler . stage ,
289297 format_args ! ( "library artifacts{}" , crate_description( & self . crates) ) ,
290- compiler . host ,
298+ build_compiler . host ,
291299 target,
292300 ) ;
293301 run_cargo (
294302 builder,
295303 cargo,
296304 vec ! [ ] ,
297- & build_stamp:: libstd_stamp ( builder, compiler , target) ,
305+ & build_stamp:: libstd_stamp ( builder, build_compiler , target) ,
298306 target_deps,
299307 self . is_for_mir_opt_tests , // is_check
300308 false ,
301309 ) ;
302310
303311 builder. ensure ( StdLink :: from_std (
304312 self ,
305- builder. compiler ( compiler . stage , builder. config . host_target ) ,
313+ builder. compiler ( build_compiler . stage , builder. config . host_target ) ,
306314 ) ) ;
307315 }
308316
309317 fn metadata ( & self ) -> Option < StepMetadata > {
310- Some ( StepMetadata :: build ( "std" , self . target ) . built_by ( self . compiler ) )
318+ Some ( StepMetadata :: build ( "std" , self . target ) . built_by ( self . build_compiler ) )
311319 }
312320}
313321
@@ -688,7 +696,7 @@ impl StdLink {
688696 pub fn from_std ( std : Std , host_compiler : Compiler ) -> Self {
689697 Self {
690698 compiler : host_compiler,
691- target_compiler : std. compiler ,
699+ target_compiler : std. build_compiler ,
692700 target : std. target ,
693701 crates : std. crates ,
694702 force_recompile : std. force_recompile ,
0 commit comments