Skip to content

Commit b073df2

Browse files
committed
64-bit watchOS should imply a 5.3 minimum version of the Swift runtime
1 parent 12a2e20 commit b073df2

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/AST/Availability.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ AvailabilityContext ASTContext::getSwift50Availability() {
259259
return AvailabilityContext(
260260
VersionRange::allGTE(llvm::VersionTuple(12,2)));
261261
} else if (target.isWatchOS()) {
262-
if (target.getArch() == llvm::Triple::ArchType::x86_64)
262+
if (target.isArch64Bit())
263263
return AvailabilityContext::alwaysAvailable();
264264

265265
return AvailabilityContext(
@@ -297,6 +297,9 @@ AvailabilityContext ASTContext::getSwift51Availability() {
297297
return AvailabilityContext(
298298
VersionRange::allGTE(llvm::VersionTuple(13,0,0)));
299299
} else if (target.isWatchOS()) {
300+
if (target.isArch64Bit())
301+
return AvailabilityContext::alwaysAvailable();
302+
300303
return AvailabilityContext(
301304
VersionRange::allGTE(llvm::VersionTuple(6,0,0)));
302305
} else {

lib/Basic/Platform.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,14 +423,20 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget(
423423
}
424424
}
425425
} else if (Triple.isWatchOS()) {
426+
auto floorFor64bits = [&Triple](llvm::VersionTuple v) {
427+
if (!Triple.isArch64Bit()) return v;
428+
// 64-bit watchOS was introduced with Swift 5.3
429+
return MAX(v, llvm::VersionTuple(5, 3));
430+
};
431+
426432
Triple.getWatchOSVersion(Major, Minor, Micro);
427433
if (Major <= 5) {
428-
return llvm::VersionTuple(5, 0);
434+
return floorFor64bits(llvm::VersionTuple(5, 0));
429435
} else if (Major <= 6) {
430436
if (Minor <= 1) {
431-
return llvm::VersionTuple(5, 1);
437+
return floorFor64bits(llvm::VersionTuple(5, 1));
432438
} else {
433-
return llvm::VersionTuple(5, 2);
439+
return floorFor64bits(llvm::VersionTuple(5, 2));
434440
}
435441
}
436442
}

0 commit comments

Comments
 (0)