Skip to content

[6.2 🍒][C++Interop] Do not query C++ Standard Library Swift overlays when building Swift modules which were built without C++ interop #81912

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

Merged

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented Jun 2, 2025

Cherry-pick of #81908

…tual modules which were not built with c++interop

When the compiler is building a module without a defined formal C++ interop mode (e.g. building a textual interface which specifies it was built without C++ interop enabled), avoid looking up the C++ standard library Swift overlay for it. This is required for the case of the Darwin module, for example, which includes headers which map to C++ stdlib headers when the compiler is operating in C++ interop mode, but the C++ standard library Swift overlay module itself depends on 'Darwin', which results in a cycle. To resolve such situations, we can rely on the fact that Swift textual interfaces of modules which were not built with C++ interop must be able to build without importing the C++ standard library Swift overlay, so we avoid specifying it as a dependency for such modules. The primary source module, as well as Swift textual module dependencies which were built with C++ interop will continue getting a direct depedency of the 'CxxStdlib' Swift module.

This was previously fixed in the dependency scanner for explicitly-built modules in swiftlang#81415.
@artemcm artemcm added c++ interop Feature: Interoperability with C++ 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels Jun 2, 2025
@artemcm
Copy link
Contributor Author

artemcm commented Jun 2, 2025

@swift-ci test

Textual interfaces for 'Darwin' built with recent compilers specify that it is built witout C++ interop enabled. However, to ensure compatibility with versions of the 'Darwin' module built with older compilers, we hard-code this fact. This is required to break the module cycle that occurs when building the 'Darwin' module with C++ interop enabled, where the underlying 'Darwin' clang module depends on C++ standard library for which the compiler brings in the 'CxxStdlib' Swift overlay, which depends on 'Darwin'.
@artemcm artemcm force-pushed the FixImplicitBuildCXXInteropCycle_62 branch from ec16433 to 5749ef3 Compare June 2, 2025 21:18
@artemcm
Copy link
Contributor Author

artemcm commented Jun 2, 2025

@swift-ci test

@artemcm artemcm marked this pull request as ready for review June 2, 2025 21:19
@artemcm artemcm requested a review from a team as a code owner June 2, 2025 21:19
Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this to support using the textual interface of CxxStdlib without hitting cycles.

@artemcm artemcm enabled auto-merge June 3, 2025 00:30
@artemcm artemcm merged commit 784a506 into swiftlang:release/6.2 Jun 3, 2025
5 checks passed
@artemcm artemcm deleted the FixImplicitBuildCXXInteropCycle_62 branch June 3, 2025 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++ 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants