mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Serialization] Teach ASTSectionImporter to filter by triple.
On macOS it is possible for one application to contain Swift modules compiled for different triples that are incompatible as far as the Swift compiler is concerned. Examples include an iOS simulator application hunning on a macOS host, or a macCatalyst application running on macOS. A debugger might see .swift_ast sections for all triples at the same time. This patch adds an interface to let the client provide a triple to filter Swift modules in an ASTSection. rdar://107869141
This commit is contained in:
@@ -91,6 +91,16 @@ static bool isTargetTooNew(const llvm::Triple &moduleTarget,
|
||||
return ctxTarget.isOSVersionLT(moduleTarget);
|
||||
}
|
||||
|
||||
namespace swift {
|
||||
namespace serialization {
|
||||
bool areCompatible(const llvm::Triple &moduleTarget,
|
||||
const llvm::Triple &ctxTarget) {
|
||||
return areCompatibleArchitectures(moduleTarget, ctxTarget) &&
|
||||
areCompatibleOSs(moduleTarget, ctxTarget);
|
||||
}
|
||||
} // namespace serialization
|
||||
} // namespace swift
|
||||
|
||||
ModuleFile::ModuleFile(std::shared_ptr<const ModuleFileSharedCore> core)
|
||||
: Core(core) {
|
||||
assert(!core->hasError());
|
||||
@@ -249,8 +259,7 @@ Status ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc,
|
||||
ASTContext &ctx = getContext();
|
||||
|
||||
llvm::Triple moduleTarget(llvm::Triple::normalize(Core->TargetTriple));
|
||||
if (!areCompatibleArchitectures(moduleTarget, ctx.LangOpts.Target) ||
|
||||
!areCompatibleOSs(moduleTarget, ctx.LangOpts.Target)) {
|
||||
if (!areCompatible(moduleTarget, ctx.LangOpts.Target)) {
|
||||
status = Status::TargetIncompatible;
|
||||
if (!recoverFromIncompatibility)
|
||||
return error(status);
|
||||
|
||||
Reference in New Issue
Block a user