Do not fail the build on only finding incompatible-architecture modules on 'canImport'

This change refactors the module loaders to explicitly take a parameter indicating whether or not the loader is handling a 'canImport' query, in order to avoid emitting an error when finding a dependency Swift binary module with only imcompatible architecture variants present.

Resolves rdar://161175498
This commit is contained in:
Artem Chikin
2025-09-23 14:45:57 -07:00
parent 8e96210c47
commit c73869e479
9 changed files with 56 additions and 51 deletions

View File

@@ -103,7 +103,7 @@ protected:
std::unique_ptr<llvm::MemoryBuffer> *moduleBuffer,
std::unique_ptr<llvm::MemoryBuffer> *moduleDocBuffer,
std::unique_ptr<llvm::MemoryBuffer> *moduleSourceInfoBuffer,
bool skipBuildingInterface, bool isTestableDependencyLookup,
bool isCanImportLookup, bool isTestableDependencyLookup,
bool &isFramework, bool &isSystemModule);
/// Attempts to search the provided directory for a loadable serialized
@@ -125,8 +125,8 @@ protected:
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
std::unique_ptr<llvm::MemoryBuffer> *ModuleSourceInfoBuffer,
bool SkipBuildingInterface, bool IsFramework,
bool isTestableDependencyLookup = false) = 0;
bool IsCanImportLookup, bool IsFramework,
bool IsTestableDependencyLookup = false) = 0;
std::error_code
openModuleFile(
@@ -154,7 +154,8 @@ protected:
virtual bool maybeDiagnoseTargetMismatch(
SourceLoc sourceLocation,
StringRef moduleName,
const SerializedModuleBaseName &BaseName) {
const SerializedModuleBaseName &BaseName,
bool isCanImportLookup) {
return false;
}
@@ -278,13 +279,14 @@ class ImplicitSerializedModuleLoader : public SerializedModuleLoaderBase {
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
std::unique_ptr<llvm::MemoryBuffer> *ModuleSourceInfoBuffer,
bool SkipBuildingInterface, bool IsFramework,
bool isTestableDependencyLookup = false) override;
bool IsCanImportLookup, bool IsFramework,
bool IsTestableDependencyLookup = false) override;
bool maybeDiagnoseTargetMismatch(
SourceLoc sourceLocation,
StringRef moduleName,
const SerializedModuleBaseName &BaseName) override;
const SerializedModuleBaseName &BaseName,
bool isCanImportLookup) override;
public:
virtual ~ImplicitSerializedModuleLoader();
@@ -336,14 +338,9 @@ class MemoryBufferSerializedModuleLoader : public SerializedModuleLoaderBase {
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
std::unique_ptr<llvm::MemoryBuffer> *ModuleSourceInfoBuffer,
bool SkipBuildingInterface, bool IsFramework,
bool IsCanImportLookup, bool IsFramework,
bool IsTestableDependencyLookup = false) override;
bool maybeDiagnoseTargetMismatch(
SourceLoc sourceLocation,
StringRef moduleName,
const SerializedModuleBaseName &BaseName) override;
bool BypassResilience;
public:
virtual ~MemoryBufferSerializedModuleLoader();