-
Notifications
You must be signed in to change notification settings - Fork 129
Resolve duplicate crate dependencies (support multiple versions) #430
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
Resolve duplicate crate dependencies (support multiple versions) #430
Conversation
compiler/rustc_codegen_llvm/src/gotoc/mir_to_goto/context/goto_ctx.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_codegen_llvm/src/gotoc/mir_to_goto/context/goto_ctx.rs
Outdated
Show resolved
Hide resolved
2f75433 to
5948728
Compare
.gitignore
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need **
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just call this full_crate_name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to clone here? Or should we return &str?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this where this function belongs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could see an argument for either, where it's used for global names, or compiler/rustc_codegen_llvm/src/gotoc/mir_to_goto/utils/names.rs. Maybe the right thing is to move both the global name stuff and this to names.rs, thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens on mac?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the given command, it fails to find std:
error[E0463]: can't find crate for `std`
|
= note: the `x86_64-unknown-linux-gnu` target may not be installed
= help: consider downloading the target with `rustup target add x86_64-unknown-linux-gnu`
= help: consider building the standard library from source with `cargo build -Zbuild-std`
If you try to build std (using nightly), you hit ICE's within building std. This block to skip is copied from the Firecrackers regression test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does cargo rmc not work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it fails with:
rmc (dependencies) $ ./src/test/rmc-dependency-test/diamond-dependency/run-dependency-test.sh
ERROR: Unexpected number of json outputs: 5
It seems like the script for it assumes a single symbol table output, but here we get one per dependency and main.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets file a ticket for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e36b13f to
7f5d99e
Compare
danielsn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved modulo comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a useful helper function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, moved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a hack. We should note it as such, and have a tracking issue to do the right thing here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed and adding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we cache this one and not the other one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One we pull directly from MIR, the other will build from two parts. Maybe with the to_string in the first case it's the same, though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would there be an advantage to returning foo.x + foo.y so that upstream tests could assert on that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets file a ticket for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if we use the osx target here and build on mac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC it requires rebuilding the std lib on mac, which then fails. We can look at this again together.
Description of changes:
When building with Cargo RMC, you can run into name conflicts with global allocations if two different versions of a crate are pulled into dependencies.
There are two different problems that this PR addresses:
Global allocations
We should use the full crate name, including a mangled versioning info string, when naming allocations.
Example:
Before:
Name:
getrandom::alloc174Error:
After:
1vemgcjvp3r154gr::getrandom::alloc174Struct types
If the same struct is defined differently across versions of a crate, the C we generate has conflicts. This PR now adds the unique type ID, which differs across crates, to the type mangled name.
Before:
After:
mmap::GuestRegionMmap::3024063347542320770Resolved issues:
Resolves #429
Testing:
Added a new test that creates a diamond crate dependency, where two dependencies use different version of a crate with the same name. Run as its own script since it needs Cargo RMC.
Also manually running on a (private) codebase with this issue.
No.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.