-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[WIP] feat: maximize artifact reuse between different modes #15627
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
base: master
Are you sure you want to change the base?
Conversation
@@ -404,7 +404,6 @@ fn collision_doc_profile_split() { | |||
p.cargo("doc") | |||
.with_stderr_data( | |||
str![[r#" | |||
[CHECKING] common v1.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proc-macro build has generated rmeta first, so skipping checking.
@@ -2416,7 +2416,7 @@ fn doc_lib_true() { | |||
|
|||
// Verify that it emits rmeta for the bin and lib dependency. | |||
assert_eq!(p.glob("target/debug/artifact/*.rlib").count(), 0); | |||
assert_eq!(p.glob("target/debug/deps/libbar-*.rmeta").count(), 2); | |||
assert_eq!(p.glob("target/debug/deps/libbar-*.rmeta").count(), 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Artifact lib build generated rmeta first, so doc build can skip checking dependencies.
As of this writing, it aims to reuse `rmeta` between build and check modes. (one emits rmeta + rlib, and the other emits rmeta) This has a caveat that `DefId` in rmeta files might not match between rustc invocations with different `--emits` values, and that might lead to rustc rejecting the input rmeta. To avoid failures in rustc, this is currently guarded by fingerprint to ensure all output files present, if not, rerun. This make running `check` after `build` safe: `build`'s rmeta files might have more information and rustc is correct on rejection.
Is this meant to be incremental to eventually allow |
I would love to see it happen. Still experimenting with rustc.
You may still run |
rust-lang/compiler-team#738 is partially related |
Allowing That said, I think a lot of people run What is the cost / risks of going through this change though? |
A check and regular build will produce a different crate hash, so if you do |
Hummm.. is that because of the |
The is used |
would the same happen if you run |
This is a good point. By sharing it might make rust-analyzer a bit worse to work with cargo. I think the real world situation is more complicated for partial build, as other factors like feature unification may kick in. I just tried |
The crate hash field in the crate metadata. This field is also recorded in the crate metadata for all dependencies. If it changes, then next time rustc has to load it as indirect dependency, it will reject the .rlib/.rmeta file as having the wrong crate hash, thus forcing all dependents of a crate to be recompiled whenever the crate hash changes. |
What does this PR try to resolve?
As of this writing, it aims to reuse
rmeta
between build and check modes.(one emits rmeta + rlib, and the other emits rmeta)
This has a caveat that
DefId
in rmeta files might not match between rustcinvocations with different
--emits
values, and that might lead to rustcrejecting the input rmeta. To avoid failures in rustc, this is currently
guarded by fingerprint to ensure all output files present, if not, rerun.
This make running
check
afterbuild
safe:build
's rmeta files mighthave more information and rustc is correct on rejection.
How to test and review this PR?
Proof of concept. NOT READY FOR REVIEW