diff --git a/library/Cargo.lock b/library/Cargo.lock index c16bb3eafbdac..e601137e00573 100644 --- a/library/Cargo.lock +++ b/library/Cargo.lock @@ -328,7 +328,7 @@ dependencies = [ "std_detect", "unwind", "wasi 0.11.1+wasi-snapshot-preview1", - "wasi 0.14.3+wasi-0.2.4", + "wasi 0.14.4+wasi-0.2.4", "windows-targets 0.0.0", ] @@ -402,9 +402,9 @@ dependencies = [ [[package]] name = "wasi" -version = "0.14.3+wasi-0.2.4" +version = "0.14.4+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a51ae83037bdd272a9e28ce236db8c07016dd0d50c27038b3f407533c030c95" +checksum = "88a5f4a424faf49c3c2c344f166f0662341d470ea185e939657aaff130f0ec4a" dependencies = [ "rustc-std-workspace-alloc", "rustc-std-workspace-core", diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 8b78fe53a3978..d28a7f0b46022 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -81,7 +81,7 @@ wasi = { version = "0.11.0", features = [ ], default-features = false } [target.'cfg(all(target_os = "wasi", target_env = "p2"))'.dependencies] -wasip2 = { version = '0.14.3', features = [ +wasip2 = { version = '0.14.4', features = [ 'rustc-dep-of-std', ], default-features = false, package = 'wasi' } diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index eb198a0051abe..378c9c19ba5da 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -965,9 +965,11 @@ macro_rules! tool_doc { ( $tool: ident, $path: literal, - $(rustc_private_tool = $rustc_private_tool:literal, )? - $(is_library = $is_library:expr,)? - $(crates = $crates:expr)? + mode = $mode:expr + $(, is_library = $is_library:expr )? + $(, crates = $crates:expr )? + // Subset of nightly features that are allowed to be used when documenting + $(, allow_features: $allow_features:expr )? ) => { #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct $tool { @@ -988,20 +990,29 @@ macro_rules! tool_doc { fn make_run(run: RunConfig<'_>) { let target = run.target; - let (build_compiler, mode) = if true $(&& $rustc_private_tool)? { - // Rustdoc needs the rustc sysroot available to build. - let compilers = RustcPrivateCompilers::new(run.builder, run.builder.top_stage, target); - - // Build rustc docs so that we generate relative links. - run.builder.ensure(Rustc::from_build_compiler(run.builder, compilers.build_compiler(), target)); - - (compilers.build_compiler(), Mode::ToolRustcPrivate) - } else { - // bootstrap/host tools have to be documented with the stage 0 compiler - (prepare_doc_compiler(run.builder, run.builder.host_target, 1), Mode::ToolBootstrap) + let build_compiler = match $mode { + Mode::ToolRustcPrivate => { + // Rustdoc needs the rustc sysroot available to build. + let compilers = RustcPrivateCompilers::new(run.builder, run.builder.top_stage, target); + + // Build rustc docs so that we generate relative links. + run.builder.ensure(Rustc::from_build_compiler(run.builder, compilers.build_compiler(), target)); + compilers.build_compiler() + } + Mode::ToolBootstrap => { + // bootstrap/host tools should be documented with the stage 0 compiler + prepare_doc_compiler(run.builder, run.builder.host_target, 1) + } + Mode::ToolTarget => { + // target tools should be documented with the in-tree compiler + prepare_doc_compiler(run.builder, run.builder.host_target, run.builder.top_stage) + } + _ => { + panic!("Unexpected tool mode for documenting: {:?}", $mode); + } }; - run.builder.ensure($tool { build_compiler, mode, target }); + run.builder.ensure($tool { build_compiler, mode: $mode, target }); } /// Generates documentation for a tool. @@ -1032,6 +1043,15 @@ macro_rules! tool_doc { source_type, &[], ); + let allow_features = { + let mut _value = ""; + $( _value = $allow_features; )? + _value + }; + + if !allow_features.is_empty() { + cargo.allow_features(allow_features); + } cargo.arg("-Zskip-rustdoc-fingerprint"); // Only include compiler crates, no dependencies of those, such as `libc`. @@ -1087,18 +1107,33 @@ macro_rules! tool_doc { tool_doc!( BuildHelper, "src/build_helper", - rustc_private_tool = false, + mode = Mode::ToolBootstrap, is_library = true, crates = ["build_helper"] ); -tool_doc!(Rustdoc, "src/tools/rustdoc", crates = ["rustdoc", "rustdoc-json-types"]); -tool_doc!(Rustfmt, "src/tools/rustfmt", crates = ["rustfmt-nightly", "rustfmt-config_proc_macro"]); -tool_doc!(Clippy, "src/tools/clippy", crates = ["clippy_config", "clippy_utils"]); -tool_doc!(Miri, "src/tools/miri", crates = ["miri"]); +tool_doc!( + Rustdoc, + "src/tools/rustdoc", + mode = Mode::ToolRustcPrivate, + crates = ["rustdoc", "rustdoc-json-types"] +); +tool_doc!( + Rustfmt, + "src/tools/rustfmt", + mode = Mode::ToolRustcPrivate, + crates = ["rustfmt-nightly", "rustfmt-config_proc_macro"] +); +tool_doc!( + Clippy, + "src/tools/clippy", + mode = Mode::ToolRustcPrivate, + crates = ["clippy_config", "clippy_utils"] +); +tool_doc!(Miri, "src/tools/miri", mode = Mode::ToolRustcPrivate, crates = ["miri"]); tool_doc!( Cargo, "src/tools/cargo", - rustc_private_tool = false, + mode = Mode::ToolTarget, crates = [ "cargo", "cargo-credential", @@ -1110,27 +1145,30 @@ tool_doc!( "crates-io", "mdman", "rustfix", - ] + ], + // Required because of the im-rc dependency of Cargo, which automatically opts into the + // "specialization" feature in its build script when it detects a nightly toolchain. + allow_features: "specialization" ); -tool_doc!(Tidy, "src/tools/tidy", rustc_private_tool = false, crates = ["tidy"]); +tool_doc!(Tidy, "src/tools/tidy", mode = Mode::ToolBootstrap, crates = ["tidy"]); tool_doc!( Bootstrap, "src/bootstrap", - rustc_private_tool = false, + mode = Mode::ToolBootstrap, is_library = true, crates = ["bootstrap"] ); tool_doc!( RunMakeSupport, "src/tools/run-make-support", - rustc_private_tool = false, + mode = Mode::ToolBootstrap, is_library = true, crates = ["run_make_support"] ); tool_doc!( Compiletest, "src/tools/compiletest", - rustc_private_tool = false, + mode = Mode::ToolBootstrap, is_library = true, crates = ["compiletest"] ); diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index cca0c803e63bc..924bb4adb42d0 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -533,7 +533,7 @@ impl Builder<'_> { if cmd_kind == Kind::Doc { let my_out = match mode { // This is the intended out directory for compiler documentation. - Mode::Rustc | Mode::ToolRustcPrivate | Mode::ToolBootstrap => { + Mode::Rustc | Mode::ToolRustcPrivate | Mode::ToolBootstrap | Mode::ToolTarget => { self.compiler_doc_out(target) } Mode::Std => { diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index 9e8c13eb4dec7..19cfe79be5dba 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -1130,6 +1130,59 @@ mod snapshot { ); } + #[test] + fn dist_compiler_docs() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("dist") + .path("rustc-docs") + .args(&["--set", "build.compiler-docs=true"]) + .render_steps(), @r" + [build] rustc 0 -> UnstableBookGen 1 + [build] rustc 0 -> Rustbook 1 + [doc] unstable-book (book) + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [build] rustdoc 1 + [doc] rustc 1 -> standalone 2 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [doc] rustc 1 -> rustc 2 + [build] rustc 1 -> rustc 2 + [doc] rustc 1 -> Rustdoc 2 + [doc] rustc 1 -> Rustfmt 2 + [build] rustc 1 -> error-index 2 + [doc] rustc 1 -> error-index 2 + [doc] nomicon (book) + [doc] rustc 1 -> reference (book) 2 + [doc] rustdoc (book) + [doc] rust-by-example (book) + [build] rustc 0 -> LintDocs 1 + [doc] rustc (book) + [doc] rustc 1 -> Cargo 2 + [doc] cargo (book) + [doc] rustc 1 -> Clippy 2 + [doc] clippy (book) + [doc] rustc 1 -> Miri 2 + [doc] embedded-book (book) + [doc] edition-guide (book) + [doc] style-guide (book) + [build] rustdoc 0 + [doc] rustc 0 -> Tidy 1 + [doc] rustc 0 -> Bootstrap 1 + [doc] rustc 1 -> releases 2 + [doc] rustc 0 -> RunMakeSupport 1 + [doc] rustc 0 -> BuildHelper 1 + [doc] rustc 0 -> Compiletest 1 + [build] rustc 0 -> RustInstaller 1 + " + ); + } + #[test] fn dist_extended() { let ctx = TestCtx::new(); @@ -2462,6 +2515,33 @@ mod snapshot { "); } + #[test] + fn doc_cargo_stage_1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("doc") + .path("cargo") + .render_steps(), @r" + [build] rustdoc 0 + [doc] rustc 0 -> Cargo 1 + "); + } + #[test] + fn doc_cargo_stage_2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("doc") + .path("cargo") + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustdoc 1 + [doc] rustc 1 -> Cargo 2 + "); + } + #[test] fn doc_core() { let ctx = TestCtx::new();