-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix autolink mechanism for static libraries on Linux #2996
Fix autolink mechanism for static libraries on Linux #2996
Conversation
9ceb356
to
fc0c1c8
Compare
When you have this working could you add an integration test into the https://github.com/apple/swift-integration-tests repository to catch any future regressions? Thanks. There are some example tests in |
@spevans Okey, I'll add a test case in the repo. Thanks for letting me know :) |
cc @compnerd |
`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
fc0c1c8
to
718159e
Compare
Please test with following PR: @swift-ci Please test |
swiftlang/swift#35936 has been merged into main branch, so there is no blocker to merge this. Please proceed review again 🙏 |
Gentle ping :) |
Resolve: [SR-14536] Importing FoundationNetworking with -static-stdlib is broken with missing symbols on Linux - Swift
Discussion: Autolinking behavior of @_implementationOnly with static linking - Development / Core Libraries - Swift Forums
Blocked by [Frontend] Add -public-autolink-library option by kateinoigakukun · Pull Request #35936 · apple/swiftOverview
Foundation
importsCoreFoundation
with@_implementationOnly
as a private dependency, and it doesn't emitIMPORTED_MODULE
in swiftmodule.Users of Foundation can link
libCoreFoundation.so
automatically when using dynamic linking because it's already linked intolibFoundation.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
oricui18n
, addLINK_LIBRARY
entry in Foundation.swiftmodule using-public-autolink-library
which is introduced by swiftlang/swift#35936