[Dependency Scanning] Re-enable querying Swift Overlays only for visible Clang modules

This change re-enables the new semantic of looking up Swift Overlay modules only for "visible" clang modules.
We have investigated the failures we were seeing with this change enabled and addressed them with project-side fixes.
This commit is contained in:
Artem Chikin
2025-08-20 16:04:29 -07:00
committed by Kathy Gray
parent 3011cc6077
commit 44f16a985b
2 changed files with 4 additions and 26 deletions

View File

@@ -563,23 +563,6 @@ ModuleDependencyScanner::ModuleDependencyScanner(
DependencyTracker, CAS, ActionCache, PrefixMapper.get(), Diagnostics));
}
/// Find all of the imported Clang modules starting with the given module name.
static void findAllImportedClangModules(StringRef moduleName,
const ModuleDependenciesCache &cache,
llvm::StringSet<> &allModules) {
if (!allModules.insert(moduleName).second)
return;
auto moduleID =
ModuleDependencyID{moduleName.str(), ModuleDependencyKind::Clang};
auto optionalDependencies = cache.findDependency(moduleID);
if (!optionalDependencies.has_value())
return;
for (const auto &dep : cache.getAllClangDependencies(moduleID))
findAllImportedClangModules(dep.ModuleName, cache, allModules);
}
static std::set<ModuleDependencyID>
collectBinarySwiftDeps(const ModuleDependenciesCache &cache) {
std::set<ModuleDependencyID> binarySwiftModuleDepIDs;
@@ -1467,11 +1450,7 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
ModuleDependencyIDSetVector &swiftOverlayDependencies) {
PrettyStackTraceStringAction trace(
"Resolving Swift Overlay dependencies of module", moduleID.ModuleName);
llvm::StringSet<> allClangDependencies;
// Find all of the discovered Clang modules that this module depends on.
for (const auto &dep : cache.getAllClangDependencies(moduleID))
findAllImportedClangModules(dep.ModuleName, cache, allClangDependencies);
auto visibleClangDependencies = cache.getVisibleClangModules(moduleID);
llvm::StringMap<SwiftModuleScannerQueryResult> swiftOverlayLookupResult;
std::mutex lookupResultLock;
@@ -1502,7 +1481,7 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
};
// Enque asynchronous lookup tasks
for (const auto &clangDep : allClangDependencies)
for (const auto &clangDep : visibleClangDependencies)
ScanningThreadPool.async(scanForSwiftDependency,
getModuleImportIdentifier(clangDep.getKey().str()));
ScanningThreadPool.wait();
@@ -1531,7 +1510,7 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
lookupResult.incompatibleCandidates, cache, std::nullopt);
}
};
for (const auto &clangDep : allClangDependencies)
for (const auto &clangDep : visibleClangDependencies)
recordResult(clangDep.getKey().str());
// C++ Interop requires additional handling
@@ -1564,7 +1543,7 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
lookupCxxStdLibOverlay = false;
if (lookupCxxStdLibOverlay) {
for (const auto &clangDepNameEntry : allClangDependencies) {
for (const auto &clangDepNameEntry : visibleClangDependencies) {
auto clangDepName = clangDepNameEntry.getKey().str();
// If this Clang module is a part of the C++ stdlib, and we haven't