Description
Previous ID | SR-12654 |
Radar | rdar://problem/62895053 |
Original Reporter | @drexin |
Type | Bug |
Additional Detail from JIRA
Votes | 0 |
Component/s | |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: 90a0a1d903a4b0e681389f8b74697eb9
Issue Description:
I have been looking into static linking on Linux and discovered the when importing modules like Foundation or Dispatch, their dependencies are not (or only partially) included in the linker flags, causing the linking process to fail with missing symbols. I discovered several issues with the status quo:
1. Dispatch and Foundation are built differently for static and shared libraries. The shared libraries contain some (dispatch) or all (foundation) of the C object files in the resulting shared objects. In the static build however, there are separate static library files for CoreFoundation and DispatchStubs. The linker flags are included in the modulemap files, but the same modulemap is used for the shared and static builds, so the static builds are missing references to the libraries that do not exist as separate files in the shared build. This can easily be fixed by using separate modulemap files for the different build configurations.
2. swiftc does not read autolinking information from the libraries. In the IRGen, the modules that the current compilation unit references will be collected and passed to the linker, but the transitive dependencies (which are included in the library files in the `.swift1_autolink_` sections.
I think the correct way to fix this is the look up the libraries, read the autolinking information and include that in the resulting object files. Doing this would mean that all transitive dependencies would always be included in the resulting objects.