-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Transitive crate dependency resolution ignores metadata #2138
Comments
We actually need to know the exact version of dependencies of dependencies, and the real rules for making these resolve correctly is going to a bit more subtle than I can imagine just now. |
It should not be scanning metadata our resolving dependencies past the A -> B edge. The dependency from B to C was already resolved to a specific mangled library name during compilation of B, and the bound library name should be integrated (through hashing, along with the metadata of B) into the mangled library name of B. At least, if I understand this bug correctly. |
We need to know the exact version of C that B depends on at compile time because we have to load its metadata. Currently when compiling A, we see that C is crate 'foo' and then locate any crate called 'foo' to read the metadata from. What we really need to do is see that C is crate 'foo-HASH-VERSION' and locate that exact crate. |
I agree that crate B should export the fact that it depends on (Also, I thought lht did this stuff already, but I guess he only did transitive name-dependencies, not |
B doesn't need to reexport C's link metadata. I thought that it did originally. A need's C's metadata because B's public interface may refer to types (and maybe other things?) that live in C and that A needs to know about as well. |
Previously, I only implemented transitive hash calculation.
Another thing is if B reexports types or functions from C, A needs C's metadata? |
Crate resolution and linking now works much better. Here's an example (from a test) of the kinds of things that we can do now:
|
One more thing left is checking hashes of indirect dependent crates. I'll work on this. And we may also avoid the glob search when finding dependents' dependent crates, given we now have hash and version information. |
Close this one after commiting 7d227f2. |
Adjust Miri to also require return places everywhere This is the miri side of rust-lang#96098 . It'll still need a bump to rust-version once the rust PR is merged, but the test suite passes against my local build of rustc.
We have crate A, B, and C, A depends on B and B depends on C. When building crate A rustc finds the library for crate B based on the metadata, then it goes through and finds all the dependencies of crate B, etc. Once it recurses and starts resolving dependencies of dependencies it stops doing any metadata matching and just looks for the name of the crate. This could easily result in situations where rustc loads the wrong crate.
To fix this we need to encode all the matched metadata for a crate's dependencies.
The text was updated successfully, but these errors were encountered: