-
Notifications
You must be signed in to change notification settings - Fork 8
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
Plan for removal of rustc-dep-of-std
#51
Comments
So, my input on this: I work on a custom out-of-tree libstd for a very niche target (a custom OS I'm working on). As part of this, I pull quite a lot of dependencies. I currently use Xargo's multi-stage builds to avoid having to add a I'm definitely interested in a system that's "automatic" in the sense of not having to modify the Cargo.toml of my sub-dependencies. Is that something that's possible? |
Sounds great! Just keep in mind the use-case where previously rustc-specific crates migrate to crates.io. I think rather than patch stdlib deps to be normal deps, we should be patching normal deps to be stdlib deps, so for those future versions of the compiler we just drop the patch and the regular thing happens. |
My personal preference would be to pursue the "patch" syntax for this. For example the [patch.sysroot]
std = { path = "src/libstd" }
core = { path = "src/libcore" }
alloc = { path = "src/liballoc" }
# maybe not necessary, unsure
proc_macro = { path = "src/libproc_macro" }
test = { path = "src/libtest" } That way all crates.io crates with explicit deps would get rewrited to the I would prefer to avoid supporting a sort of magical "just match up the names in the crate graph" behavior because Cargo has largely avoided that sort of dependency matching, and I think that |
This means that we'd still have to modify every crates' Cargo.toml to give them an explicit |
My confusion around It might be nice for rustbuild to share the target directories, though I do not know what challenges there are there. Or maybe
I think a hypothetical |
That's an excellent point! My "ideal strategy" using @roblabla ah yeah I agree with @ehuss and it wouldn't require that everyone write out |
Looks good, are this on the road? |
Do we have the ability to write explicit standard library deps yet? I would think that the syntax for that and these overrides would go hand-in-hand. |
This issue is to discuss the strategy for removing the
rustc-dep-of-std
feature and therust-std-workspace-*
packages which allows standard library crates to use crates from crates.io. This is relatively low priority, but will be a nice-to-have once stdlib dependencies are supported (and possibly stabilized).Alex sketched out an outline at #27 (comment).
I have been working on explicit dependencies, so I've been thinking about this lately. Assuming Cargo has explicit stdlib dependencies, and they are stabilized, then these crates can be modified to use explicit stdlib dependencies instead of
rustc-dep-of-std
. When built under normal circumstances, Cargo will pass pathless--extern
flags to causerustc
to add those dependencies to the extern prelude, and rely on the resolver to load those crates from the sysroot. A complication with how rustbuild works remains: how will Cargo know what to do with these dependencies when building the standard library when there is no sysroot?There are a few approaches:
Use
build-std
Rustbuild would use the
build-std
mode of Cargo to build the standard library. It would somehow need to tell Cargo the location of the stdlib source (which is in the workspace root, not the sysroot). Cargo would also need to detect when it is building a std dependency to properly draw the dependency edge to the real thing. Rustbuild would also need a base package to build, since it needs something to kick it off. This could be an empty library.I'm not a big fan of this approach. Overall it seems messy, and much less flexible. I'm also not sure how features could be passed in to the standard library.
Normal build with
explicit-std
Rustbuild would do a build of the standard library the same way it does today. The only difference is that it needs to tell Cargo that explicit stdlib dependencies shouldn't use the sysroot (since it is in the process of building it). We instead want Cargo to pass
--extern core=deps/libcore.rlib
style options with the correct path.Some suggestions for how to tell Cargo to behave this way:
core
, andcore
is being built, draw a dependency edge to thecore
unit.build-std
mode. This does have an intriguing consequence that inbuild-std
mode, users could replace stdlib crates just by adding a normal dependency.build-std
could restrict the search to the std graph, and not the user graph, if that seems too wild.I'm enticed by the automatic option, since it "just works" and is relatively simple. Alex wasn't too enthusiastic when I mentioned it though 😜 .
The text was updated successfully, but these errors were encountered: