-
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
linker: Never use whole-archive linking unless explicitly requested #85144
Conversation
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
Interesting, I haven't observed any errors on a full |
This comment has been minimized.
This comment has been minimized.
FWIW LLD shows even more missing symbols:
|
@petrochenkov I'm not a good reviewer for this. Any idea who might be better? |
r? @bjorn3 I guess I obviously made some wrong assumptions about dylibs and I need to figure out what exactly I got wrong, but I wasn't able to get to this PR since May for prioritization reasons, so this PR is pretty far from needing a review right now. |
The job Click to see the possible cause of the failure (guessed by this bot)
|
☔ The latest upstream changes (presumably #88227) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm going to close this for now. This PR contains two orthogonal changes:
|
Reminder: "whole-archive" linking for a static library means including all the object files from the library into the output binary instead only those that are needed ("needed" is determined by the current list of unresolved symbols).
We have two automatic uses of whole-archive right now.
The use of whole-archive in this case is pretty random and inconsistent, and also entirely unnecessary in regular cases.
Moreover, when whole-archive was properly implemented for MSVC targets in linker: MSVC supports linking static libraries as a whole archive #72785 it caused regressions (see links to other issues from that PR).
The comment tells that it's done because "
dylib
can be reused as an intermediate artifact", perhaps it was necessary in the past, but now it shouldn't be necessary because everything usable from a dylib should be already kept alive by export lists (fn export_symbols
).I wanted to land this sooner in the release cycle in case I'm missing something and there are regressions.
However, it may also make sense to land this together with stabilizing the
+whole-archive
linking modifier (#81490) to make sure there's a fix available on stable in cases wherewhole-archive
was actually required in one these specific situations (which should be a rare case).