Skip to content

Commit 871efdb

Browse files
committed
[clang][driver][darwin] support -target with Mac Catalyst triple without OS version
Some users might omit the version and assume the compiler will target the initial Mac Catalyst version. (cherry picked from commit 3d0d7d8)
1 parent 0afeef8 commit 871efdb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,12 @@ std::string getOSVersion(llvm::Triple::OSType OS, const llvm::Triple &Triple,
18071807
<< Triple.getOSName();
18081808
break;
18091809
case llvm::Triple::IOS:
1810-
Triple.getiOSVersion(Major, Minor, Micro);
1810+
if (Triple.isMacCatalystEnvironment() && !Triple.getOSMajorVersion()) {
1811+
Major = 13;
1812+
Minor = 1;
1813+
Micro = 0;
1814+
} else
1815+
Triple.getiOSVersion(Major, Minor, Micro);
18111816
break;
18121817
case llvm::Triple::TvOS:
18131818
Triple.getOSVersion(Major, Minor, Micro);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
// RUN: %clang -target x86_64-apple-ios13.1-macabi -c %s -### 2>&1 | \
22
// RUN: FileCheck --check-prefix=CHECK-VERSION1 %s
3+
// RUN: %clang -target x86_64-apple-ios-macabi -c %s -### 2>&1 | \
4+
// RUN: FileCheck --check-prefix=CHECK-VERSION1 %s
35
// RUN: %clang -target x86_64-apple-ios13.0-macabi -c %s -### 2>&1 | \
46
// RUN: FileCheck --check-prefix=CHECK-ERROR %s
57
// RUN: %clang -target x86_64-apple-ios12.0-macabi -c %s -### 2>&1 | \
68
// RUN: FileCheck --check-prefix=CHECK-ERROR %s
79

10+
// CHECK-VERSION1-NOT: error:
811
// CHECK-VERSION1: "x86_64-apple-ios13.1.0-macabi"
912
// CHECK-ERROR: error: invalid version number in '-target x86_64-apple-ios

0 commit comments

Comments
 (0)