Skip to content

Commit e13fafc

Browse files
authored
Merge pull request swiftlang#39083 from beccadax/give-me-some-e
Add arm64 -> arm64e fallback to module loading
2 parents 8557649 + 2240a39 commit e13fafc

File tree

16 files changed

+94
-21
lines changed

16 files changed

+94
-21
lines changed

lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,23 @@ namespace {
4646
void forEachTargetModuleBasename(const ASTContext &Ctx,
4747
llvm::function_ref<void(StringRef)> body) {
4848
auto normalizedTarget = getTargetSpecificModuleTriple(Ctx.LangOpts.Target);
49+
50+
// An arm64 module can import an arm64e module.
51+
Optional<llvm::Triple> normalizedAltTarget;
52+
if ((normalizedTarget.getArch() == llvm::Triple::ArchType::aarch64) &&
53+
(normalizedTarget.getSubArch() !=
54+
llvm::Triple::SubArchType::AArch64SubArch_arm64e)) {
55+
auto altTarget = normalizedTarget;
56+
altTarget.setArchName("arm64e");
57+
normalizedAltTarget = getTargetSpecificModuleTriple(altTarget);
58+
}
59+
4960
body(normalizedTarget.str());
5061

62+
if (normalizedAltTarget) {
63+
body(normalizedAltTarget->str());
64+
}
65+
5166
// We used the un-normalized architecture as a target-specific
5267
// module name. Fall back to that behavior.
5368
body(Ctx.LangOpts.Target.getArchName());
@@ -61,6 +76,10 @@ void forEachTargetModuleBasename(const ASTContext &Ctx,
6176
if (Ctx.LangOpts.Target.getArch() == llvm::Triple::ArchType::arm) {
6277
body("arm");
6378
}
79+
80+
if (normalizedAltTarget) {
81+
body(normalizedAltTarget->getArchName());
82+
}
6483
}
6584

6685
enum class SearchPathKind {

test/ModuleInterface/Inputs/DummyFramework.framework/Modules/DummyFramework.swiftmodule/arm64-apple-ios.swiftinterface

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/ModuleInterface/Inputs/DummyFramework.framework/Modules/DummyFramework.swiftmodule/arm64.swiftinterface

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/ModuleInterface/Inputs/DummyFramework.framework/Modules/DummyFramework.swiftmodule/arm64e.swiftinterface

Lines changed: 0 additions & 4 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-compiler-version: Apple Swift version 5.2
3+
// swift-module-flags: -target arm64e-apple-ios13.0 -enable-library-evolution -swift-version 5 -module-name PtrAuthFramework
4+
import Swift
5+
6+
#if _ptrauth(_arm64e)
7+
public let iOSPtrAuth: Bool = true
8+
#else
9+
public let iOSNotPtrAuth: Bool = true
10+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-compiler-version: Apple Swift version 5.2
3+
// swift-module-flags: -target arm64e-apple-macos10.13 -enable-library-evolution -swift-version 5 -module-name PtrAuthFramework
4+
import Swift
5+
6+
#if _ptrauth(_arm64e)
7+
public let macOSPtrAuth: Bool = true
8+
#else
9+
public let macOSNotPtrAuth: Bool = true
10+
#endif

0 commit comments

Comments
 (0)