mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[cxx-interop] Do not emit C++ interop flag in textual interfaces
This makes sure that the compiler does not emit `-enable-experimental-cxx-interop`/`-cxx-interoperability-mode` flags in `.swiftinterface` files. Those flags were breaking explicit module builds. The module can still be rebuilt from its textual interface if C++ interop was enabled in the current compilation. rdar://140203932
This commit is contained in:
@@ -2014,12 +2014,8 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
|
||||
GenericArgs.push_back(blocklist);
|
||||
}
|
||||
|
||||
// For now, we only inherit the C++ interoperability mode in
|
||||
// Explicit Module Builds.
|
||||
if (langOpts.EnableCXXInterop &&
|
||||
(frontendOpts.DisableImplicitModules ||
|
||||
LoaderOpts.requestedAction ==
|
||||
FrontendOptions::ActionType::ScanDependencies)) {
|
||||
// Inherit the C++ interoperability mode.
|
||||
if (langOpts.EnableCXXInterop) {
|
||||
// Modelled after a reverse of validateCxxInteropCompatibilityMode
|
||||
genericSubInvocation.getLangOptions().EnableCXXInterop = true;
|
||||
genericSubInvocation.getLangOptions().cxxInteropCompatVersion =
|
||||
@@ -2208,6 +2204,19 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
|
||||
BuildArgs.push_back("-module-name");
|
||||
BuildArgs.push_back(moduleName);
|
||||
|
||||
// FIXME: Hack for Darwin.swiftmodule, which cannot be rebuilt with C++
|
||||
// interop enabled by the Swift CI because it uses an old host SDK.
|
||||
if (moduleName == "Darwin") {
|
||||
subInvocation.getLangOptions().EnableCXXInterop = false;
|
||||
subInvocation.getLangOptions().cxxInteropCompatVersion = {};
|
||||
BuildArgs.erase(llvm::remove_if(BuildArgs,
|
||||
[](StringRef arg) -> bool {
|
||||
return arg.starts_with(
|
||||
"-cxx-interoperability-mode=");
|
||||
}),
|
||||
BuildArgs.end());
|
||||
}
|
||||
|
||||
// Calculate output path of the module.
|
||||
llvm::SmallString<256> buffer;
|
||||
StringRef CacheHash;
|
||||
|
||||
Reference in New Issue
Block a user