utils: Pass linker flags to the Swift flags#88758
Conversation
|
@swift-ci please test windows platform |
|
@swift-ci please build toolchain windows platform |
|
We've been working around this for a while for Android too: do you know if the CMake devs are going to fix this? It doesn't make sense to pass in arbitrary linker flags to all languages' compilers, as they do with Swift. I know @compnerd filed an issue for it back then, but not sure what happened after. |
There was a behavior change in CMake 3.30, where CMake started passing Regarding Android, the NDK ends up setting linker flags "the wrong way". You can take a look at the current state of Going forward, for Android, I would suggest enabling the following:
For Android, you will also want some version of the workaround I mentioned above. I believe that once CMake 4.4 is released and the NDK files are updated to leverage CMP0181, we should be in a much better state. |
Starting with CMake 3.30+, CMAKE_SHARED_LINKER_FLAGS are passed to Swift targets. This is an undocumented behavior change from CMake 3.29. However, the same does not apply to CMAKE_EXE_LINKER_FLAGS, which are only supported with CMake 4.4+ and CMP0214. In order to work around these issues and keep the handling of linker arguments consistent, this changes build.ps1 to also pass linker flags to the Swift flags, maintaining consistency. At worst, this results in duplicate linker arguments, which is not a problem in practice. This is a no-op when building with CMake 3.29.
d7634b9 to
89fb25a
Compare
Starting with CMake 3.30+, CMAKE_SHARED_LINKER_FLAGS are passed to Swift targets. This is an undocumented behavior change from CMake 3.29. However, the same does not apply to CMAKE_EXE_LINKER_FLAGS, which are only supported with CMake 4.4+ and CMP0214.
In order to work around these issues and keep the handling of linker arguments consistent, this changes build.ps1 to also pass linker flags to the Swift flags, maintaining consistency. At worst, this results in duplicate linker arguments, which is not a problem in practice.
This should be a no-op when building with CMake 3.29, which is what Swift CI uses. This fixes some build issues with CMake 3.30+.
No-op with CMake 3.29 and Swift CI. Should fix the last remaining issues with CMake 3.30+.
Local testing with CMake 3.29, 3.30 and 4.0 + CI.