[Dependency Scanning] Discard and diagnose discovered binary modules built for an incompatible target

Previously the scanner accepted binary modules regardless of what triple they were built for
This commit is contained in:
Artem Chikin
2025-06-26 15:51:44 -07:00
parent d10b3f82fc
commit c8714b5627
8 changed files with 60 additions and 22 deletions

View File

@@ -444,6 +444,7 @@ private:
bool isFramework,
bool requiresOSSAModules,
StringRef requiredSDK,
std::optional<llvm::Triple> target,
serialization::ValidationInfo &info, PathObfuscator &pathRecoverer);
/// Change the status of the current module.
@@ -571,6 +572,10 @@ public:
/// linking purposes.
/// \param requiresOSSAModules If true, this requires dependent modules to be
/// compiled with -enable-ossa-modules.
/// \param requiredSDK A string denoting the name of the currently-used SDK,
/// to ensure that the loaded module was built with a compatible SDK.
/// \param target The target triple of the current compilation for
/// validating that the module we are attempting to load is compatible.
/// \param[out] theModule The loaded module.
/// \returns Whether the module was successfully loaded, or what went wrong
/// if it was not.
@@ -580,13 +585,14 @@ public:
std::unique_ptr<llvm::MemoryBuffer> moduleDocInputBuffer,
std::unique_ptr<llvm::MemoryBuffer> moduleSourceInfoInputBuffer,
bool isFramework, bool requiresOSSAModules,
StringRef requiredSDK, PathObfuscator &pathRecoverer,
StringRef requiredSDK, std::optional<llvm::Triple> target,
PathObfuscator &pathRecoverer,
std::shared_ptr<const ModuleFileSharedCore> &theModule) {
serialization::ValidationInfo info;
auto *core = new ModuleFileSharedCore(
std::move(moduleInputBuffer), std::move(moduleDocInputBuffer),
std::move(moduleSourceInfoInputBuffer), isFramework,
requiresOSSAModules, requiredSDK, info,
requiresOSSAModules, requiredSDK, target, info,
pathRecoverer);
if (!moduleInterfacePath.empty()) {
ArrayRef<char> path;