Skip to content

Commit 24d3a98

Browse files
kubamracekDougGregor
authored andcommitted
The concurrency compat library should not be unconditionally used in arm64e builds (swiftlang#39385)
(cherry picked from commit 942b0e8)
1 parent 0516744 commit 24d3a98

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

lib/Basic/Platform.cpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -364,44 +364,56 @@ Optional<llvm::VersionTuple>
364364
swift::getSwiftRuntimeCompatibilityVersionForTarget(
365365
const llvm::Triple &Triple) {
366366
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))
370368

371369
if (Triple.isMacOSX()) {
372370
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+
373378
if (Major == 10) {
374379
if (Triple.isAArch64() && Minor <= 16)
375-
return llvm::VersionTuple(5, 3);
380+
return floorFor64e(llvm::VersionTuple(5, 3));
376381

377382
if (Minor <= 14) {
378-
return llvm::VersionTuple(5, 0);
383+
return floorFor64e(llvm::VersionTuple(5, 0));
379384
} else if (Minor <= 15) {
380385
if (Micro <= 3) {
381-
return llvm::VersionTuple(5, 1);
386+
return floorFor64e(llvm::VersionTuple(5, 1));
382387
} else {
383-
return llvm::VersionTuple(5, 2);
388+
return floorFor64e(llvm::VersionTuple(5, 2));
384389
}
385390
}
386391
} else if (Major == 11) {
387-
return llvm::VersionTuple(5, 3);
392+
return floorFor64e(llvm::VersionTuple(5, 3));
388393
}
389394
} else if (Triple.isiOS()) { // includes tvOS
390395
Triple.getiOSVersion(Major, Minor, Micro);
391396

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+
392404
// arm64 simulators and macCatalyst are introduced in iOS 14.0/tvOS 14.0
393405
// with Swift 5.3
394406
if (Triple.isAArch64() && Major <= 14 &&
395407
(Triple.isSimulatorEnvironment() || Triple.isMacCatalystEnvironment()))
396-
return llvm::VersionTuple(5, 3);
408+
return floorFor64e(llvm::VersionTuple(5, 3));
397409

398410
if (Major <= 12) {
399-
return llvm::VersionTuple(5, 0);
411+
return floorFor64e(llvm::VersionTuple(5, 0));
400412
} else if (Major <= 13) {
401413
if (Minor <= 3) {
402-
return llvm::VersionTuple(5, 1);
414+
return floorFor64e(llvm::VersionTuple(5, 1));
403415
} else {
404-
return llvm::VersionTuple(5, 2);
416+
return floorFor64e(llvm::VersionTuple(5, 2));
405417
}
406418
}
407419
} else if (Triple.isWatchOS()) {

0 commit comments

Comments
 (0)