@@ -250,6 +250,9 @@ impl Step for Cargotest {
250
250
) ;
251
251
exit ! ( 1 ) ;
252
252
}
253
+ // We want to build cargo stage N (where N == top_stage), and rustc stage N,
254
+ // and test both of these together.
255
+ // So we need to get a build compiler stage N-1 to build the stage N components.
253
256
run. builder . ensure ( Cargotest {
254
257
build_compiler : run. builder . compiler ( run. builder . top_stage - 1 , run. target ) ,
255
258
host : run. target ,
@@ -261,9 +264,15 @@ impl Step for Cargotest {
261
264
/// This tool in `src/tools` will check out a few Rust projects and run `cargo
262
265
/// test` to ensure that we don't regress the test suites there.
263
266
fn run ( self , builder : & Builder < ' _ > ) {
264
- // Here we need to ensure that we run cargo with an in-tree compiler, because we test
265
- // both their behavior together.
266
- // We can build cargo with the earlier stage compiler though.
267
+ // cargotest's staging has several pieces:
268
+ // consider ./x test cargotest --stage=2.
269
+ //
270
+ // The test goal is to exercise a (stage 2 cargo, stage 2 rustc) pair through a stage 2
271
+ // cargotest tool.
272
+ // To produce the stage 2 cargo and cargotest, we need to do so with the stage 1 rustc and std.
273
+ // Importantly, the stage 2 rustc being tested (`tested_compiler`) via stage 2 cargotest is
274
+ // the rustc built by an earlier stage 1 rustc (the build_compiler). These are two different
275
+ // compilers!
267
276
let cargo =
268
277
builder. ensure ( tool:: Cargo :: from_build_compiler ( self . build_compiler , self . host ) ) ;
269
278
let tested_compiler = builder. compiler ( self . build_compiler . stage + 1 , self . host ) ;
@@ -298,6 +307,7 @@ impl Step for Cargotest {
298
307
}
299
308
300
309
/// Runs `cargo test` for cargo itself.
310
+ /// We label these tests as "cargo self-tests".
301
311
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
302
312
pub struct Cargo {
303
313
build_compiler : Compiler ,
@@ -328,7 +338,7 @@ impl Step for Cargo {
328
338
329
339
/// Runs `cargo test` for `cargo` packaged with Rust.
330
340
fn run ( self , builder : & Builder < ' _ > ) {
331
- // When we do a "stage 1 cargo test", it means that we test the stage 1 rustc
341
+ // When we do a "stage 1 cargo self- test", it means that we test the stage 1 rustc
332
342
// using stage 1 cargo. So we actually build cargo using the stage 0 compiler, and then
333
343
// run its tests against the stage 1 compiler (called `tested_compiler` below).
334
344
builder. ensure ( tool:: Cargo :: from_build_compiler ( self . build_compiler , self . host ) ) ;
0 commit comments