mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ScanDependency] Pass crossimport overlay file to swift-frontend
Teach dependency scanner to pass cross import overlay file to swift-frontend for main module compilation. This allows swift-frontend not to repeat the file system search for overlay files when loading modules. This also fixes the issue when caching is enabled, the cross import doesn't work when the first module is a clang module because the module built with caching using clang include tree does not preserve DefinitionLoc which is used to inferred the modulemap location for cross import overlay search. rdar://127844120
This commit is contained in:
@@ -800,7 +800,7 @@ void ModuleDependencyScanner::discoverCrossImportOverlayDependencies(
|
||||
llvm::function_ref<void(ModuleDependencyID)> action) {
|
||||
// Modules explicitly imported. Only these can be secondary module.
|
||||
llvm::SetVector<Identifier> newOverlays;
|
||||
std::vector<std::string> overlayFiles;
|
||||
std::vector<std::pair<std::string, std::string>> overlayFiles;
|
||||
for (auto dep : allDependencies) {
|
||||
auto moduleName = dep.ModuleName;
|
||||
// Do not look for overlays of main module under scan
|
||||
@@ -887,9 +887,15 @@ void ModuleDependencyScanner::discoverCrossImportOverlayDependencies(
|
||||
mainDep.addModuleDependency(crossImportOverlayModID);
|
||||
});
|
||||
|
||||
llvm::for_each(overlayFiles, [&mainDep](const std::string &file) {
|
||||
mainDep.addAuxiliaryFile(file);
|
||||
});
|
||||
auto cmdCopy = mainDep.getCommandline();
|
||||
cmdCopy.push_back("-disable-cross-import-overlay-search");
|
||||
for (auto &entry : overlayFiles) {
|
||||
mainDep.addAuxiliaryFile(entry.second);
|
||||
cmdCopy.push_back("-swift-module-cross-import");
|
||||
cmdCopy.push_back(entry.first);
|
||||
cmdCopy.push_back(entry.second);
|
||||
}
|
||||
mainDep.updateCommandLine(cmdCopy);
|
||||
|
||||
cache.updateDependency(
|
||||
{mainModuleName.str(), ModuleDependencyKind::SwiftSource}, mainDep);
|
||||
|
||||
Reference in New Issue
Block a user