mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Dependency Scanning] Do not track source module dependencies separately in SwiftDependencyScanningService
Instead, treat them like any other module that is specific to the scanning context hash of the scan it originates from. Otherwise we may actually have simultaneous scans happening for the same source module but with different context hashes, and the current scheme leads to collisions.
This commit is contained in:
@@ -386,7 +386,8 @@ bool ModuleDependenciesCacheDeserializer::readGraph(SwiftDependencyScanningServi
|
||||
for (const auto &mod : *bridgingModuleDeps)
|
||||
moduleDep.addBridgingModuleDependency(mod, alreadyAdded);
|
||||
|
||||
cache.recordSourceDependency(currentModuleName, std::move(moduleDep));
|
||||
cache.recordDependency(currentModuleName, std::move(moduleDep),
|
||||
getContextHash());
|
||||
hasCurrentModule = false;
|
||||
break;
|
||||
}
|
||||
@@ -991,37 +992,9 @@ unsigned ModuleDependenciesCacheSerializer::getArrayID(ModuleDependencyID module
|
||||
|
||||
void ModuleDependenciesCacheSerializer::collectStringsAndArrays(
|
||||
const SwiftDependencyScanningService &cache) {
|
||||
for (auto &moduleID : cache.getAllSourceModules()) {
|
||||
assert(moduleID.second == ModuleDependencyKind::SwiftSource &&
|
||||
"Expected source-based dependency");
|
||||
auto optionalDependencyInfo =
|
||||
cache.findSourceModuleDependency(moduleID.first);
|
||||
assert(optionalDependencyInfo.has_value() && "Expected dependency info.");
|
||||
auto dependencyInfo = optionalDependencyInfo.value();
|
||||
// Add the module's name
|
||||
addIdentifier(moduleID.first);
|
||||
// Add the module's dependencies
|
||||
addStringArray(moduleID, ModuleIdentifierArrayKind::DependencyImports,
|
||||
dependencyInfo->getModuleImports());
|
||||
addDependencyIDArray(moduleID, ModuleIdentifierArrayKind::QualifiedModuleDependencyIDs,
|
||||
dependencyInfo->getModuleDependencies());
|
||||
auto swiftSourceDeps = dependencyInfo->getAsSwiftSourceModule();
|
||||
assert(swiftSourceDeps);
|
||||
addStringArray(moduleID, ModuleIdentifierArrayKind::ExtraPCMArgs,
|
||||
swiftSourceDeps->textualModuleDetails.extraPCMArgs);
|
||||
if (swiftSourceDeps->textualModuleDetails.bridgingHeaderFile.has_value())
|
||||
addIdentifier(swiftSourceDeps->textualModuleDetails.bridgingHeaderFile.value());
|
||||
addStringArray(moduleID, ModuleIdentifierArrayKind::SourceFiles,
|
||||
swiftSourceDeps->sourceFiles);
|
||||
addStringArray(moduleID, ModuleIdentifierArrayKind::BridgingSourceFiles,
|
||||
swiftSourceDeps->textualModuleDetails.bridgingSourceFiles);
|
||||
addStringArray(moduleID, ModuleIdentifierArrayKind::BridgingModuleDependencies,
|
||||
swiftSourceDeps->textualModuleDetails.bridgingModuleDependencies);
|
||||
}
|
||||
|
||||
for (auto &contextHash : cache.getAllContextHashes()) {
|
||||
addIdentifier(contextHash);
|
||||
for (auto &moduleID : cache.getAllNonSourceModules(contextHash)) {
|
||||
for (auto &moduleID : cache.getAllModules(contextHash)) {
|
||||
auto optionalDependencyInfo = cache.findDependency(moduleID.first,
|
||||
moduleID.second,
|
||||
contextHash);
|
||||
@@ -1078,6 +1051,21 @@ void ModuleDependenciesCacheSerializer::collectStringsAndArrays(
|
||||
addIdentifier(swiftPHDeps->sourceInfoPath);
|
||||
break;
|
||||
}
|
||||
case swift::ModuleDependencyKind::SwiftSource: {
|
||||
auto swiftSourceDeps = dependencyInfo->getAsSwiftSourceModule();
|
||||
assert(swiftSourceDeps);
|
||||
addStringArray(moduleID, ModuleIdentifierArrayKind::ExtraPCMArgs,
|
||||
swiftSourceDeps->textualModuleDetails.extraPCMArgs);
|
||||
if (swiftSourceDeps->textualModuleDetails.bridgingHeaderFile.has_value())
|
||||
addIdentifier(swiftSourceDeps->textualModuleDetails.bridgingHeaderFile.value());
|
||||
addStringArray(moduleID, ModuleIdentifierArrayKind::SourceFiles,
|
||||
swiftSourceDeps->sourceFiles);
|
||||
addStringArray(moduleID, ModuleIdentifierArrayKind::BridgingSourceFiles,
|
||||
swiftSourceDeps->textualModuleDetails.bridgingSourceFiles);
|
||||
addStringArray(moduleID, ModuleIdentifierArrayKind::BridgingModuleDependencies,
|
||||
swiftSourceDeps->textualModuleDetails.bridgingModuleDependencies);
|
||||
break;
|
||||
}
|
||||
case swift::ModuleDependencyKind::Clang: {
|
||||
auto clangDeps = dependencyInfo->getAsClangModule();
|
||||
assert(clangDeps);
|
||||
@@ -1135,17 +1123,8 @@ void ModuleDependenciesCacheSerializer::writeInterModuleDependenciesCache(
|
||||
writeArraysOfIdentifiers();
|
||||
|
||||
// Write the core graph
|
||||
// First, write the source modules we've encountered
|
||||
for (auto &moduleID : cache.getAllSourceModules()) {
|
||||
auto dependencyInfo = cache.findSourceModuleDependency(moduleID.first);
|
||||
assert(dependencyInfo.has_value() && "Expected dependency info.");
|
||||
writeModuleInfo(moduleID, llvm::Optional<std::string>(), **dependencyInfo);
|
||||
}
|
||||
|
||||
// Write all non-source modules, for each of the context hashes this scanner
|
||||
// has been used with
|
||||
for (auto &contextHash : cache.getAllContextHashes()) {
|
||||
for (auto &moduleID : cache.getAllNonSourceModules(contextHash)) {
|
||||
for (auto &moduleID : cache.getAllModules(contextHash)) {
|
||||
auto dependencyInfo = cache.findDependency(moduleID.first,
|
||||
moduleID.second,
|
||||
contextHash);
|
||||
|
||||
Reference in New Issue
Block a user