@@ -468,7 +468,7 @@ ModuleDependencyScanner::getMainModuleDependencyInfo(ModuleDecl *mainModule) {
468468 // build command to main module to ensure frontend gets the same result.
469469 // This needs to happen after visiting all the top-level decls from all
470470 // SourceFiles.
471- auto buildArgs = mainDependencies.getCommandline ();
471+ std::vector<std::string> buildArgs = mainDependencies.getCommandline ();
472472 mainModule->getASTContext ().forEachCanImportVersionCheck (
473473 [&](StringRef moduleName, const llvm::VersionTuple &Version,
474474 const llvm::VersionTuple &UnderlyingVersion) {
@@ -1328,25 +1328,33 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
13281328 recordResult (clangDep);
13291329
13301330 // C++ Interop requires additional handling
1331- if (ScanCompilerInvocation.getLangOptions ().EnableCXXInterop ) {
1332- for (const auto &clangDepName : allClangDependencies) {
1333- // If this Clang module is a part of the C++ stdlib, and we haven't loaded
1334- // the overlay for it so far, it is a split libc++ module (e.g.
1335- // std_vector). Load the CxxStdlib overlay explicitly.
1336- const auto &clangDepInfo =
1337- cache.findDependency (clangDepName, ModuleDependencyKind::Clang)
1338- .value ()
1339- ->getAsClangModule ();
1340- if (importer::isCxxStdModule (clangDepName, clangDepInfo->IsSystem ) &&
1341- !swiftOverlayDependencies.contains (
1342- {clangDepName, ModuleDependencyKind::SwiftInterface}) &&
1343- !swiftOverlayDependencies.contains (
1344- {clangDepName, ModuleDependencyKind::SwiftBinary})) {
1345- ScanningThreadPool.async (
1346- scanForSwiftDependency,
1347- getModuleImportIdentifier (ScanASTContext.Id_CxxStdlib .str ()));
1348- ScanningThreadPool.wait ();
1349- recordResult (ScanASTContext.Id_CxxStdlib .str ().str ());
1331+ if (ScanCompilerInvocation.getLangOptions ().EnableCXXInterop &&
1332+ moduleID.Kind == ModuleDependencyKind::SwiftInterface) {
1333+ const auto &moduleInfo = cache.findKnownDependency (moduleID);
1334+ const auto commandLine = moduleInfo.getCommandline ();
1335+
1336+ // If the textual interface was built without C++ interop, do not query
1337+ // the C++ Standard Library Swift overlay for its compilation.
1338+ if (llvm::find (commandLine, " -formal-cxx-interoperability-mode=off" ) ==
1339+ commandLine.end ()) {
1340+ for (const auto &clangDepName : allClangDependencies) {
1341+ // If this Clang module is a part of the C++ stdlib, and we haven't
1342+ // loaded the overlay for it so far, it is a split libc++ module (e.g.
1343+ // std_vector). Load the CxxStdlib overlay explicitly.
1344+ const auto &clangDepInfo =
1345+ cache.findDependency (clangDepName, ModuleDependencyKind::Clang)
1346+ .value ()
1347+ ->getAsClangModule ();
1348+ if (importer::isCxxStdModule (clangDepName, clangDepInfo->IsSystem ) &&
1349+ !swiftOverlayDependencies.contains (
1350+ {clangDepName, ModuleDependencyKind::SwiftInterface}) &&
1351+ !swiftOverlayDependencies.contains (
1352+ {clangDepName, ModuleDependencyKind::SwiftBinary})) {
1353+ scanForSwiftDependency (
1354+ getModuleImportIdentifier (ScanASTContext.Id_CxxStdlib .str ()));
1355+ recordResult (ScanASTContext.Id_CxxStdlib .str ().str ());
1356+ break ;
1357+ }
13501358 }
13511359 }
13521360 }
@@ -1401,7 +1409,7 @@ void ModuleDependencyScanner::resolveCrossImportOverlayDependencies(
14011409 // Update the command-line on the main module to
14021410 // disable implicit cross-import overlay search.
14031411 auto mainDep = cache.findKnownDependency (actualMainID);
1404- auto cmdCopy = mainDep.getCommandline ();
1412+ std::vector<std::string> cmdCopy = mainDep.getCommandline ();
14051413 cmdCopy.push_back (" -disable-cross-import-overlay-search" );
14061414 for (auto &entry : overlayFiles) {
14071415 mainDep.addAuxiliaryFile (entry.second );
0 commit comments