-
Notifications
You must be signed in to change notification settings - Fork 69
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
Add a new --orchestrator-id
flag to rustc
#635
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed. cc @rust-lang/compiler @rust-lang/compiler-contributors |
Given that this is a user visible flag (otherwise I'd just second): @rfcbot fcp merge |
Team member @estebank has proposed to merge this. The next step is review by the rest of the tagged team members:
Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
@rfcbot concern other-existing-options The zulip thread lists some alternatives like One alternative, for example, is making |
(I'm checking my box under the assumption that the implementation of this MCP will explore leveraging an extension of @rfcbot reviewed |
@rfcbot concern option-name When reading the title, I assumed this was an flagthat would allow the user to choose what |
I don't think it makes sense to block this FCP on finding a mentor, unless you think the change to the compiler is so large that its acceptance should be conditional on finding someone to implement it (which seems out of the ordinary) -- IMO, the FCP is just for approval of the technical change. Also, the syntax is |
@compiler-errors fair point, sorry for the noise. Just wanted to be sure that that point was't forgotten. |
--build-id
flag to rustc--orchestrator-id
flag to rustc
I've updated the proposal to reflect the feedback above (and in Zulip).
|
I still don't understand what is the point of this, rustc is already able to identify crates uniquely. I'll remove my concern to unblock the experimentation, but the scenario that I'd prefer to see in the future is
@rfcbot resolve other-existing-options |
@rfcbot resolve option-name |
🔔 This is now entering its final comment period, as per the review above. 🔔 psst @estebank, I wasn't able to add the |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. psst @estebank, I wasn't able to add the |
@rustbot label -final-comment-period +major-change-accepted |
Proposal (Updated on 2024-09-06)
Context
The JSON documentation for a crate often refers to items (e.g. functions, traits, types, etc.) defined in one or more its dependencies, either direct or transitive.
This can happen in a variety of scenarios:
Problem
The JSON documentation for a crate doesn't provide many details when it comes to foreign items. If you want to dig deeper, you must generate the JSON documentation for the crate where they are defined and then combine the information from those two JSON documents to get a complete picture1.
In other words, you need to walk the dependency graph to perform analyses where foreign items are in scope.
To walk the graph, you need to go from "I have this foreign item" to "here's the JSON documentation for crate X, where that item was defined".
This is the difficult part: the JSON documentation for a crate contains very little information about third party crates. In particular, it only reports their names and the root URLs to their docs.
In the simplest scenario, that's not a problem: the crate name is enough to generate the JSON documentation if there is only one instance of that crate in the dependency graph.
It becomes an issue when multiple versions of the same crate appear together in the same JSON document. There will be multiple entries in
external_crates
with the samename
, one for each version of that duplicated dependency.There is no bullet-proof mechanism to disambuigate between those entries and map them back to specific package entries in the dependency tree of the "root" crate2. That's the problem this MCP tries to solve.
The proposed solution
For
rustdoc
rustdoc
will provide an additional field inExternalCrate
, namedorchestrator_id
.orchestrator_id
will be of typeOption<String>
.orchestrator_id
will be (optionally) provided by the tool orchestrating the overall build. This will becargo
in the most common case, but it may as well be an alternative orchestrator (bazel
,buck2
, etc.). If an orchestrator decides to provide an id for each build unit, it must guarantee that those ids uniquely identify that unit within the dependency graph.For
cargo
cargo
will populate theorchestrator_id
field.The id will be a valid string for the
--package
flag incargo
(e.g.cargo rustdoc -p <build-id>
should always work). This will allow tool builders to walk the graph without ambiguity when working with JSON documentation.Implementation strategy
How would
rustdoc
receive thisorchestrator_id
, in practice?rustdoc
looks at thermeta
file to gather information about third party crates. We want to includeorchestrator_id
in that file to get it fromcargo
torustdoc
. This requiresrustc
to cooperate.Adding a new (unstable)
--orchestrator-id
option torustc
seems to be the simplest way forward.This could then be stabilised as is or, if preferred, moved to a different "channel" (e.g. as part of
-Cmetadata
, its own-C
flag, etc.).Mentors or Reviewers
A mentor would definitely be appreciated, I never touched any of the code involved here.
Process
The main points of the [Major Change Process][MCP] are as follows:
@rustbot second
.-C flag
, then full team check-off is required.@rfcbot fcp merge
on either the MCP or the PR.Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.
Notes
This proposal supercedes #622, incorporating the feedback and ideas that were surfaced in the associated Zulip stream.
Previous proposal, before first round of feedback
The problem
rustdoc
's JSON output for a crate must often refer to items (e.g. functions, traits, types, etc.) defined in one or more its dependencies.Very little information is captured about those dependencies: their name and the root URL to their docs.
This causes issues when multiple versions of the same crate appear as direct dependencies (e.g. via renames) of the crate we are documenting—e.g. it becomes impossible to find out where items are coming from.
The proposed solution
Add a
--build-id
flag torustc
.The value would be provided by
cargo
and then captured as part of the .rlib metadata, which would in turn make it available torustdoc
, as well as other parts of the compiler that might benefit from it (e.g. diagnostics, such as version mismatches which currently limit themselves toperhaps two different version of CRATE_NAME are being used?
).The provided
build-id
must:--package
flag incargo
(e.g.cargo rustdoc -p <build-id>
should always work). This allows toolmakers to fetch more information on-demand when working withrustdoc
's JSON output;Footnotes
This is an intentional design choice, that's been discussed at length in the
rustdoc
team and that's been endorsed by all JSON-based tool builders that interface with the team. ↩See this Zulip thread for more details. ↩
The text was updated successfully, but these errors were encountered: