[Dependency Scanning][C++ Interop] Avoid 'CxxStdlib' overlay lookup for binary Swift dependencies which were not built with C++ interop

In addition to skipping it on textual Swift module dependencies which were built without C++ interop enabled, also skip it over similarly on binary Swift dependencies
This commit is contained in:
Artem Chikin
2025-08-04 17:34:50 -07:00
parent 3db1a66f08
commit 77a61a242f
7 changed files with 87 additions and 36 deletions

View File

@@ -1525,23 +1525,34 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
recordResult(clangDep.getKey().str());
// C++ Interop requires additional handling
bool lookupCxxStdLibOverlay = ScanCompilerInvocation.getLangOptions().EnableCXXInterop;
if (lookupCxxStdLibOverlay && moduleID.Kind == ModuleDependencyKind::SwiftInterface) {
bool lookupCxxStdLibOverlay =
ScanCompilerInvocation.getLangOptions().EnableCXXInterop;
if (lookupCxxStdLibOverlay &&
moduleID.Kind == ModuleDependencyKind::SwiftInterface) {
const auto &moduleInfo = cache.findKnownDependency(moduleID);
const auto commandLine = moduleInfo.getCommandline();
// If the textual interface was built without C++ interop, do not query
// the C++ Standard Library Swift overlay for its compilation.
//
// FIXME: We always declare the 'Darwin' module as formally having been built
// without C++Interop, for compatibility with prior versions. Once we are certain
// that we are only building against modules built with support of
// '-formal-cxx-interoperability-mode', this hard-coded check should be removed.
if (moduleID.ModuleName == "Darwin" ||
llvm::find(commandLine, "-formal-cxx-interoperability-mode=off") !=
commandLine.end())
if (llvm::find(commandLine, "-formal-cxx-interoperability-mode=off") !=
commandLine.end())
lookupCxxStdLibOverlay = false;
} else if (lookupCxxStdLibOverlay &&
moduleID.Kind == ModuleDependencyKind::SwiftBinary) {
const auto &moduleDetails =
cache.findKnownDependency(moduleID).getAsSwiftBinaryModule();
// If the binary module was built without C++ interop, do not query
// the C++ Standard Library Swift overlay.
if (!moduleDetails->isBuiltWithCxxInterop)
lookupCxxStdLibOverlay = false;
}
// FIXME: We always declare the 'Darwin' module as formally having been built
// without C++Interop, for compatibility with prior versions. Once we are certain
// that we are only building against modules built with support of
// '-formal-cxx-interoperability-mode', this hard-coded check should be removed.
if (lookupCxxStdLibOverlay && moduleID.ModuleName == "Darwin")
lookupCxxStdLibOverlay = false;
if (lookupCxxStdLibOverlay) {
for (const auto &clangDepNameEntry : visibleClangDependencies) {
auto clangDepName = clangDepNameEntry.getKey().str();