mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Frontend: Ignore resilient binary swiftmodules under usr/lib/swift
Most SDKs use only swiftinterfaces under usr/lib/swift. Let's make sure we standardize this behavior and use only swiftinterface when they are present, even if there are also binary swiftmodule files available. Apply the same logic to SubFrameworks as well while we're at it. rdar://145316821
This commit is contained in:
@@ -237,6 +237,7 @@ struct ModuleRebuildInfo {
|
||||
enum class ReasonIgnored {
|
||||
NotIgnored,
|
||||
PublicFramework,
|
||||
PublicLibrary,
|
||||
InterfacePreferred,
|
||||
CompilerHostModule,
|
||||
Blocklisted,
|
||||
@@ -762,6 +763,28 @@ class ModuleInterfaceLoaderImpl {
|
||||
return pathStartsWith(frameworksPath, path);
|
||||
}
|
||||
|
||||
bool isInSystemSubFrameworks(StringRef path) {
|
||||
StringRef sdkPath = ctx.SearchPathOpts.getSDKPath();
|
||||
if (sdkPath.empty()) return false;
|
||||
|
||||
SmallString<128> frameworksPath;
|
||||
llvm::sys::path::append(frameworksPath,
|
||||
sdkPath, "System", "Library", "SubFrameworks");
|
||||
|
||||
return pathStartsWith(frameworksPath, path);
|
||||
}
|
||||
|
||||
bool isInSystemLibraries(StringRef path) {
|
||||
StringRef sdkPath = ctx.SearchPathOpts.getSDKPath();
|
||||
if (sdkPath.empty()) return false;
|
||||
|
||||
SmallString<128> frameworksPath;
|
||||
llvm::sys::path::append(frameworksPath,
|
||||
sdkPath, "usr", "lib", "swift");
|
||||
|
||||
return pathStartsWith(frameworksPath, path);
|
||||
}
|
||||
|
||||
std::pair<std::string, std::string> getCompiledModuleCandidates() {
|
||||
using ReasonIgnored = ModuleRebuildInfo::ReasonIgnored;
|
||||
using ReasonModuleInterfaceIgnored =
|
||||
@@ -813,10 +836,15 @@ class ModuleInterfaceLoaderImpl {
|
||||
|
||||
// Don't use the adjacent swiftmodule for frameworks from the public
|
||||
// Frameworks folder of the SDK.
|
||||
if (isInSystemFrameworks(modulePath, /*publicFramework*/true)) {
|
||||
if (isInSystemFrameworks(modulePath, /*publicFramework*/true) ||
|
||||
isInSystemSubFrameworks(modulePath)) {
|
||||
shouldLoadAdjacentModule = false;
|
||||
rebuildInfo.addIgnoredModule(modulePath,
|
||||
ReasonIgnored::PublicFramework);
|
||||
} else if (isInSystemLibraries(modulePath) && moduleName != STDLIB_NAME) {
|
||||
shouldLoadAdjacentModule = false;
|
||||
rebuildInfo.addIgnoredModule(modulePath,
|
||||
ReasonIgnored::PublicLibrary);
|
||||
} else if (isInResourceHostDir(modulePath)) {
|
||||
shouldLoadAdjacentModule = false;
|
||||
rebuildInfo.addIgnoredModule(modulePath,
|
||||
|
||||
Reference in New Issue
Block a user