[Caching] Allow prefix mapping for generated bridging header

To allow prefix mapping of the bridging header to achieve cache hit when
source files are located in different location, the generated chained
bridging header should not include absolute paths of the headers. Fix
the problem by concat the chained bridging header together.

Fixes: https://github.com/swiftlang/swift/issues/84088
This commit is contained in:
Steven Wu
2025-09-10 16:33:56 -07:00
parent 963aad3556
commit b7329f4ea7
16 changed files with 241 additions and 82 deletions

View File

@@ -1478,8 +1478,9 @@ swift::extractUserModuleVersionFromInterface(StringRef moduleInterfacePath) {
return result;
}
std::string swift::extractEmbeddedBridgingHeaderContent(
std::unique_ptr<llvm::MemoryBuffer> file, ASTContext &Context) {
std::unique_ptr<llvm::MemoryBuffer> swift::extractEmbeddedBridgingHeaderContent(
std::unique_ptr<llvm::MemoryBuffer> file, StringRef headerPath,
ASTContext &Context) {
std::shared_ptr<const ModuleFileSharedCore> loadedModuleFile;
serialization::ValidationInfo loadInfo = ModuleFileSharedCore::load(
"", "", std::move(file), nullptr, nullptr, false,
@@ -1489,9 +1490,10 @@ std::string swift::extractEmbeddedBridgingHeaderContent(
loadedModuleFile);
if (loadInfo.status != serialization::Status::Valid)
return {};
return nullptr;;
return loadedModuleFile->getEmbeddedHeader();
return llvm::MemoryBuffer::getMemBufferCopy(
loadedModuleFile->getEmbeddedHeader(), headerPath);
}
bool SerializedModuleLoaderBase::canImportModule(