-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Avoid declaring a fake dependency edge #68298
Conversation
To be honest I'm not super happy with this change - feels a bit ad-hoc and I worry it could change under us and we wouldn't notice. Not sure we can do better though. cc @petrochenkov as well |
Can you explain more how changing the order the files are printed should fix the issue? |
Oh, I was over eager in a refactor, the code should call next() on the iterator instead of pushing the whole iterator on. |
1b047ff
to
9457681
Compare
Fixed. |
I think an alternate solution, which may be more of an "at the source" fix, might be to avoid reading these files entirely? For example if we find I feel like this sort of route would protect against potential bugs where we don't say we depend on the |
I can try to experiment with that path -- I think @petrochenkov planned on trying to do so based on comments on the issue. I do think it's better :) |
12bdd0e
to
90ba750
Compare
Initial implementation for the proposed "at the source" change is up, though I've not run tests locally. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
This is what I wanted to do, basically. |
I've just realized that if the dependency is a proc macro, then in addition to its (Same applies to plugin dependencies, but |
I will refactor/correct the code as you've suggested. I believe it is indeed the case that we don't care about plugin dependencies (yet, at least). I will not try to solve that problem in this PR. |
90ba750
to
0f9f382
Compare
The failing test case (https://github.com/rust-lang/rust/blob/master/src/test/ui/rmeta-rpass.rs) appears to assert that when we find an rmeta and rlib in the linker path, we should prefer the rlib. I'm not sure why this is true. Per #10786, we would generally want this to be an error (as the metadata in the two files is incompatible), but I don't think we should load both -- I consider it in an unstable implementation detail which file is ultimately used if you have incompatible files. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
From the PR introducing the test it looks like just something to ensure that the behavior doesn't change in unnoticed way. |
0f9f382
to
0d0006b
Compare
I wanted to write some short overview of this situation and dependencies, perhaps this weekend. Right now if two versions of the "same library", e.g. "rmeta vs rlib" or "target vs host" in case of "dual proc macros" become unsynchronized, it's pretty much undefined behavior. |
Before r+'ing I'd like to get a confirmation from Cargo people that something like cargo check
modify lib.rs
cargo build won't produce unsynchronized rmeta (older) and rlib (newer) in the same directory. It looks like the disambiguators (like |
r=me otherwise |
When we're producing an rlib, we do not need anything more than an rmeta file for each of our dependencies (this is indeed utilized by Cargo for pipelining). Previously, we were still storing the paths of possible rlib/dylib crates, which meant that they could still plausibly be accessed. With -Zbinary-dep-depinfo, that meant that Cargo thought that rustc was using both the rlib and an (earlier emitted) rmeta, and so needed a recompile, as the rlib may have finished writing *after* compilation started (for more detail, see issue 68149). This commit changes metadata loading to not store the filepaths of dylib/rlib if we're going to end up creating an rlib only.
0d0006b
to
be663bf
Compare
Let's r? @alexcrichton then to hopefully resolve the Cargo question (or maybe @ehuss knows better, not sure :) |
@bors: r=petrochenkov Code here looks great to me, thanks!
I believe this is correct, due to all the trickiness involved In any case if I'm remembering incorrectly I suspect we'll figure out quickly! |
📌 Commit be663bf has been approved by |
@bors rollup=never to make sure we really figure out quickly. |
Avoid declaring a fake dependency edge When we're producing an rlib, we do not need anything more than an rmeta file for each of our dependencies (this is indeed utilized by Cargo for pipelining). Previously, we were still storing the paths of possible rlib/dylib crates, which meant that they could still plausibly be accessed. With -Zbinary-dep-depinfo, that meant that Cargo thought that rustc was using both the rlib and an (earlier emitted) rmeta, and so needed a recompile, as the rlib may have finished writing *after* compilation started (for more detail, see issue 68149). This commit changes metadata loading to not store the filepaths of dylib/rlib if we're going to end up creating an rlib only. Fixes #68149.
☀️ Test successful - checks-azure |
When we're producing an rlib, we do not need anything more than an rmeta file
for each of our dependencies (this is indeed utilized by Cargo for pipelining).
Previously, we were still storing the paths of possible rlib/dylib crates, which
meant that they could still plausibly be accessed. With -Zbinary-dep-depinfo,
that meant that Cargo thought that rustc was using both the rlib and an (earlier
emitted) rmeta, and so needed a recompile, as the rlib may have finished writing
after compilation started (for more detail, see issue 68149).
This commit changes metadata loading to not store the filepaths of dylib/rlib if
we're going to end up creating an rlib only.
Fixes #68149.