@@ -364,44 +364,56 @@ Optional<llvm::VersionTuple>
364
364
swift::getSwiftRuntimeCompatibilityVersionForTarget (
365
365
const llvm::Triple &Triple) {
366
366
unsigned Major, Minor, Micro;
367
-
368
- if (Triple.getArchName () == " arm64e" )
369
- return llvm::VersionTuple (5 , 3 );
367
+ #define MAX (a, b ) ((a) > (b) ? (a) : (b))
370
368
371
369
if (Triple.isMacOSX ()) {
372
370
Triple.getMacOSXVersion (Major, Minor, Micro);
371
+
372
+ auto floorFor64e = [&Triple](llvm::VersionTuple v) {
373
+ if (Triple.getArchName () != " arm64e" ) return v;
374
+ // macOS got first arm64e support in 11.0, i.e. VersionTuple(5, 3)
375
+ return MAX (v, llvm::VersionTuple (5 , 3 ));
376
+ };
377
+
373
378
if (Major == 10 ) {
374
379
if (Triple.isAArch64 () && Minor <= 16 )
375
- return llvm::VersionTuple (5 , 3 );
380
+ return floorFor64e ( llvm::VersionTuple (5 , 3 ) );
376
381
377
382
if (Minor <= 14 ) {
378
- return llvm::VersionTuple (5 , 0 );
383
+ return floorFor64e ( llvm::VersionTuple (5 , 0 ) );
379
384
} else if (Minor <= 15 ) {
380
385
if (Micro <= 3 ) {
381
- return llvm::VersionTuple (5 , 1 );
386
+ return floorFor64e ( llvm::VersionTuple (5 , 1 ) );
382
387
} else {
383
- return llvm::VersionTuple (5 , 2 );
388
+ return floorFor64e ( llvm::VersionTuple (5 , 2 ) );
384
389
}
385
390
}
386
391
} else if (Major == 11 ) {
387
- return llvm::VersionTuple (5 , 3 );
392
+ return floorFor64e ( llvm::VersionTuple (5 , 3 ) );
388
393
}
389
394
} else if (Triple.isiOS ()) { // includes tvOS
390
395
Triple.getiOSVersion (Major, Minor, Micro);
391
396
397
+ auto floorFor64e = [&Triple](llvm::VersionTuple v) {
398
+ if (Triple.getArchName () != " arm64e" ) return v;
399
+ // iOS got first arm64e support in 12.0, which has a Swift runtime version
400
+ // older than 5.0, so let's floor at VersionTuple(5, 0) instead.
401
+ return MAX (v, llvm::VersionTuple (5 , 0 ));
402
+ };
403
+
392
404
// arm64 simulators and macCatalyst are introduced in iOS 14.0/tvOS 14.0
393
405
// with Swift 5.3
394
406
if (Triple.isAArch64 () && Major <= 14 &&
395
407
(Triple.isSimulatorEnvironment () || Triple.isMacCatalystEnvironment ()))
396
- return llvm::VersionTuple (5 , 3 );
408
+ return floorFor64e ( llvm::VersionTuple (5 , 3 ) );
397
409
398
410
if (Major <= 12 ) {
399
- return llvm::VersionTuple (5 , 0 );
411
+ return floorFor64e ( llvm::VersionTuple (5 , 0 ) );
400
412
} else if (Major <= 13 ) {
401
413
if (Minor <= 3 ) {
402
- return llvm::VersionTuple (5 , 1 );
414
+ return floorFor64e ( llvm::VersionTuple (5 , 1 ) );
403
415
} else {
404
- return llvm::VersionTuple (5 , 2 );
416
+ return floorFor64e ( llvm::VersionTuple (5 , 2 ) );
405
417
}
406
418
}
407
419
} else if (Triple.isWatchOS ()) {
0 commit comments