mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Dependency Scanning] Scan header inputs of binary Swift moduel dependencies
Otherwise they may have module dependencies of their own which will not be detected by the scanner and included in the list of explicit inputs for compilation.
This commit is contained in:
@@ -324,7 +324,7 @@ bool ModuleDependenciesCacheDeserializer::readGraph(SwiftDependencyScanningServi
|
||||
if (!bridgingSourceFiles)
|
||||
llvm::report_fatal_error("Bad bridging source files");
|
||||
for (const auto &file : *bridgingSourceFiles)
|
||||
moduleDep.addBridgingSourceFile(file);
|
||||
moduleDep.addHeaderSourceFile(file);
|
||||
|
||||
// Add source files
|
||||
auto sourceFiles = getStringArray(sourceFilesArrayID);
|
||||
@@ -338,8 +338,8 @@ bool ModuleDependenciesCacheDeserializer::readGraph(SwiftDependencyScanningServi
|
||||
if (!bridgingModuleDeps)
|
||||
llvm::report_fatal_error("Bad bridging module dependencies");
|
||||
llvm::StringSet<> alreadyAdded;
|
||||
for (const auto &mod : *bridgingModuleDeps)
|
||||
moduleDep.addBridgingModuleDependency(mod, alreadyAdded);
|
||||
for (const auto &mod : bridgingModuleDeps.value())
|
||||
moduleDep.addHeaderInputModuleDependency(mod, alreadyAdded);
|
||||
|
||||
// Add Swift overlay dependencies
|
||||
auto overlayModuleDependencyIDs = getModuleDependencyIDArray(overlayDependencyIDArrayID);
|
||||
@@ -432,7 +432,7 @@ bool ModuleDependenciesCacheDeserializer::readGraph(SwiftDependencyScanningServi
|
||||
if (!bridgingSourceFiles)
|
||||
llvm::report_fatal_error("Bad bridging source files");
|
||||
for (const auto &file : *bridgingSourceFiles)
|
||||
moduleDep.addBridgingSourceFile(file);
|
||||
moduleDep.addHeaderSourceFile(file);
|
||||
|
||||
// Add source files
|
||||
auto sourceFiles = getStringArray(sourceFilesArrayID);
|
||||
@@ -447,7 +447,7 @@ bool ModuleDependenciesCacheDeserializer::readGraph(SwiftDependencyScanningServi
|
||||
llvm::report_fatal_error("Bad bridging module dependencies");
|
||||
llvm::StringSet<> alreadyAdded;
|
||||
for (const auto &mod : *bridgingModuleDeps)
|
||||
moduleDep.addBridgingModuleDependency(mod, alreadyAdded);
|
||||
moduleDep.addHeaderInputModuleDependency(mod, alreadyAdded);
|
||||
|
||||
// Add Swift overlay dependencies
|
||||
auto overlayModuleDependencyIDs = getModuleDependencyIDArray(overlayDependencyIDArrayID);
|
||||
@@ -475,12 +475,15 @@ bool ModuleDependenciesCacheDeserializer::readGraph(SwiftDependencyScanningServi
|
||||
"Unexpected SWIFT_BINARY_MODULE_DETAILS_NODE record");
|
||||
cache.configureForContextHash(getContextHash());
|
||||
unsigned compiledModulePathID, moduleDocPathID, moduleSourceInfoPathID,
|
||||
overlayDependencyIDArrayID, headerImportsArrayID, isFramework,
|
||||
overlayDependencyIDArrayID, headerImportID,
|
||||
headerModuleDependenciesArrayID,
|
||||
headerImportsSourceFilesArrayID, isFramework,
|
||||
moduleCacheKeyID;
|
||||
SwiftBinaryModuleDetailsLayout::readRecord(
|
||||
Scratch, compiledModulePathID, moduleDocPathID,
|
||||
moduleSourceInfoPathID, overlayDependencyIDArrayID,
|
||||
headerImportsArrayID, isFramework, moduleCacheKeyID);
|
||||
headerImportID, headerModuleDependenciesArrayID,
|
||||
headerImportsSourceFilesArrayID, isFramework, moduleCacheKeyID);
|
||||
|
||||
auto compiledModulePath = getIdentifier(compiledModulePathID);
|
||||
if (!compiledModulePath)
|
||||
@@ -494,22 +497,34 @@ bool ModuleDependenciesCacheDeserializer::readGraph(SwiftDependencyScanningServi
|
||||
auto moduleCacheKey = getIdentifier(moduleCacheKeyID);
|
||||
if (!moduleCacheKey)
|
||||
llvm::report_fatal_error("Bad moduleCacheKey");
|
||||
|
||||
auto headerImports = getStringArray(headerImportsArrayID);
|
||||
if (!headerImports)
|
||||
llvm::report_fatal_error("Bad binary direct dependencies: no header imports");
|
||||
auto headerImport = getIdentifier(headerImportID);
|
||||
if (!headerImport)
|
||||
llvm::report_fatal_error("Bad binary direct dependencies: no header import");
|
||||
|
||||
// Form the dependencies storage object
|
||||
auto moduleDep = ModuleDependencyInfo::forSwiftBinaryModule(
|
||||
*compiledModulePath, *moduleDocPath, *moduleSourceInfoPath,
|
||||
*currentModuleImports, *currentOptionalModuleImports,
|
||||
*headerImports, isFramework, *moduleCacheKey);
|
||||
*headerImport, isFramework, *moduleCacheKey);
|
||||
|
||||
auto headerModuleDependencies = getStringArray(headerModuleDependenciesArrayID);
|
||||
if (!headerModuleDependencies)
|
||||
llvm::report_fatal_error("Bad binary direct dependencies: no header import module dependencies");
|
||||
llvm::StringSet<> alreadyAdded;
|
||||
for (const auto &dep : *headerModuleDependencies)
|
||||
moduleDep.addHeaderInputModuleDependency(dep, alreadyAdded);
|
||||
|
||||
auto headerImportsSourceFiles = getStringArray(headerImportsSourceFilesArrayID);
|
||||
if (!headerImportsSourceFiles)
|
||||
llvm::report_fatal_error("Bad binary direct dependencies: no header import source files");
|
||||
for (const auto &depSource : *headerImportsSourceFiles)
|
||||
moduleDep.addHeaderSourceFile(depSource);
|
||||
|
||||
// Add Swift overlay dependencies
|
||||
auto overlayModuleDependencyIDs = getModuleDependencyIDArray(overlayDependencyIDArrayID);
|
||||
if (!overlayModuleDependencyIDs.has_value())
|
||||
llvm::report_fatal_error("Bad overlay dependencies: no qualified dependencies");
|
||||
moduleDep.setOverlayDependencies(overlayModuleDependencyIDs.value());
|
||||
moduleDep.setOverlayDependencies(*overlayModuleDependencyIDs);
|
||||
|
||||
cache.recordDependency(currentModuleName, std::move(moduleDep),
|
||||
getContextHash());
|
||||
@@ -746,6 +761,8 @@ enum ModuleIdentifierArrayKind : uint8_t {
|
||||
SourceFiles,
|
||||
BridgingSourceFiles,
|
||||
BridgingModuleDependencies,
|
||||
HeaderInputDependencySourceFiles,
|
||||
HeaderInputModuleDependencies,
|
||||
SwiftOverlayDependencyIDs,
|
||||
BridgingHeaderBuildCommandLine,
|
||||
NonPathCommandLine,
|
||||
@@ -1013,6 +1030,8 @@ void ModuleDependenciesCacheSerializer::writeModuleInfo(
|
||||
getIdentifier(swiftBinDeps->sourceInfoPath),
|
||||
getArrayID(moduleID, ModuleIdentifierArrayKind::SwiftOverlayDependencyIDs),
|
||||
getArrayID(moduleID, ModuleIdentifierArrayKind::DependencyHeaders),
|
||||
getArrayID(moduleID, ModuleIdentifierArrayKind::HeaderInputModuleDependencies),
|
||||
getArrayID(moduleID, ModuleIdentifierArrayKind::HeaderInputDependencySourceFiles),
|
||||
swiftBinDeps->isFramework,
|
||||
getIdentifier(swiftBinDeps->moduleCacheKey));
|
||||
|
||||
@@ -1193,8 +1212,11 @@ void ModuleDependenciesCacheSerializer::collectStringsAndArrays(
|
||||
addIdentifier(swiftBinDeps->moduleDocPath);
|
||||
addIdentifier(swiftBinDeps->sourceInfoPath);
|
||||
addIdentifier(swiftBinDeps->moduleCacheKey);
|
||||
addStringArray(moduleID, ModuleIdentifierArrayKind::DependencyHeaders,
|
||||
swiftBinDeps->preCompiledBridgingHeaderPaths);
|
||||
addIdentifier(swiftBinDeps->headerImport);
|
||||
addStringArray(moduleID, ModuleIdentifierArrayKind::HeaderInputModuleDependencies,
|
||||
swiftBinDeps->headerModuleDependencies);
|
||||
addStringArray(moduleID, ModuleIdentifierArrayKind::HeaderInputDependencySourceFiles,
|
||||
swiftBinDeps->headerSourceFiles);
|
||||
addDependencyIDArray(
|
||||
moduleID, ModuleIdentifierArrayKind::SwiftOverlayDependencyIDs,
|
||||
swiftBinDeps->swiftOverlayDependencies);
|
||||
|
||||
Reference in New Issue
Block a user