[Dependency Scanning] Resolve cross-import overlays relative to defining interface for prebuilt binary Swift dependencies

When the dependency scanner picks a pre-built binary module candidate for a given dependency, it needs to be able to attempt to resolve its cross-import overlays relative to the textual interface that the binary module was built from. For example, if a collection of binary modules are located in, and resolved as dependencies from, a pre-built module directory, the scanner must lookup their corresponding cross-import overlays relative to the defining interface as read out from the binary module's MODULE_INTERFACE_PATH. https://github.com/swiftlang/swift/pull/70817 ensures that binary modules serialize the path to their defining textual interface.

Resolves rdar://130778577
This commit is contained in:
Artem Chikin
2024-07-02 15:50:55 -07:00
committed by artemcm
parent 1fde4c1267
commit 2464f87f8f
9 changed files with 134 additions and 27 deletions

View File

@@ -511,11 +511,16 @@ SerializedModuleLoaderBase::scanModuleFile(Twine modulePath, bool isFramework,
LibraryKind::Framework));
}
// Attempt to resolve the module's defining .swiftinterface path
std::string definingModulePath =
loadedModuleFile->resolveModuleDefiningFilePath(Ctx.SearchPathOpts.getSDKPath());
// Map the set of dependencies over to the "module dependencies".
auto dependencies = ModuleDependencyInfo::forSwiftBinaryModule(
modulePath.str(), moduleDocPath, sourceInfoPath, moduleImports,
optionalModuleImports, linkLibraries, importedHeader, isFramework,
loadedModuleFile->isStaticLibrary(), /*module-cache-key*/ "");
optionalModuleImports, linkLibraries, importedHeader,
definingModulePath, isFramework, loadedModuleFile->isStaticLibrary(),
/*module-cache-key*/ "");
return std::move(dependencies);
}