-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Improve linking of crates with circular dependencies #69371
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @davidtwco (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
2a5cef8
to
59fab0d
Compare
r? @eddyb |
I am not familiar with r? @alexcrichton (who authored #49316) |
Thanks for the PR! I'm not sure I fully understand why the previous iteration was incorrect, though. Can you describe in more detail why Additionally, would it be possible to add a test to this PR? |
I don't know how to create small self contained test for this specific bug. |
The situation from #69368 as happening previously (highlighting only the most relevant language items / crates):
The |
Ah ok I think I see what's happening now, thanks for the explanation! FWIW the iteration is in reverse order so it's a bit different, but I think it's the same principle. With the current code nothing populates
Does this match the behavior you're seeing with the linker? Are we surrounding |
Your comment touches on another aspect that I think is incorrect, but the one Note that the order I described in the comment above is already the There is one additional bit of complexity to the whole story. When using Why the difference then? In the context of reproducer from the issue, the std |
d743775
to
6ae0ae3
Compare
Hm I don't understand what you mean by your previous comment being reversed, since It's true yes that if multiple Also sorry I'm not really understanding what you are saying when you're talking about additional complexity or the difference from the reproducer. I don't really understand how build-std factors into this (how it changes lang item requirements) nor do I understand what different is going on with panic runtimes that has such a large difference here. |
We visit alloc first, and std later. After all, the end of the group is set
I reproduced the issue without build-std and added a test case, it should be |
Oh sorry I'm getting mixed up in directions. Also thanks for the test! I'll try to poke around with that a bit locally. Hopefully one last question, though, why does std require a personality sometimes but not always? I'm not sure what's affecting that and why it's specifically an issue with build-std but not for precompiled binaries. |
The language item is considered missing in a crate if it is used but not In the build-std case, the std is built only as rlib, the panic_unwind crate Without build-std, the std does depend on panic_unwind and has no missing lang items. |
☔ The latest upstream changes (presumably #69570) made this pull request unmergeable. Please resolve the merge conflicts. |
6ae0ae3
to
9039320
Compare
@bors: r+ Ah right yes because we enable features as part of rustbuild which aren't enabled in build-std, thanks for the info! |
📌 Commit 9039320 has been approved by |
Improve linking of crates with circular dependencies Previously, the code responsible for handling the cycles between crates introduces through weak lang items, would keep a set of missing language items: * extending it with items missing from the current crate, * removing items provided by the current crate, * grouping the crates when the set changed from non-empty back to empty. This could produce incorrect results, if a lang item was missing from a crate that comes after the crate that provides it (in the loop iteration order). In that case the grouping would not take place. The changes here address this specific failure scenario by keeping track of two separate sets of crates. Those that are required to link successfully, and those that are available for linking. Verified using test case from #69368.
💔 Test failed - checks-azure |
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 |
Previously, the code responsible for handling the cycles between crates introduces through weak lang items, would keep a set of missing language items: * extending it with items missing from the current crate, * removing items provided by the current crate, * grouping the crates when the set changed from non-empty back to empty. This could produce incorrect results, if a lang item was missing from a crate that comes after the crate that provides it (in the loop iteration order). In that case the grouping would not take place. The changes here address this specific failure scenario by keeping track of two separate sets of crates. Those that are required to link successfully, and those that are available for linking. Verified using test case from 69368.
5858dd6
to
44dba79
Compare
@bors: r+ |
📌 Commit 44dba79 has been approved by |
☀️ Test successful - checks-azure |
Previously, the code responsible for handling the cycles between crates
introduces through weak lang items, would keep a set of missing language
items:
This could produce incorrect results, if a lang item was missing from a
crate that comes after the crate that provides it (in the loop iteration
order). In that case the grouping would not take place.
The changes here address this specific failure scenario by keeping track
of two separate sets of crates. Those that are required to link successfully,
and those that are available for linking.
Verified using test case from #69368.