Skip to content

-Z build-std with unified workspace #64

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

Open
Ericson2314 opened this issue Jan 19, 2021 · 3 comments
Open

-Z build-std with unified workspace #64

Ericson2314 opened this issue Jan 19, 2021 · 3 comments

Comments

@Ericson2314
Copy link

If I'm not misreading the Cargo code:

  • We currently have separate workspace for the user's project std
  • We resolve them separately and then combine the unit graphs

I don't think this is a good approach, long term:

Conversely, we might inject the crates and (explicit and implicit) stdlib deps to create a unified workspace. We would also combine the lock files to create a lockfile for the combined workspace with the materialized. Now, this will be a bunch of work up front, but I think it comes with a bunch of benefits:

  • It's not adding expressive power: one could also manually combine the workspace, lockfile, and add the stdlib deps and then run Cargo on it. This means no new code paths downstream of the workspace combination.
  • Since everything is resolved at once, std features affected by project crate features

I also wonder if it might help with #23 (comment). Combining the workspaces and lockfiles is also a "big global change", so maybe it's OK to use source for mirroring just in that case?

@lygstate
Copy link

What's the plan to stablize -Z build-std?

@Ericson2314
Copy link
Author

Hopefully not until these changes are done...

@adamgemmell
Copy link

This was discussed at length on Zulip. The crux of the issue is that because the standard library's crates.io dependencies can use nightly features (often hidden behind a Cargo feature flag), their versions cannot be changed. Currently the Cargo resolver does not allow conflicting versions of a dependency (different semvers with the same major version) in the same resolve - meaning any shared dependencies would have to be locked to the standard library's version.

The general reason for this restriction is that types defined in different versions of the same dependency are considered different types and are not interchangeable. However, the standard library does not actually leak types defined in its dependencies and all types in its API are its own. This means this restriction could be lifted somewhat for std's dependencies. std's dependencies could be classed as Private Dependencies which seems like the best way to make these resolve changes more generalised.

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

No branches or pull requests

3 participants