Skip to content

Commit 8c5b8b1

Browse files
Rollup merge of rust-lang#152921 - blkerby:bootstrap-rustdoc-config, r=Kobzol
Add build.rustdoc option to bootstrap config This adds a bootstrap config option `build.rustdoc` to be able to override the stage0 `rustdoc` binary. When unspecified, this defaults to the existing behavior of using the `rustdoc` binary in the same directory as `rustc`, making this a backward-compatible change. ### Motivation The existing behavior does not seem to be documented and can be surprising. By adding the new option, the behavior gets documented in `bootstrap.example.toml`. I ran into this because I was experimenting with a build with a configuration like this: ``` build.rustc = "/usr/bin/rustc-1.92" build.cargo = "/usr/bin/cargo-1.92" ``` This was on Ubuntu where the packages `rustc-1.92` and `cargo-1.92` place symlinks at these locations. This resulted in failure as the bootstrap process tried to run doc tests on `tidy` using a binary `/usr/bin/rustdoc` which did not exist. It took some digging to understand where that path `/usr/bin/rustdoc` was coming from. @rustbot label +A-bootstrap-config
2 parents 4646f7b + 7df7485 commit 8c5b8b1

4 files changed

Lines changed: 13 additions & 3 deletions

File tree

bootstrap.example.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@
302302
# If you set this, you likely want to set `cargo` as well.
303303
#build.rustc = "/path/to/rustc"
304304

305+
# Use this rustdoc binary as the stage0 snapshot rustdoc.
306+
# If unspecified, then the binary "rustdoc" (with platform-specific extension, e.g. ".exe")
307+
# in the same directory as "rustc" will be used.
308+
#build.rustdoc = "/path/to/rustdoc"
309+
305310
# Instead of downloading the src/stage0 version of rustfmt specified,
306311
# use this rustfmt binary instead as the stage0 snapshot rustfmt.
307312
#build.rustfmt = "/path/to/rustfmt"

src/bootstrap/src/core/config/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ pub struct Config {
298298
// These are either the stage0 downloaded binaries or the locally installed ones.
299299
pub initial_cargo: PathBuf,
300300
pub initial_rustc: PathBuf,
301+
pub initial_rustdoc: PathBuf,
301302
pub initial_cargo_clippy: Option<PathBuf>,
302303
pub initial_sysroot: PathBuf,
303304
pub initial_rustfmt: Option<PathBuf>,
@@ -456,6 +457,7 @@ impl Config {
456457
build_dir: build_build_dir,
457458
cargo: mut build_cargo,
458459
rustc: mut build_rustc,
460+
rustdoc: build_rustdoc,
459461
rustfmt: build_rustfmt,
460462
cargo_clippy: build_cargo_clippy,
461463
docs: build_docs,
@@ -751,6 +753,9 @@ impl Config {
751753
default_stage0_rustc_path(&out)
752754
});
753755

756+
let initial_rustdoc = build_rustdoc
757+
.unwrap_or_else(|| initial_rustc.with_file_name(exe("rustdoc", host_target)));
758+
754759
let initial_sysroot = t!(PathBuf::from_str(
755760
command(&initial_rustc)
756761
.args(["--print", "sysroot"])
@@ -1348,6 +1353,7 @@ impl Config {
13481353
initial_cargo,
13491354
initial_cargo_clippy: build_cargo_clippy,
13501355
initial_rustc,
1356+
initial_rustdoc,
13511357
initial_rustfmt,
13521358
initial_sysroot,
13531359
jemalloc: rust_jemalloc.unwrap_or(false),

src/bootstrap/src/core/config/toml/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ define_config! {
2525
build_dir: Option<String> = "build-dir",
2626
cargo: Option<PathBuf> = "cargo",
2727
rustc: Option<PathBuf> = "rustc",
28+
rustdoc: Option<PathBuf> = "rustdoc",
2829
rustfmt: Option<PathBuf> = "rustfmt",
2930
cargo_clippy: Option<PathBuf> = "cargo-clippy",
3031
docs: Option<bool> = "docs",

src/bootstrap/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,7 @@ impl Build {
535535
initial_lld,
536536
initial_relative_libdir,
537537
initial_rustc: config.initial_rustc.clone(),
538-
initial_rustdoc: config
539-
.initial_rustc
540-
.with_file_name(exe("rustdoc", config.host_target)),
538+
initial_rustdoc: config.initial_rustdoc.clone(),
541539
initial_cargo: config.initial_cargo.clone(),
542540
initial_sysroot: config.initial_sysroot.clone(),
543541
local_rebuild: config.local_rebuild,

0 commit comments

Comments
 (0)