Skip to content

Commit a58b1ed

Browse files
committed
Auto merge of #71458 - ecstatic-morse:bootstrap-cfg-doc, r=Mark-Simulacrum
Set `--cfg bootstrap` for stage0 rustdoc Resolves #71455. With this patch, running `./x.py doc --stage 0 src/libstd` with a clean `build` dir successfully outputs docs for `core`, `alloc` and `std` in under a minute. This kind of turnaround for viewing small changes to the standard library documentation is quite nice, and I think we should endeavour to keep it working. I'm not sure how involved that would be though. r? @Mark-Simulacrum
2 parents 40008dc + 08c8996 commit a58b1ed

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/bootstrap/builder.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,11 @@ impl<'a> Builder<'a> {
791791
rustflags.arg("--cfg=bootstrap");
792792
}
793793

794+
// FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`,
795+
// but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See
796+
// #71458.
797+
let rustdocflags = rustflags.clone();
798+
794799
if let Ok(s) = env::var("CARGOFLAGS") {
795800
cargo.args(s.split_whitespace());
796801
}
@@ -1269,7 +1274,7 @@ impl<'a> Builder<'a> {
12691274
}
12701275
}
12711276

1272-
Cargo { command: cargo, rustflags }
1277+
Cargo { command: cargo, rustflags, rustdocflags }
12731278
}
12741279

12751280
/// Ensure that a given step is built, returning its output. This will
@@ -1327,7 +1332,7 @@ impl<'a> Builder<'a> {
13271332
#[cfg(test)]
13281333
mod tests;
13291334

1330-
#[derive(Debug)]
1335+
#[derive(Debug, Clone)]
13311336
struct Rustflags(String);
13321337

13331338
impl Rustflags {
@@ -1367,6 +1372,7 @@ impl Rustflags {
13671372
pub struct Cargo {
13681373
command: Command,
13691374
rustflags: Rustflags,
1375+
rustdocflags: Rustflags,
13701376
}
13711377

13721378
impl Cargo {
@@ -1399,7 +1405,16 @@ impl Cargo {
13991405

14001406
impl From<Cargo> for Command {
14011407
fn from(mut cargo: Cargo) -> Command {
1402-
cargo.command.env("RUSTFLAGS", &cargo.rustflags.0);
1408+
let rustflags = &cargo.rustflags.0;
1409+
if !rustflags.is_empty() {
1410+
cargo.command.env("RUSTFLAGS", rustflags);
1411+
}
1412+
1413+
let rustdocflags = &cargo.rustdocflags.0;
1414+
if !rustdocflags.is_empty() {
1415+
cargo.command.env("RUSTDOCFLAGS", rustdocflags);
1416+
}
1417+
14031418
cargo.command
14041419
}
14051420
}

0 commit comments

Comments
 (0)