Skip to content

Conversation

Steelskin
Copy link
Contributor

CMake 3.30 passes linker flags to the Swift invocation when it is used as the linker driver. However, Swift cannot parse the linker arguments, so they need to be passed with the -Xlinker prefix. This cannot be done uncondtionally as the same arguments are also used with the MSVC toolchain.
CMake 4.0 introduces the CMP0181 policy, which allows CMake to parse the LINKER: syntax on the linker flags passed on the command line, which simplifies handling of flags.

Note that building for Android still requires CMake 3.29 for the time being as we pass a linker driver argument to the CMake linker flags to override the linker used.

CMake 3.30 passes linker flags to the Swift invocation when it is used
as the linker driver. However, Swift cannot parse the linker arguments,
so they need to be passed with the `-Xlinker` prefix. This cannot be
done uncondtionally as the same arguments are also used with the MSVC
toolchain.
CMake 4.0 introduces the CMP0181 policy, which allows CMake to parse the
`LINKER:` syntax on the linker flags passed on the command line, which
simplifies handling of flags.

Note that building for Android still requires CMake 3.29 for the time
being as we pass a linker driver argument to the CMake linker flags to
override the linker used.
@Steelskin Steelskin requested review from a team and compnerd as code owners September 15, 2025 20:59
@Steelskin
Copy link
Contributor Author

@swift-ci please test windows platform

@Steelskin
Copy link
Contributor Author

@swift-ci please test windows platform

@Steelskin Steelskin requested a review from compnerd September 16, 2025 17:31
@Steelskin
Copy link
Contributor Author

@swift-ci please test linux platform

@Steelskin
Copy link
Contributor Author

@swift-ci please test macos platform

@Steelskin
Copy link
Contributor Author

@swift-ci please smoke test linux platform

@Steelskin
Copy link
Contributor Author

@swift-ci please smoke test macos platform

@Steelskin
Copy link
Contributor Author

@swift-ci please smoke test linux platform

1 similar comment
@Steelskin
Copy link
Contributor Author

@swift-ci please smoke test linux platform

@compnerd
Copy link
Member

@swift-ci please smoke test Linux platform

1 similar comment
@Steelskin
Copy link
Contributor Author

@swift-ci please smoke test Linux platform

@Steelskin
Copy link
Contributor Author

@swift-ci please test linux platform

@compnerd compnerd merged commit 841db27 into swiftlang:main Sep 23, 2025
5 checks passed
Steelskin pushed a commit to Steelskin/swift that referenced this pull request Oct 1, 2025
@Steelskin Steelskin deleted the fabrice/cmake-version-support branch October 9, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants