Serialize explicit module dependencies in swift module files

For clients, such as the debugger, who do not have access the full
output of the dependency scanner, it is a huger performance and
correctness improvement if each explicitly built Swift module not just
serialized all its Clang .pcm dependencies (via the serialized Clang
compiler invocation) but also its direct Swift module dependencies.

This patch changes the Swift module format to store the absolute path
or cas cache key for each dependency in the INPUT block, and makes
sure the deserialization makes these available to the ESML.

rdar://150969755
This commit is contained in:
Adrian Prantl
2025-09-18 16:54:54 -07:00
parent cb7ddbe9ea
commit c91211a5d2
20 changed files with 148 additions and 62 deletions

View File

@@ -103,8 +103,8 @@ protected:
std::unique_ptr<llvm::MemoryBuffer> *moduleBuffer,
std::unique_ptr<llvm::MemoryBuffer> *moduleDocBuffer,
std::unique_ptr<llvm::MemoryBuffer> *moduleSourceInfoBuffer,
bool isCanImportLookup, bool isTestableDependencyLookup,
bool &isFramework, bool &isSystemModule);
std::string *CacheKey, bool isCanImportLookup,
bool isTestableDependencyLookup, bool &isFramework, bool &isSystemModule);
/// Attempts to search the provided directory for a loadable serialized
/// .swiftmodule with the provided `ModuleFilename`. Subclasses must
@@ -268,6 +268,8 @@ public:
/// A textual reason why the compiler rejected a binary module load
/// attempt with a given status, to be used for diagnostic output.
static std::optional<std::string> invalidModuleReason(serialization::Status status);
virtual void addExplicitModulePath(StringRef name, std::string path) {};
};
/// Imports serialized Swift modules into an ASTContext.