How to build just rustdoc?


I wanted to tweak HTML output of rustdoc, but found it surprisingly hard. It seems like I need to bootstrap and rebuild all of Rust, LLVM included, just to use my changed librustdoc.

Could rustdoc be separated from the rest of the compiler? Can it be rebuilt easier?



Not really, and it’s a major pain. You are not the first person who has wanted to do this and found it surprisingly difficult.

Currently, it can not. We may or may not be able to make it so in the future. Maybe. But also maybe not; using the compiler as a library is arguably the right thing for rustdoc. That said…

Right now no, but I was chatting with @eddyb about this earlier, and he mentioned that there was some bugs that might be causing unneeded building, or at least, that’s what I thought he meant :smile:. This means you’d need to build the compiler, but the first time only.



So, you should be able to just copy src/librustdoc into wherever and use the latest nightly on it (if you use Cargo you’ll want to remove all relative dependencies in Cargo.toml).

I suppose you’ll also want src/rustc/ as your binary to have something to run.

As for the building the compiler twice: ./ build --stage 1 src/libstd works in terms of making a functional compiler (including rustdoc).

The problem is running tests, because some of the tests require compiler plugins, and the the “bugs” that make us need stage2 to run all tests, but the majority work at stage1 (i.e. building the compiler only once).

Sadly rustdoc tests changed to require building the compiler twice at some point because they’re testing custom derives or something.


closed #4

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.