-
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
Usage of --sysroot
may still be racy and/or allow false dependencies
#49
Comments
I have implemented a branch that removes Any objections to moving in that direction? If that is OK, the next question I have: Should I prototype a new flag in |
👍 from me!
👍 from me as well The name of |
I think this should be closed after rust-lang/cargo#7699? |
I've been leaving it open because |
Isn't that what #31 is, or am I missing something? |
Oh, good point, closing for #31. |
I'm realizing now that after we've implemented
--sysroot
that we may still be susceptible races where you can depend on a sysroot crate without actually declaring that you depend on it. Let's say that #5 has already been implemented, and you say you only depend oncore
, I think you could also depend onalloc
via the following:alloc
, but your crate fails to build.alloc
crate, however, did actually end up finish building by the time your crate received its error.cargo build
again.alloc
is linked into the sysrootextern crate alloc
, now "magically works"I think the problem here is that we're giving, via
--sysroot
, crates access to anything in the sysroot. Cargo doesn't actually have any control over what can be loaded from the sysroot. While this will probably only rarely come up in practice, I think we may want to strive to have Cargo have a more intrusive understanding of what crates are where in the sysroot.Assuming that #5 is implemented I think we'll have some sort of distinction between crates that have sysroot dependencies or not. For example your crate will either declare its sysroot dependencies explicitly, or you won't say anything (like all crates do today) and we'll have some default behavior (like assuming you can use up to
proc_macro
). That puts us in one of two buckets:--sysroot
. We instead use--extern
always. This should be fine since the feature isn't implemented yet! If you're building in-Zbuild-std
mode Cargo has a path to pass, otherwise Cargo uses--extern std
to activate the name resolution logic to work the same as if--extern name=path
was passed.--extern-sysroot
flag to point to the compiled crates. This has the same name resolution logic that sysroot crates have today (wrt shadowing via macros and stuff like that).The invented
--extern-sysroot
flag here would take the form--extern-sysroot name=path
. In all cases Cargo would pass-L dependency=...
for the sysroot, and the--extern
flags would configure which crates can be loaded from the sysroot. The only reason for--extern-sysroot
to exist is to match the name resolution behavior of sysroot crates today since there are subtle differences. Alternatively we could fix rustc so there are no differences!The text was updated successfully, but these errors were encountered: