Skip to content

Commit 08fa5f0

Browse files
committed
bootstrap-rustdoc: use current stage if download-rustc enabled
When using download-rustc, using stage 1 rustdoc results in the wrong librustc_driver being used. ```sh $ ./build/host/stage1/bin/rustdoc --version ./build/host/stage1/bin/rustdoc: error while loading shared libraries: librustc_driver-7ff02ed05016d515.so: cannot open shared object file: No such file or directory ``` This change fixes that by not cutting the stage if download-rustc is enabled. Signed-off-by: onur-ozkan <[email protected]>
1 parent 3186d17 commit 08fa5f0

File tree

1 file changed

+11
-12
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+11
-12
lines changed

Diff for: src/bootstrap/src/core/build_steps/tool.rs

+11-12
Original file line numberDiff line numberDiff line change
@@ -476,24 +476,23 @@ impl Step for Rustdoc {
476476
return builder.initial_rustc.with_file_name(exe("rustdoc", target_compiler.host));
477477
}
478478
let target = target_compiler.host;
479-
// Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
480-
// we'd have stageN/bin/rustc and stageN/bin/rustdoc be effectively different stage
481-
// compilers, which isn't what we want. Rustdoc should be linked in the same way as the
482-
// rustc compiler it's paired with, so it must be built with the previous stage compiler.
483-
let build_compiler = builder.compiler(target_compiler.stage - 1, builder.config.build);
479+
480+
let build_compiler = if builder.download_rustc() && target_compiler.stage == 1 {
481+
// We already have the stage 1 compiler, we don't need to cut the stage.
482+
builder.compiler(target_compiler.stage, builder.config.build)
483+
} else {
484+
// Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
485+
// we'd have stageN/bin/rustc and stageN/bin/rustdoc be effectively different stage
486+
// compilers, which isn't what we want. Rustdoc should be linked in the same way as the
487+
// rustc compiler it's paired with, so it must be built with the previous stage compiler.
488+
builder.compiler(target_compiler.stage - 1, builder.config.build)
489+
};
484490

485491
// When using `download-rustc` and a stage0 build_compiler, copying rustc doesn't actually
486492
// build stage0 libstd (because the libstd in sysroot has the wrong ABI). Explicitly build
487493
// it.
488494
builder.ensure(compile::Std::new(build_compiler, target_compiler.host));
489495
builder.ensure(compile::Rustc::new(build_compiler, target_compiler.host));
490-
// NOTE: this implies that `download-rustc` is pretty useless when compiling with the stage0
491-
// compiler, since you do just as much work.
492-
if !builder.config.dry_run() && builder.download_rustc() && build_compiler.stage == 0 {
493-
println!(
494-
"WARNING: `download-rustc` does nothing when building stage1 tools; consider using `--stage 2` instead"
495-
);
496-
}
497496

498497
// The presence of `target_compiler` ensures that the necessary libraries (codegen backends,
499498
// compiler libraries, ...) are built. Rustdoc does not require the presence of any

0 commit comments

Comments
 (0)