Don't condition RUSTDOC_LIBDIR on --no-doc

In d94e7ff065, `rustdoc_path` was changed
to ignore `want_rustdoc` (which is just whether `--no-doc` was passed).
But RUSTDOC_LIBDIR wasn't kept in sync. Rather than trying to keep
`rustdoc_path` in sync with `RUSTDOC_LIBDIR`, just pass LIBDIR to the
rustc shim unconditionally.

This fix allows calling `ensure(doc::Step)` from a non-doc top-level
Step, even if `--no-doc` was present in the command line.
This commit is contained in:
Jynn Nelson 2025-09-22 10:59:39 -07:00
parent dc2c3564d2
commit 73f6b08022

View file

@ -10,7 +10,7 @@ use crate::core::config::flags::Color;
use crate::utils::build_stamp;
use crate::utils::helpers::{self, LldThreads, check_cfg_arg, linker_args, linker_flags};
use crate::{
BootstrapCommand, CLang, Compiler, Config, DocTests, DryRun, EXTRA_CHECK_CFGS, GitRepo, Mode,
BootstrapCommand, CLang, Compiler, Config, DryRun, EXTRA_CHECK_CFGS, GitRepo, Mode,
RemapScheme, TargetSelection, command, prepare_behaviour_dump_dir, t,
};
@ -851,8 +851,6 @@ impl Builder<'_> {
rustflags.arg("-Zmacro-backtrace");
let want_rustdoc = self.doc_tests != DocTests::No;
// Clear the output directory if the real rustc we're using has changed;
// Cargo cannot detect this as it thinks rustc is bootstrap/debug/rustc.
//
@ -881,7 +879,8 @@ impl Builder<'_> {
.env("RUSTC_REAL", self.rustc(compiler))
.env("RUSTC_STAGE", build_compiler_stage.to_string())
.env("RUSTC_SYSROOT", sysroot)
.env("RUSTC_LIBDIR", libdir)
.env("RUSTC_LIBDIR", &libdir)
.env("RUSTDOC_LIBDIR", libdir)
.env("RUSTDOC", self.bootstrap_out.join("rustdoc"))
.env("RUSTDOC_REAL", rustdoc_path)
.env("RUSTC_ERROR_METADATA_DST", self.extended_error_dir());
@ -919,11 +918,6 @@ impl Builder<'_> {
rustflags.arg(&format!("-Zstack-protector={stack_protector}"));
}
if !matches!(cmd_kind, Kind::Build | Kind::Check | Kind::Clippy | Kind::Fix) && want_rustdoc
{
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler));
}
let debuginfo_level = match mode {
Mode::Rustc | Mode::Codegen => self.config.rust_debuginfo_level_rustc,
Mode::Std => self.config.rust_debuginfo_level_std,