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