[ModuleInterface] Ignore adjacent swiftmodules from the Frameworks folder

Always use the swiftinterfaces of modules under the public Frameworks
folder in the SDK. Distributed swiftmodules are unreliable, they should
only be used as a local cache. Let's avoid them when possible.

rdar://92037292
This commit is contained in:
Alexis Laferrière
2022-04-20 10:40:39 -07:00
parent 2266a5705c
commit 3aebf2850d
2 changed files with 49 additions and 2 deletions

View File

@@ -651,10 +651,20 @@ class ModuleInterfaceLoaderImpl {
std::pair<std::string, std::string> getCompiledModuleCandidates() {
std::pair<std::string, std::string> result;
// Keep track of whether we should attempt to load a .swiftmodule adjacent
// to the .swiftinterface.
// Should we attempt to load a swiftmodule adjacent to the swiftinterface?
bool shouldLoadAdjacentModule = true;
// Don't use the adjacent swiftmodule for frameworks from the public
// Frameworks folder of the SDK.
SmallString<128> publicFrameworksPath;
llvm::sys::path::append(publicFrameworksPath,
ctx.SearchPathOpts.getSDKPath(),
"System", "Library", "Frameworks");
if (!ctx.SearchPathOpts.getSDKPath().empty() &&
modulePath.startswith(publicFrameworksPath)) {
shouldLoadAdjacentModule = false;
}
switch (loadMode) {
case ModuleLoadingMode::OnlyInterface:
// Always skip both the caches and adjacent modules, and always build the