Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't bootstrap with rustdoc #43284

Closed
alexcrichton opened this issue Jul 17, 2017 · 13 comments · Fixed by #43482
Closed

Don't bootstrap with rustdoc #43284

alexcrichton opened this issue Jul 17, 2017 · 13 comments · Fixed by #43482
Assignees
Labels
T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue.

Comments

@alexcrichton
Copy link
Member

Currently the rustdoc executable is bootstrapped in the same manner as rustc itself, meaning that we compile rustdoc itself once per stage. This isn't really necessary though as we only really need to bootstrap the compiler! As a result dev times are slower (stage0/stage1 need to compile rustdoc) and overall CI times are slower (we compile it twice instead of once).

I think we could instead move rustdoc to src/tools and instead compile it in only one stage, the final stage. This'll involve a few changes such as:

  • Delete src/driver (I think this is an old vestigate at this point anyway?
  • Add src/tools/rustdoc
  • Add dependency on src/librustdoc from src/tools/rustdoc
  • Make src/tools/rustdoc/src/main.rs a one-line shim to rustdoc::main
  • Remove all librustc* dependencies in src/librustdoc/Cargo.toml
  • Rework rustbuild rules and dependencies to account for this movement
  • Rework assembling the distribution in dist.rs to account moving the rustdoc executable into place.
@alexcrichton alexcrichton added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Jul 17, 2017
@alexcrichton
Copy link
Member Author

cc @Mark-Simulacrum would you be interested in tackling this?

cc @aidanhs as well

@nikomatsakis
Copy link
Contributor

cc @GuillaumeGomez -- this would help you with your html diff problems

@Mark-Simulacrum
Copy link
Member

Sure, we can do this. However, is it worth the investment today? AIUI, @steveklabnik is working on a rewrite that won't even be in-tree perhaps (or just a submodule). Should we wait for that?

@alexcrichton
Copy link
Member Author

@Mark-Simulacrum I don't think there's any need to block, all of this work will need to happen anyway for a rewrite regardless.

@Mark-Simulacrum
Copy link
Member

True. I'd prefer not to implement this myself on the current rustbuild, but I'd be happy to do it once we make a decision on the rewrite.

Remove all librustc* dependencies in src/librustdoc/Cargo.toml

I'm not quite sure if this is what you meant to say -- this seems like a fairly large task; is the intent that we'd instead link against them via extern crate and the unstable feature gate rustc_private?

@steveklabnik steveklabnik added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. labels Jul 17, 2017
@alexcrichton
Copy link
Member Author

Oh sorry I mean just literally delete these lines and nothing more. All those crates will be in the sysroot, so Cargo doesn't need to build them.

@steveklabnik
Copy link
Member

I'm generally in support of this idea.

@Mark-Simulacrum it is still very early days with that project; I wouldn't be taking anything about it into consideration when making decisions generally.

@ollie27
Copy link
Member

ollie27 commented Jul 17, 2017

As long as this also fixes #38318 then 👍.

@GuillaumeGomez
Copy link
Member

I approve!

@Mark-Simulacrum Mark-Simulacrum self-assigned this Jul 17, 2017
@aidanhs
Copy link
Member

aidanhs commented Jul 18, 2017

May (or may not) also have an effect on the proc macro issues in #41991.

@QuietMisdreavus
Copy link
Member

What would this change affect in terms of edit-compile-debug cycles on rustdoc or std documentation itself? I admit i don't know the placement of "tools" in terms of the build order, but it sounds like just working on rustdoc would have a longer single-setup time (since it would be part of "the final stage") but much shorter turnaround times (since you don't have to rebuild the world to get a working rustdoc)? How would this interact with the trick of using rustup to link a local toolchain that points to your local rustdoc? Would rustdoc now only appear in the stage2/bin folder? Would it no longer be part of that output?

As for regenerating std docs, how would this interact with that? When I'm working on rustdoc i like to test my changes on the std documentation so i don't have to write a purpose-built test crate for it. Putting rustdoc outside the regular staging could require some new considerations in regards to how it wants to rebuild dependencies of the crate you're documenting.

I don't see these as pure blockers to getting this done, just things that may need to be taken into account as part of shaking out the rustbuild dependency graph and the ./x.py doc command. Since this could also solve my own pet rustbuild issue (#42686) i'm mainly on board.

@alexcrichton
Copy link
Member Author

@QuietMisdreavus it would make edit-compile faster on rustdoc because rustbuild wouldn't be fooled into thinking rustc depends on rustdoc. I would not improve edits to libstd documentation.

but it sounds like just working on rustdoc would have a longer single-setup time

Actually it'll get faster! ./x.py build will still produce rustdoc, and it'll just produce rustdoc more quickly. Incantations like ./x.py build src/tools/rustdoc --stage 1 will still work for those who want a rustdoc quickly (same for stage 0)

How would this interact with the trick of using rustup to link a local toolchain that points to your local rustdoc?

Shouldn't affect it, the sysroot will still look the same.

Would rustdoc now only appear in the stage2/bin folder?

Probably!

As for regenerating std docs, how would this interact with that?

No better than it is today.

@GuillaumeGomez
Copy link
Member

I can't wait to have this update!

bors added a commit that referenced this issue Jul 27, 2017
Compile rustdoc on-demand

Fixes #43284, fixes #38318, and fixes #39505.

Doesn't directly help with #42686, since we need to rebuild just as much. In fact, this hurts it, since `./x.py doc --stage 0` will now fail. I'm not sure if it did before, but with these changes it runs into the problem where we attempt to use artifacts from bootstrap rustc with a non-bootstrap rustdoc, running into version conflicts. I believe this is solvable, but leaving for a future PR.

This means that rustdoc will no longer be compiled when compiling rustc, by default. However, it is still built from `./x.py build` (for hosts, but not targets, since we don't produce compiler toolchains for them) and will be built for doc tests and crate tests.

After this, the recommended workflow if you want a rustdoc is: `./x.py build --stage 1 src/tools/rustdoc` which will give you a working rustdoc in `build/triple/stage1/bin/rustdoc`. Note that you can add `src/libstd` onto the command to compile libstd as well so that the rustdoc can easily compile crates in the wild. `./x.py doc --stage 1 src/libstd` will document `libstd` with a freshly built rustdoc (if necessary), and will not rebuild rustc on modifications to rustdoc.

r? @alexcrichton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants