@@ -425,24 +425,18 @@ impl Step for Rustdoc {
425
425
return builder. initial_rustc . with_file_name ( exe ( "rustdoc" , & target_compiler. host ) ) ;
426
426
}
427
427
let target = target_compiler. host ;
428
- let build_compiler = if target_compiler. stage == 0 {
429
- builder. compiler ( 0 , builder. config . build )
430
- } else if target_compiler. stage >= 2 {
431
- // Past stage 2, we consider the compiler to be ABI-compatible and hence capable of
432
- // building rustdoc itself.
433
- builder. compiler ( target_compiler. stage , builder. config . build )
434
- } else {
435
- // Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
436
- // we'd have stageN/bin/rustc and stageN/bin/rustdoc be effectively different stage
437
- // compilers, which isn't what we want.
438
- builder. compiler ( target_compiler. stage - 1 , builder. config . build )
439
- } ;
440
-
441
- builder. ensure ( compile:: Rustc { compiler : build_compiler, target } ) ;
442
- builder. ensure ( compile:: Rustc {
443
- compiler : build_compiler,
444
- target : builder. config . build ,
445
- } ) ;
428
+ // Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
429
+ // we'd have stageN/bin/rustc and stageN/bin/rustdoc be effectively different stage
430
+ // compilers, which isn't what we want. Rustdoc should be linked in the same way as the
431
+ // rustc compiler it's paired with, so it must be built with the previous stage compiler.
432
+ let build_compiler = builder. compiler ( target_compiler. stage - 1 , builder. config . build ) ;
433
+
434
+ // The presence of `target_compiler` ensures that the necessary libraries (codegen backends,
435
+ // compiler libraries, ...) are built. Rustdoc does not require the presence of any
436
+ // libraries within sysroot_libdir (i.e., rustlib), though doctests may want it (since
437
+ // they'll be linked to those libraries). As such, don't explicitly `ensure` any additional
438
+ // libraries here. The intuition here is that If we've built a compiler, we should be able
439
+ // to build rustdoc.
446
440
447
441
let mut cargo = prepare_tool_cargo (
448
442
builder,
0 commit comments