-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Frontend] Add -public-autolink-library option #35936
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
[Frontend] Add -public-autolink-library option #35936
Conversation
5439d2b
to
bf8780b
Compare
@swift-ci please smoke test |
bf8780b
to
1a92574
Compare
@swift-ci please smoke test |
I've had the same issue on Android for the last couple months. |
To be clear, the issue for me is that once @drexin or @spevans, could one of you provide direction on this? |
1a92574
to
14266fa
Compare
`Foundation` imports `CoreFoundation` with `@_implementationOnly` as a private dependency, and it doesn't emit `IMPORTED_MODULE` in swiftmodule. Users of Foundation can link `libCoreFoundation.so` automatically when using dynamic linking because it's already linked into `libFoundation.so`. However, this automatic linking doesn't work when static linking, so users need to link CoreFoundation and dependent libraries of CoreFoundation explicitly by adding `-lCoreFoundation -lBlocksRuntime -licui18n`. To avoid forcing users to link private dependencies explicitly, this patch changed to merge the dependencies into libFoundation.a. And also to avoid forcing to link dependent libs of CoreFoundation like `curl` or `icui18n`, add `LINK_LIBRARY` entry in Foundation.swiftmodule using `-public-autolink-library` which is introduced by swiftlang/swift#35936
`Foundation` imports `CoreFoundation` with `@_implementationOnly` as a private dependency, and it doesn't emit `IMPORTED_MODULE` in swiftmodule. Users of Foundation can link `libCoreFoundation.so` automatically when using dynamic linking because it's already linked into `libFoundation.so`. However, this automatic linking doesn't work when static linking, so users need to link CoreFoundation and dependent libraries of CoreFoundation explicitly by adding `-lCoreFoundation -lBlocksRuntime -licui18n`. To avoid forcing users to link private dependencies explicitly, this patch changed to merge the dependencies into libFoundation.a. And also to avoid forcing to link dependent libs of CoreFoundation like `curl` or `icui18n`, add `LINK_LIBRARY` entry in Foundation.swiftmodule using `-public-autolink-library` which is introduced by swiftlang/swift#35936
@compnerd Could you take a look at this change? This feature is required for swiftlang/swift-corelibs-foundation#2996 |
@swift-ci please smoke test |
Please test with following PR: @swift-ci please test |
Build failed |
Could you re-run the CI again? 🙏 |
@swift-ci please smoke test |
@MaxDesiatov Thanks:) Could you re-trigger with PRs links in |
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hmm, ci bot is something wrong ? the GitHub PR status has not been updated 🤔 |
Please test with following pull request: @swift-ci Please test |
@compnerd Gentle ping :) And CI status is not updated, but they have been succeeded. |
This comment has been minimized.
This comment has been minimized.
1 similar comment
@swift-ci please test Windows platform |
Hi, @compnerd :) Could you take a look? |
14266fa
to
8ce7eea
Compare
@swift-ci please smoke test |
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.
This is an acceptable solution to an extremely tricky autolinking problem that I imagine we'll encounter in the future in even more exotic configurations than just the core libs.
Foundation imports CoreFoundation with @_implementationOnly, so CoreFoundation's modulemap won't be read, and the dependent libraries of CoreFoundation will not be automatically linked when using static linking. For example, CoreFoundation depends on libicui18n and it's modulemap has `link "icui18n"` statement. If Foundation imports CoreFoundation with @_implementationOnly as a private dependency, the toolchain doesn't have CoreFoundation's modulemap and Foundation's swiftmodule doesn't import CoreFoundation. So the swiftc can't know that libicui18n is required. This new option will add LINK_LIBRARY entry in swiftmodule to specify dependent libraries (in the example case, Foundation's swiftmodule should have LINK_LIBRARY entry of libicui18n)
8ce7eea
to
831facd
Compare
@swift-ci please smoke test |
Foundation imports CoreFoundation with
@_implementationOnly
,so CoreFoundation's modulemap won't be read, and the dependent libraries
of CoreFoundation will not be automatically linked when using static
linking.
For example, CoreFoundation depends on libicui18n and it's modulemap has
link "icui18n"
statement. If Foundation imports CoreFoundation with@_implementationOnly
as a private dependency, the toolchain doesn't haveCoreFoundation's modulemap and Foundation's swiftmodule doesn't import
CoreFoundation. So the swiftc can't know that libicui18n is required.
This new option will add LINK_LIBRARY entry in swiftmodule to
specify dependent libraries (in the example case, Foundation's
swiftmodule should have LINK_LIBRARY entry of libicui18n)
See also: Autolinking behavior of @_implementationOnly with static linking
CC: @compnerd