-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[C++Interop] Do not query C++ Standard Library Swift overlays when building Swift modules which were built without C++ interop #81908
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
[C++Interop] Do not query C++ Standard Library Swift overlays when building Swift modules which were built without C++ interop #81908
Conversation
ab6839a
to
c40ea46
Compare
…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.
c40ea46
to
7075dcf
Compare
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function wise, LGTM.
lib/Frontend/CompilerInvocation.cpp
Outdated
@@ -737,7 +738,10 @@ void LangOptions::setCxxInteropFromArgs(ArgList &Args, | |||
// version, and is either 4, 5, 6, or 7 (even though only 5.9 and 6.* make | |||
// any sense). For now, we don't actually care about the version, so we'll | |||
// just use version 6 (i.e., 'swift-6') to mean that C++ interop mode is on. | |||
if (EnableCXXInterop) | |||
// | |||
// FIXME: Always declare the 'Darwin' module as formally having been built |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This FIXME
reads like this is something should be fixed to do, not what currently do that needs to be fixed. Also there is a separate check for Darwin
module name that probably also requires a FIXME
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'.
7075dcf
to
5b501ad
Compare
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@swift-ci test Linux platform |
Similarly to how this was fixed in #81415 in the Dependency Scanner for builds using Explicitly-Built modules, this change causes Implicitly-Built module code path to also forego querying Swift overlay
CxxStdlib
when the compiler is building a module with no declared "formal C++ interop mode".This change also temporarily hard-codes the
Darwin
module to always have no formal C++ interop mode, for the sake of compatibility withDarwin
Swift module textual interfaces which were constructed prior to the introduction of the-formal-cxx-interoperability-mode=
option.