Uh oh!
There was an error while loading. Please reload this page.
Improve linking of crates with circular dependencies - #69371
Conversation
rust-highfive
commented
Feb 22, 2020
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
59fab0dComparedavidtwco
commented
Feb 22, 2020
r? @eddyb |
eddyb
commented
Feb 24, 2020
I am not familiar with r? @alexcrichton (who authored #49316) |
alexcrichton
commented
Feb 25, 2020
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? |
tmiasko
commented
Feb 25, 2020
I don't know how to create small self contained test for this specific bug. |
tmiasko
commented
Feb 26, 2020
The situation from #69368 as happening previously (highlighting only the most relevant language items / crates):
The |
alexcrichton
commented
Feb 27, 2020
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 |
tmiasko
commented
Feb 27, 2020
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
6ae0ae3Comparealexcrichton
commented
Feb 28, 2020
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. |
tmiasko
commented
Feb 28, 2020
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 |
alexcrichton
commented
Feb 28, 2020
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. |
tmiasko
commented
Feb 28, 2020
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. |
bors
commented
Feb 29, 2020
☔ The latest upstream changes (presumably #69570) made this pull request unmergeable. Please resolve the merge conflicts. |
6ae0ae3 to
9039320Comparealexcrichton
commented
Mar 2, 2020
@bors: r+ Ah right yes because we enable features as part of rustbuild which aren't enabled in build-std, thanks for the info! |
bors
commented
Mar 2, 2020
📌 Commit 9039320 has been approved by |
bors
commented
Mar 3, 2020
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.
bors
commented
Mar 3, 2020
💔 Test failed - checks-azure |
rust-highfive
commented
Mar 3, 2020
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
44dba79Comparealexcrichton
commented
Mar 3, 2020
@bors: r+ |
bors
commented
Mar 3, 2020
📌 Commit 44dba79 has been approved by |
bors
commented
Mar 3, 2020
bors
commented
Mar 3, 2020
☀️ 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.