Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions library/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }

Expand Down
90 changes: 64 additions & 26 deletions src/bootstrap/src/core/build_steps/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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",
Expand All @@ -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"]
);
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/builder/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
80 changes: 80 additions & 0 deletions src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <host> -> UnstableBookGen 1 <host>
[build] rustc 0 <host> -> Rustbook 1 <host>
[doc] unstable-book (book) <host>
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[doc] book (book) <host>
[doc] book/first-edition (book) <host>
[doc] book/second-edition (book) <host>
[doc] book/2018-edition (book) <host>
[build] rustdoc 1 <host>
[doc] rustc 1 <host> -> standalone 2 <host>
[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]
[doc] rustc 1 <host> -> rustc 2 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[doc] rustc 1 <host> -> Rustdoc 2 <host>
[doc] rustc 1 <host> -> Rustfmt 2 <host>
[build] rustc 1 <host> -> error-index 2 <host>
[doc] rustc 1 <host> -> error-index 2 <host>
[doc] nomicon (book) <host>
[doc] rustc 1 <host> -> reference (book) 2 <host>
[doc] rustdoc (book) <host>
[doc] rust-by-example (book) <host>
[build] rustc 0 <host> -> LintDocs 1 <host>
[doc] rustc (book) <host>
[doc] rustc 1 <host> -> Cargo 2 <host>
[doc] cargo (book) <host>
[doc] rustc 1 <host> -> Clippy 2 <host>
[doc] clippy (book) <host>
[doc] rustc 1 <host> -> Miri 2 <host>
[doc] embedded-book (book) <host>
[doc] edition-guide (book) <host>
[doc] style-guide (book) <host>
[build] rustdoc 0 <host>
[doc] rustc 0 <host> -> Tidy 1 <host>
[doc] rustc 0 <host> -> Bootstrap 1 <host>
[doc] rustc 1 <host> -> releases 2 <host>
[doc] rustc 0 <host> -> RunMakeSupport 1 <host>
[doc] rustc 0 <host> -> BuildHelper 1 <host>
[doc] rustc 0 <host> -> Compiletest 1 <host>
[build] rustc 0 <host> -> RustInstaller 1 <host>
"
);
}

#[test]
fn dist_extended() {
let ctx = TestCtx::new();
Expand Down Expand Up @@ -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 <host>
[doc] rustc 0 <host> -> Cargo 1 <host>
");
}
#[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 <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustdoc 1 <host>
[doc] rustc 1 <host> -> Cargo 2 <host>
");
}

#[test]
fn doc_core() {
let ctx = TestCtx::new();
Expand Down
Loading