@@ -168,12 +168,8 @@ pub struct Rustc {
168
168
}
169
169
170
170
impl Rustc {
171
- pub fn new ( builder : & Builder < ' _ > , build_compiler : Compiler , target : TargetSelection ) -> Self {
172
- let crates = builder
173
- . in_tree_crates ( "rustc-main" , Some ( target) )
174
- . into_iter ( )
175
- . map ( |krate| krate. name . to_string ( ) )
176
- . collect ( ) ;
171
+ pub fn new ( builder : & Builder < ' _ > , target : TargetSelection , crates : Vec < String > ) -> Self {
172
+ let build_compiler = prepare_compiler_for_check ( builder, target, Mode :: Rustc ) ;
177
173
Self { build_compiler, target, crates }
178
174
}
179
175
}
@@ -189,11 +185,7 @@ impl Step for Rustc {
189
185
190
186
fn make_run ( run : RunConfig < ' _ > ) {
191
187
let crates = run. make_run_crates ( Alias :: Compiler ) ;
192
- run. builder . ensure ( Rustc {
193
- target : run. target ,
194
- build_compiler : prepare_compiler_for_check ( run. builder , run. target , Mode :: Rustc ) ,
195
- crates,
196
- } ) ;
188
+ run. builder . ensure ( Rustc :: new ( run. builder , run. target , crates) ) ;
197
189
}
198
190
199
191
/// Check the compiler.
@@ -207,15 +199,6 @@ impl Step for Rustc {
207
199
let build_compiler = self . build_compiler ;
208
200
let target = self . target ;
209
201
210
- // Build host std for compiling build scripts
211
- builder. std ( build_compiler, build_compiler. host ) ;
212
-
213
- // Build target std so that the checked rustc can link to it during the check
214
- // FIXME: maybe we can a way to only do a check of std here?
215
- // But for that we would have to copy the stdlib rmetas to the sysroot of the build
216
- // compiler, which conflicts with std rlibs, if we also build std.
217
- builder. std ( build_compiler, target) ;
218
-
219
202
let mut cargo = builder:: Cargo :: new (
220
203
builder,
221
204
build_compiler,
@@ -289,11 +272,13 @@ fn prepare_compiler_for_check(
289
272
build_compiler
290
273
}
291
274
Mode :: ToolRustc | Mode :: Codegen => {
292
- // FIXME: this is a hack, see description of Mode::Rustc below
293
- let stage = if host == target { builder. top_stage - 1 } else { builder. top_stage } ;
294
- // When checking tool stage N, we check it with compiler stage N-1
295
- let build_compiler = builder. compiler ( stage, host) ;
296
- builder. ensure ( Rustc :: new ( builder, build_compiler, target) ) ;
275
+ // Check Rustc to produce the required rmeta artifacts for rustc_private, and then
276
+ // return the build compiler that was used to check rustc.
277
+ // We do not need to check examples/tests/etc. of Rustc for rustc_private, so we pass
278
+ // an empty set of crates, which will avoid using `cargo -p`.
279
+ let check = Rustc :: new ( builder, target, vec ! [ ] ) ;
280
+ let build_compiler = check. build_compiler ;
281
+ builder. ensure ( check) ;
297
282
build_compiler
298
283
}
299
284
Mode :: Rustc => {
@@ -305,7 +290,18 @@ fn prepare_compiler_for_check(
305
290
// FIXME: remove this and either fix cross-compilation check on stage 2 (which has a
306
291
// myriad of other problems) or disable cross-checking on stage 1.
307
292
let stage = if host == target { builder. top_stage - 1 } else { builder. top_stage } ;
308
- builder. compiler ( stage, host)
293
+ let build_compiler = builder. compiler ( stage, host) ;
294
+
295
+ // Build host std for compiling build scripts
296
+ builder. std ( build_compiler, build_compiler. host ) ;
297
+
298
+ // Build target std so that the checked rustc can link to it during the check
299
+ // FIXME: maybe we can a way to only do a check of std here?
300
+ // But for that we would have to copy the stdlib rmetas to the sysroot of the build
301
+ // compiler, which conflicts with std rlibs, if we also build std.
302
+ builder. std ( build_compiler, target) ;
303
+
304
+ build_compiler
309
305
}
310
306
Mode :: Std => {
311
307
// When checking std stage N, we want to do it with the stage N compiler
0 commit comments