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

cargo doc: Generate rmeta files for dependencies instead of compiling rlibs #4976

Merged
merged 2 commits into from
Feb 5, 2018

Conversation

mbrubeck
Copy link
Contributor

@mbrubeck mbrubeck commented Jan 24, 2018

This makes cargo doc require only metadata (.rmeta files) instead of compiled libraries (.rlib files) for dependencies. This makes cargo doc faster in cases where rlibs are not already built and/or metadata is already available.

Unfortunately, this is not a win for every workflow. In the case where the user has already compiled but has not generated metadata, it makes cargo doc do extra work. This is probably a common case, though tools like RLS and cargo check mean that many developers will have up-to-date metadata available.

It would become an unequivocal win if cargo build and cargo check re-used shared metadata (#3501). For now, starting from a clean working directory, the following sequences of commands will become:

  • cargo doc: faster
  • cargo build; cargo doc: slower
  • cargo check; cargo doc: faster
  • cargo build --release; cargo doc: faster
  • cargo check; cargo build; cargo doc: no change

@rust-highfive
Copy link

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member

Thanks! Looks like there's some compile errors though?

I'd be curious to hear thoughts from others from @rust-lang/cargo as well though. It sort of depends on what the most common way is to generate docs whether this is a good idea to do or not. I'd sort of lean towards "yes" personally, but wanted to gut check with others!

@mbrubeck
Copy link
Contributor Author

Fixed handling of plugin dependencies.

@alexcrichton
Copy link
Member

Hm maybe still some lingering errors?

@mbrubeck
Copy link
Contributor Author

The remaining failures are caused by cargo test --doc not compiling dependencies, which it should. I will work on fixing this soon.

@aturon
Copy link
Member

aturon commented Jan 27, 2018

@alexcrichton I'm in favor.

@wycats
Copy link
Contributor

wycats commented Feb 5, 2018

@alexcrichton I am also in favor. What do we think are the chances of getting #3501 ?

@alexcrichton
Copy link
Member

@wycats I think it mostly just needs some work to get it done, AFAIK there's no fundamental blockers.

@steveklabnik
Copy link
Member

Incidentally, new-rustdoc uses cargo check to do its thing, so this is also interesting from that perspective, lining the two up.

@mbrubeck
Copy link
Contributor Author

mbrubeck commented Feb 5, 2018

Pushed a fix for cargo doc --test.

@alexcrichton
Copy link
Member

@bors: r+

Looks great and sounds like we've got some momentum, thanks @mbrubeck!

@bors
Copy link
Contributor

bors commented Feb 5, 2018

📌 Commit 9bb9dbd has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Feb 5, 2018

⌛ Testing commit 9bb9dbd with merge 16ffc05...

bors added a commit that referenced this pull request Feb 5, 2018
cargo doc: Generate rmeta files for dependencies instead of compiling rlibs

This makes `cargo doc` require only metadata (`.rmeta` files) instead of compiled libraries (`.rlib` files) for dependencies.  This makes `cargo doc` faster in cases where rlibs are not already built and/or metadata is already available.

Unfortunately, this is not a win for every workflow.  In the case where the user has already compiled but has not generated metadata, it makes `cargo doc` do extra work.  This is probably a common case, though tools like RLS and `cargo check` mean that many developers *will* have up-to-date metadata available.

It would become an unequivocal win if `cargo build` and `cargo check` re-used shared metadata (#3501). For now, starting from a clean working directory, the following sequences of commands will become:

* `cargo doc`: faster
* `cargo build; cargo doc`: slower
* `cargo check; cargo doc`: faster
* `cargo build --release; cargo doc`: faster
* `cargo check; cargo build; cargo doc`: no change
@bors
Copy link
Contributor

bors commented Feb 5, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 16ffc05 to master...

@bors bors merged commit 9bb9dbd into rust-lang:master Feb 5, 2018
@dwijnand
Copy link
Member

dwijnand commented Aug 4, 2018

Would it not be possible to use .rlib files if available over .rmeta files, therefore keeping cargo build; cargo doc as fast as it was prior to this change?

@alexcrichton
Copy link
Member

@dwijnand technically it's possible! Last we tried to do that (a long time ago) it was pretty tricky in Cargo's internals keeping track of what's built and correctly handling incremental builds, but lots of time has passed since then so it may be easier today!

@ehuss ehuss added this to the 1.25.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants