Skip to content

Commit f90b239

Browse files
authored
Unrolled build for #157626
Rollup merge of #157626 - kohsine:autogen-flag-stubs, r=clubby789 Autogenerate unstable compiler flag stubs for unstable-book Closes #141525. Based on old PR #142135. Parses `rustc -Zhelp` to generate doc stubs for unstable compiler flags if any are missing.
2 parents b30f3df + 4980543 commit f90b239

3 files changed

Lines changed: 118 additions & 48 deletions

File tree

src/bootstrap/src/core/build_steps/doc.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ book!(
8282

8383
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
8484
pub struct UnstableBook {
85+
build_compiler: Compiler,
8586
target: TargetSelection,
8687
}
8788

@@ -97,11 +98,24 @@ impl Step for UnstableBook {
9798
}
9899

99100
fn make_run(run: RunConfig<'_>) {
100-
run.builder.ensure(UnstableBook { target: run.target });
101+
// Bump the stage to 2, because the unstable book requires an in-tree compiler.
102+
// At the same time, since this step is enabled by default, we don't want `x doc` to fail
103+
// in stage 1.
104+
let stage = if run.builder.config.is_explicit_stage() || run.builder.top_stage >= 2 {
105+
run.builder.top_stage
106+
} else {
107+
2
108+
};
109+
110+
run.builder.ensure(UnstableBook {
111+
build_compiler: prepare_doc_compiler(run.builder, run.target, stage),
112+
target: run.target,
113+
});
101114
}
102115

103116
fn run(self, builder: &Builder<'_>) {
104-
builder.ensure(UnstableBookGen { target: self.target });
117+
builder
118+
.ensure(UnstableBookGen { build_compiler: self.build_compiler, target: self.target });
105119
builder.ensure(RustbookSrc {
106120
target: self.target,
107121
name: "unstable-book".to_owned(),
@@ -1265,6 +1279,7 @@ impl Step for ErrorIndex {
12651279

12661280
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
12671281
pub struct UnstableBookGen {
1282+
build_compiler: Compiler,
12681283
target: TargetSelection,
12691284
}
12701285

@@ -1281,11 +1296,15 @@ impl Step for UnstableBookGen {
12811296
}
12821297

12831298
fn make_run(run: RunConfig<'_>) {
1284-
run.builder.ensure(UnstableBookGen { target: run.target });
1299+
run.builder.ensure(UnstableBookGen {
1300+
build_compiler: prepare_doc_compiler(run.builder, run.target, run.builder.top_stage),
1301+
target: run.target,
1302+
});
12851303
}
12861304

12871305
fn run(self, builder: &Builder<'_>) {
12881306
let target = self.target;
1307+
let rustc_path = builder.rustc(self.build_compiler);
12891308

12901309
builder.info(&format!("Generating unstable book md files ({target})"));
12911310
let out = builder.md_doc_out(target).join("unstable-book");
@@ -1295,6 +1314,7 @@ impl Step for UnstableBookGen {
12951314
cmd.arg(builder.src.join("library"));
12961315
cmd.arg(builder.src.join("compiler"));
12971316
cmd.arg(builder.src.join("src"));
1317+
cmd.arg(rustc_path);
12981318
cmd.arg(out);
12991319

13001320
cmd.run(builder);

src/bootstrap/src/core/builder/tests.rs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,12 +1098,12 @@ mod snapshot {
10981098
ctx
10991099
.config("dist")
11001100
.render_steps(), @r"
1101-
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1102-
[build] rustc 0 <host> -> Rustbook 1 <host>
1103-
[doc] unstable-book (book) <host>
11041101
[build] llvm <host>
11051102
[build] rustc 0 <host> -> rustc 1 <host>
11061103
[build] rustc 1 <host> -> std 1 <host>
1104+
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1105+
[build] rustc 0 <host> -> Rustbook 1 <host>
1106+
[doc] unstable-book (book) <host>
11071107
[doc] book (book) <host>
11081108
[doc] book/first-edition (book) <host>
11091109
[doc] book/second-edition (book) <host>
@@ -1150,12 +1150,12 @@ mod snapshot {
11501150
.path("rustc-docs")
11511151
.args(&["--set", "build.compiler-docs=true"])
11521152
.render_steps(), @r"
1153-
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1154-
[build] rustc 0 <host> -> Rustbook 1 <host>
1155-
[doc] unstable-book (book) <host>
11561153
[build] llvm <host>
11571154
[build] rustc 0 <host> -> rustc 1 <host>
11581155
[build] rustc 1 <host> -> std 1 <host>
1156+
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1157+
[build] rustc 0 <host> -> Rustbook 1 <host>
1158+
[doc] unstable-book (book) <host>
11591159
[doc] book (book) <host>
11601160
[doc] book/first-edition (book) <host>
11611161
[doc] book/second-edition (book) <host>
@@ -1208,15 +1208,15 @@ mod snapshot {
12081208
"rust.lld=true",
12091209
])
12101210
.render_steps(), @r"
1211-
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1212-
[build] rustc 0 <host> -> Rustbook 1 <host>
1213-
[doc] unstable-book (book) <host>
12141211
[build] llvm <host>
12151212
[build] rustc 0 <host> -> rustc 1 <host>
12161213
[build] rustc 0 <host> -> LldWrapper 1 <host>
12171214
[build] rustc 0 <host> -> WasmComponentLd 1 <host>
12181215
[build] rustc 0 <host> -> LlvmBitcodeLinker 1 <host>
12191216
[build] rustc 1 <host> -> std 1 <host>
1217+
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1218+
[build] rustc 0 <host> -> Rustbook 1 <host>
1219+
[doc] unstable-book (book) <host>
12201220
[doc] book (book) <host>
12211221
[doc] book/first-edition (book) <host>
12221222
[doc] book/second-edition (book) <host>
@@ -1284,18 +1284,18 @@ mod snapshot {
12841284
.hosts(&[&host_target()])
12851285
.targets(&[&host_target(), TEST_TRIPLE_1])
12861286
.render_steps(), @r"
1287+
[build] llvm <host>
1288+
[build] rustc 0 <host> -> rustc 1 <host>
1289+
[build] rustc 1 <host> -> std 1 <host>
12871290
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
12881291
[build] rustc 0 <host> -> Rustbook 1 <host>
12891292
[doc] unstable-book (book) <host>
1293+
[build] rustc 1 <host> -> std 1 <target1>
12901294
[doc] unstable-book (book) <target1>
1291-
[build] llvm <host>
1292-
[build] rustc 0 <host> -> rustc 1 <host>
1293-
[build] rustc 1 <host> -> std 1 <host>
12941295
[doc] book (book) <host>
12951296
[doc] book/first-edition (book) <host>
12961297
[doc] book/second-edition (book) <host>
12971298
[doc] book/2018-edition (book) <host>
1298-
[build] rustc 1 <host> -> std 1 <target1>
12991299
[doc] book (book) <target1>
13001300
[doc] book/first-edition (book) <target1>
13011301
[doc] book/second-edition (book) <target1>
@@ -1360,12 +1360,13 @@ mod snapshot {
13601360
.hosts(&[&host_target(), TEST_TRIPLE_1])
13611361
.targets(&[&host_target()])
13621362
.render_steps(), @r"
1363-
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1364-
[build] rustc 0 <host> -> Rustbook 1 <host>
1365-
[doc] unstable-book (book) <host>
13661363
[build] llvm <host>
13671364
[build] rustc 0 <host> -> rustc 1 <host>
13681365
[build] rustc 1 <host> -> std 1 <host>
1366+
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1367+
[build] rustc 0 <host> -> Rustbook 1 <host>
1368+
[doc] unstable-book (book) <host>
1369+
[build] rustc 1 <host> -> std 1 <target1>
13691370
[doc] book (book) <host>
13701371
[doc] book/first-edition (book) <host>
13711372
[doc] book/second-edition (book) <host>
@@ -1377,7 +1378,6 @@ mod snapshot {
13771378
[build] rustc 1 <host> -> error-index 2 <host>
13781379
[doc] rustc 1 <host> -> error-index 2 <host>
13791380
[build] llvm <target1>
1380-
[build] rustc 1 <host> -> std 1 <target1>
13811381
[build] rustc 1 <host> -> rustc 2 <target1>
13821382
[build] rustc 1 <host> -> error-index 2 <target1>
13831383
[doc] rustc 1 <host> -> error-index 2 <target1>
@@ -1423,18 +1423,18 @@ mod snapshot {
14231423
.hosts(&[&host_target(), TEST_TRIPLE_1])
14241424
.targets(&[&host_target(), TEST_TRIPLE_1])
14251425
.render_steps(), @r"
1426+
[build] llvm <host>
1427+
[build] rustc 0 <host> -> rustc 1 <host>
1428+
[build] rustc 1 <host> -> std 1 <host>
14261429
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
14271430
[build] rustc 0 <host> -> Rustbook 1 <host>
14281431
[doc] unstable-book (book) <host>
1432+
[build] rustc 1 <host> -> std 1 <target1>
14291433
[doc] unstable-book (book) <target1>
1430-
[build] llvm <host>
1431-
[build] rustc 0 <host> -> rustc 1 <host>
1432-
[build] rustc 1 <host> -> std 1 <host>
14331434
[doc] book (book) <host>
14341435
[doc] book/first-edition (book) <host>
14351436
[doc] book/second-edition (book) <host>
14361437
[doc] book/2018-edition (book) <host>
1437-
[build] rustc 1 <host> -> std 1 <target1>
14381438
[doc] book (book) <target1>
14391439
[doc] book/first-edition (book) <target1>
14401440
[doc] book/second-edition (book) <target1>
@@ -1508,12 +1508,12 @@ mod snapshot {
15081508
.hosts(&[])
15091509
.targets(&[TEST_TRIPLE_1])
15101510
.render_steps(), @r"
1511-
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1512-
[build] rustc 0 <host> -> Rustbook 1 <host>
1513-
[doc] unstable-book (book) <target1>
15141511
[build] llvm <host>
15151512
[build] rustc 0 <host> -> rustc 1 <host>
15161513
[build] rustc 1 <host> -> std 1 <target1>
1514+
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1515+
[build] rustc 0 <host> -> Rustbook 1 <host>
1516+
[doc] unstable-book (book) <target1>
15171517
[doc] book (book) <target1>
15181518
[doc] book/first-edition (book) <target1>
15191519
[doc] book/second-edition (book) <target1>
@@ -1551,13 +1551,13 @@ mod snapshot {
15511551
.targets(&[TEST_TRIPLE_1])
15521552
.args(&["--set", "rust.channel=nightly", "--set", "build.extended=true"])
15531553
.render_steps(), @r"
1554-
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1555-
[build] rustc 0 <host> -> Rustbook 1 <host>
1556-
[doc] unstable-book (book) <target1>
15571554
[build] llvm <host>
15581555
[build] rustc 0 <host> -> rustc 1 <host>
15591556
[build] rustc 0 <host> -> WasmComponentLd 1 <host>
15601557
[build] rustc 1 <host> -> std 1 <target1>
1558+
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1559+
[build] rustc 0 <host> -> Rustbook 1 <host>
1560+
[doc] unstable-book (book) <target1>
15611561
[doc] book (book) <target1>
15621562
[doc] book/first-edition (book) <target1>
15631563
[doc] book/second-edition (book) <target1>
@@ -1695,13 +1695,13 @@ mod snapshot {
16951695
.config("dist")
16961696
.args(&["--set", "rust.codegen-backends=['llvm', 'cranelift']"])
16971697
.render_steps(), @r"
1698-
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1699-
[build] rustc 0 <host> -> Rustbook 1 <host>
1700-
[doc] unstable-book (book) <host>
17011698
[build] llvm <host>
17021699
[build] rustc 0 <host> -> rustc 1 <host>
17031700
[build] rustc 0 <host> -> rustc_codegen_cranelift 1 <host>
17041701
[build] rustc 1 <host> -> std 1 <host>
1702+
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1703+
[build] rustc 0 <host> -> Rustbook 1 <host>
1704+
[doc] unstable-book (book) <host>
17051705
[doc] book (book) <host>
17061706
[doc] book/first-edition (book) <host>
17071707
[doc] book/second-edition (book) <host>
@@ -1778,12 +1778,12 @@ mod snapshot {
17781778
.config("dist")
17791779
.path("rustc-docs")
17801780
.render_steps(), @r"
1781-
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1782-
[build] rustc 0 <host> -> Rustbook 1 <host>
1783-
[doc] unstable-book (book) <host>
17841781
[build] llvm <host>
17851782
[build] rustc 0 <host> -> rustc 1 <host>
17861783
[build] rustc 1 <host> -> std 1 <host>
1784+
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1785+
[build] rustc 0 <host> -> Rustbook 1 <host>
1786+
[doc] unstable-book (book) <host>
17871787
[doc] book (book) <host>
17881788
[doc] book/first-edition (book) <host>
17891789
[doc] book/second-edition (book) <host>
@@ -2533,6 +2533,9 @@ mod snapshot {
25332533
insta::assert_snapshot!(
25342534
ctx.config("doc")
25352535
.render_steps(), @r"
2536+
[build] llvm <host>
2537+
[build] rustc 0 <host> -> rustc 1 <host>
2538+
[build] rustc 1 <host> -> std 1 <host>
25362539
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
25372540
[build] rustc 0 <host> -> Rustbook 1 <host>
25382541
[doc] unstable-book (book) <host>
@@ -2542,14 +2545,11 @@ mod snapshot {
25422545
[doc] book/2018-edition (book) <host>
25432546
[build] rustdoc 0 <host>
25442547
[doc] rustc 0 <host> -> standalone 1 <host>
2545-
[build] llvm <host>
2546-
[build] rustc 0 <host> -> rustc 1 <host>
25472548
[build] rustdoc 1 <host>
25482549
[doc] rustc 1 <host> -> std 1 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
25492550
[build] rustc 0 <host> -> error-index 1 <host>
25502551
[doc] rustc 0 <host> -> error-index 1 <host>
25512552
[doc] nomicon (book) <host>
2552-
[build] rustc 1 <host> -> std 1 <host>
25532553
[doc] rustc 1 <host> -> reference (book) 2 <host>
25542554
[doc] rustdoc (book) <host>
25552555
[doc] rust-by-example (book) <host>
@@ -2901,10 +2901,10 @@ mod snapshot {
29012901
}), @r"
29022902
[build] llvm <x86_64-unknown-linux-gnu>
29032903
[build] rustc 0 <x86_64-unknown-linux-gnu> -> rustc 1 <x86_64-unknown-linux-gnu>
2904+
[build] rustc 1 <x86_64-unknown-linux-gnu> -> std 1 <x86_64-unknown-linux-gnu>
29042905
[build] rustc 0 <x86_64-unknown-linux-gnu> -> UnstableBookGen 1 <x86_64-unknown-linux-gnu>
29052906
[build] rustc 0 <x86_64-unknown-linux-gnu> -> Rustbook 1 <x86_64-unknown-linux-gnu>
29062907
[doc] unstable-book (book) <x86_64-unknown-linux-gnu>
2907-
[build] rustc 1 <x86_64-unknown-linux-gnu> -> std 1 <x86_64-unknown-linux-gnu>
29082908
[doc] book (book) <x86_64-unknown-linux-gnu>
29092909
[doc] book/first-edition (book) <x86_64-unknown-linux-gnu>
29102910
[doc] book/second-edition (book) <x86_64-unknown-linux-gnu>
@@ -2960,10 +2960,10 @@ mod snapshot {
29602960
}), @r"
29612961
[build] llvm <x86_64-unknown-linux-gnu>
29622962
[build] rustc 0 <x86_64-unknown-linux-gnu> -> rustc 1 <x86_64-unknown-linux-gnu>
2963+
[build] rustc 1 <x86_64-unknown-linux-gnu> -> std 1 <x86_64-unknown-linux-gnu>
29632964
[build] rustc 0 <x86_64-unknown-linux-gnu> -> UnstableBookGen 1 <x86_64-unknown-linux-gnu>
29642965
[build] rustc 0 <x86_64-unknown-linux-gnu> -> Rustbook 1 <x86_64-unknown-linux-gnu>
29652966
[doc] unstable-book (book) <x86_64-unknown-linux-gnu>
2966-
[build] rustc 1 <x86_64-unknown-linux-gnu> -> std 1 <x86_64-unknown-linux-gnu>
29672967
[doc] book (book) <x86_64-unknown-linux-gnu>
29682968
[doc] book/first-edition (book) <x86_64-unknown-linux-gnu>
29692969
[doc] book/second-edition (book) <x86_64-unknown-linux-gnu>
@@ -3048,10 +3048,10 @@ mod snapshot {
30483048
[build] llvm <x86_64-unknown-linux-gnu>
30493049
[build] rustc 0 <x86_64-unknown-linux-gnu> -> rustc 1 <x86_64-unknown-linux-gnu>
30503050
[build] rustc 0 <x86_64-unknown-linux-gnu> -> WasmComponentLd 1 <x86_64-unknown-linux-gnu>
3051+
[build] rustc 1 <x86_64-unknown-linux-gnu> -> std 1 <x86_64-unknown-linux-gnu>
30513052
[build] rustc 0 <x86_64-unknown-linux-gnu> -> UnstableBookGen 1 <x86_64-unknown-linux-gnu>
30523053
[build] rustc 0 <x86_64-unknown-linux-gnu> -> Rustbook 1 <x86_64-unknown-linux-gnu>
30533054
[doc] unstable-book (book) <x86_64-unknown-linux-gnu>
3054-
[build] rustc 1 <x86_64-unknown-linux-gnu> -> std 1 <x86_64-unknown-linux-gnu>
30553055
[doc] book (book) <x86_64-unknown-linux-gnu>
30563056
[doc] book/first-edition (book) <x86_64-unknown-linux-gnu>
30573057
[doc] book/second-edition (book) <x86_64-unknown-linux-gnu>

0 commit comments

Comments
 (0)