[WIP] feat: maximize artifact reuse between different modes#15627
[WIP] feat: maximize artifact reuse between different modes#15627weihanglo wants to merge 2 commits intorust-lang:masterfrom
Conversation
| p.cargo("doc") | ||
| .with_stderr_data( | ||
| str![[r#" | ||
| [CHECKING] common v1.0.0 |
There was a problem hiding this comment.
proc-macro build has generated rmeta first, so skipping checking.
| // 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.
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. |
|
☔ The latest upstream changes (possibly 36bc1d1) made this pull request unmergeable. Please resolve the merge conflicts. |
|
This is not going to work in short term. Need a more comprehensive design and maybe work with compiler team. See #15627 (comment) and #15627 (comment). Closing. |
What does this PR try to resolve?
As of this writing, it aims to reuse
rmetabetween build and check modes.(one emits rmeta + rlib, and the other emits rmeta)
This has a caveat that
DefIdin rmeta files might not match between rustcinvocations with different
--emitsvalues, 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
checkafterbuildsafe: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
cc #3501