This is a tracking issue for the MCP "Relink Don't Rebuild".
The unstable option for this issue is public_api_hash
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.
There is a dedicated zulip channel for discussions related to Relink Don't Rebuild
Steps
Implement the MCP
There are currently 2 large open PR-s providing an initial working implementation of RDR. These should be split into smaller ones:
Ones marked with 🌟 are large PR-s, needing more reviewer effort. ⭐ are middle sized or need understanding of RDR to review. Ones without markers are small and should be easy to review without much knowledge of the feature.
Features not yet implemented, but should be done before stabilization
Trait impls in a public api hash are partially done. Its current state:
| Trait visibility |
Struct visibility |
Should be in the public hash |
Currently in the public hash |
| Private |
Private |
No |
No |
| Private |
Public |
No |
No |
| Public |
Private |
No |
Yes |
| Public |
Public |
Yes |
Yes |
Unresolved Questions
Span sensitivity
Spans are part of the public api. Which has the unfortuante consequence that changing the span of public items (a simple operation like editing the body of a function moves the end of its span, editing its doc comment also moves it) will cause rebuild in dependants. Errors and warnings produced by dependants rely heavily on spans, and debug info also uses it (a bit differently, debug info only needs the line numbers, while diagnostics produced also read and emit the source code covered by the spans).
Span insensitivity would enable other public api hash optimizations which don't make sense without it:
- ignore reordering of repr(rust) enum variants, union or struct fields
- ignore adding private fields to a struct (with the usual caveats)
- ignore doc comment changes
There are multiple avenues for exploration:
- add an option which simply ignores diagnostic spans for public api hashing. Combined with disabling debug info generation this could effectively make public api hashing span insensitive. This could be a major win for
cargo check, which does not generate debug info.
- add some kind of fast path which just reemits diagnostics and debug info.
v0 symbol mangling changes
Current v0 symbol mangling disambiguator does not work well with RDR. It uses a per crate global index based on the number of symbols in the crate. The symbol disambiguator part should be reworked to make them compatible. Currently, v0 symbol mangling panics when public api hashing is enabled in any dependency.
Implementation history
This is a tracking issue for the MCP "Relink Don't Rebuild".
The unstable option for this issue is
public_api_hashAbout tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.
There is a dedicated zulip channel for discussions related to Relink Don't Rebuild
Steps
Implement the MCP
There are currently 2 large open PR-s providing an initial working implementation of RDR. These should be split into smaller ones:
first
second
Ones marked with 🌟 are large PR-s, needing more reviewer effort. ⭐ are middle sized or need understanding of RDR to review. Ones without markers are small and should be easy to review without much knowledge of the feature.
Features not yet implemented, but should be done before stabilization
impl PublicTrait for PrivateStructtrait impls from the public hash, wherePublicTraitandPrivateStructare defined in the local crateTrait impls in a public api hash are partially done. Its current state:
review the hashing of the remaining metadata fields. The current set of supported fields work for the frequently changing parts of most crates, but the metadata fields left without attention should be checked and documented
Adjust documentation (see instructions on rustc-dev-guide)
Stabilization PR (see instructions on rustc-dev-guide)
Raise awareness of the feature. Rust is still known for its slow compile times. It will still be far from optimal, but RDR is a significant improvement for large projects, which could help start shifting that narrative.
Unresolved Questions
Span sensitivity
Spans are part of the public api. Which has the unfortuante consequence that changing the span of public items (a simple operation like editing the body of a function moves the end of its span, editing its doc comment also moves it) will cause rebuild in dependants. Errors and warnings produced by dependants rely heavily on spans, and debug info also uses it (a bit differently, debug info only needs the line numbers, while diagnostics produced also read and emit the source code covered by the spans).
Span insensitivity would enable other public api hash optimizations which don't make sense without it:
There are multiple avenues for exploration:
cargo check, which does not generate debug info.v0 symbol mangling changes
Current v0 symbol mangling disambiguator does not work well with RDR. It uses a per crate global index based on the number of symbols in the crate. The symbol disambiguator part should be reworked to make them compatible. Currently, v0 symbol mangling panics when public api hashing is enabled in any dependency.
Implementation history