-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Allow running tests when stdlib is built with LTO by working around auto-linking #34975
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
Conversation
@swift-ci please test |
@swift-ci please test Windows platform |
# Auto-linking does not work when stdlib is built with LTO, because linked | ||
# libraries are discovered too late (after optimizations are applied). Let's | ||
# explicitly link all libraries needed in tests. | ||
if "stdlib_lto" in config.available_features: |
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 think that this really needs a comment explaining that this won't work on Linux (without LLD). The autolinking mechanism on Linux will fail due to needing -L
arguments to the path even with this forced linking as the extracted commands will force the linker to look up the linking by name as well.
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.
Can you expand on this a bit? I thought we're already passing in -L
to the resource dir. Why is Linux different from Darwin here? Forgive my ignorance, please :)
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 isn't the resource dir that is always the location for the library - the resource dir is meant for a small subset of libraries, those which are needed by the compiler directly (i.e. stdlib). The other libraries can be anywhere. The autolink only indicates that the library must be linked, not where to find it. The normal lookup order/path applies for the resolution of linked libraries, even when auto-linked. LLD will encode the -l...
just as much as what we do now, so ultimately, the normal linker search rules apply.
@swift-ci please test |
c398ef4
to
36e0bf4
Compare
@swift-ci please test |
Resurrecting this old PR, because the problem is still present. At least with ld64 (and possibly other linkers too?), auto-linking doesn't play well with LTO. I have requested fixes from the linker, but to unblock progress (towards enabling LTO on the stdlib on the "minimal" build preset) I'd like to propose to go forward with this workaround. @compnerd Any chance you could once more explain the Linux linking specifics here? For now, I have included your comment verbatim, but I don't really follow tbh 😃 |
Build failed |
@swift-ci please test |
@compnerd gentle ping :) |
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.
Discussed with @kubamracek offline; with some minor tweaks to the comment, this seems fine.
36e0bf4
to
6b7971c
Compare
@swift-ci please test |
@swift-ci please test Windows platform |
Build failed |
@swift-ci please test macOS platform |
I accidentally clicked "merge" before pushing the comment change, sorry about that 😞 Fixing that here: #39362 |
No description provided.