Skip to content

bootstrap: doc: document std crates one by one#157143

Open
Fabian-Gruenbichler wants to merge 1 commit into
rust-lang:mainfrom
Fabian-Gruenbichler:mr/std-doc-reproducibility
Open

bootstrap: doc: document std crates one by one#157143
Fabian-Gruenbichler wants to merge 1 commit into
rust-lang:mainfrom
Fabian-Gruenbichler:mr/std-doc-reproducibility

Conversation

@Fabian-Gruenbichler

@Fabian-Gruenbichler Fabian-Gruenbichler commented May 30, 2026

Copy link
Copy Markdown
Contributor

Since switching over from individual, per crate cargo rustdoc invocations to a single cargo doc invocation for all crates, the doc output for Std became racy. Dependencies between library/ workspace crates were handled in a flaky fashion, sometimes being emitted as relative references, sometimes as references to the html root.

This is probably only a workaround, and it should actually be fixed in cargo or rustdoc, but I haven't managed to reproduce this issue outside of the Std doc build via bootstrap.

Closes: #156567

Fixes: 58e18dd

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels May 30, 2026
@rustbot

rustbot commented May 30, 2026

Copy link
Copy Markdown
Collaborator

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: bootstrap
  • bootstrap expanded to 6 candidates
  • Random selection from Mark-Simulacrum, clubby789

@rust-log-analyzer

This comment has been minimized.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
@Fabian-Gruenbichler Fabian-Gruenbichler force-pushed the mr/std-doc-reproducibility branch from fe86a47 to c67b1f5 Compare June 1, 2026 06:46
@Fabian-Gruenbichler

Copy link
Copy Markdown
Contributor Author

force-pushed with clippy fix

@Mark-Simulacrum Mark-Simulacrum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how I feel about the tradeoff here...

cc @rust-lang/bootstrap in case others have ideas

View changes since this review

cargo
.arg("--no-deps")
.arg("--target-dir")
.arg(&*target_dir.to_string_lossy())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's preexisting, but I think we should be able to just pass target_dir here? Cargo::arg should take Path/OsStr.

Kind::Doc,
);
let mut crates = requested_crates.to_vec();
let std_lib_crate_order = STD_PUBLIC_CRATES

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a regression in terms of needing STD_PUBLIC_CRATES again... right?

cc @jyn514 since you wrote #111955

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but it seems it is still required to document things in the right order. I am happy to fix this another way, but I haven't yet found a simple reproducer that allows me to figure out what takes a wrong turn where. if somebody has a clue, I am happy to take a closer look there :)

@jieyouxu

jieyouxu commented Jun 8, 2026

Copy link
Copy Markdown
Member

I'm a bit hesistant on papering over this in bootstrap 🤔 Is there any particular combo that makes it more likely to trigger this?

EDIT: ah, the discussion on the issue also points to rust-lang/cargo#8487.

Also not super sure on the tradeoffs. Do we know if using this approach can bring back other problems?

@Fabian-Gruenbichler

Copy link
Copy Markdown
Contributor Author

my reproducer was simply running x.py doc --stage 2 a few times and comparing the generated html files. it sometimes takes up to 10 tries on my machine until it does it wrong, but usually the first "rebuild" already has differences.

@Kobzol

Kobzol commented Jun 8, 2026

Copy link
Copy Markdown
Member

Is there a way to override the order without documenting the crates one by one? Sure would be nice to fix this in Cargo than to add yet another hack to bootstrap :)

@Fabian-Gruenbichler

Copy link
Copy Markdown
Contributor Author

AFAIK/AFAICT cargo already tries to pick the right order, but somehow still sometimes takes a wrong turn. I tried manually reproducing it with a workspace and crates referencing eachother, but failed to do so. I think the way bootstrap calls cargo doc here is a bit special (always passing --manifest-path pointing at sysroot, which in turn references other crates, but also specifying -p .. for all the documented crates), but even with trying to mimic those I failed to reproduce it with a minimized set of crates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doc reproducibility

6 participants