Skip to content

Commit 3d0d7d8

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.
1 parent 6e04ec8 commit 3d0d7d8

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
@@ -1820,7 +1820,12 @@ std::string getOSVersion(llvm::Triple::OSType OS, const llvm::Triple &Triple,
18201820
<< Triple.getOSName();
18211821
break;
18221822
case llvm::Triple::IOS:
1823-
Triple.getiOSVersion(Major, Minor, Micro);
1823+
if (Triple.isMacCatalystEnvironment() && !Triple.getOSMajorVersion()) {
1824+
Major = 13;
1825+
Minor = 1;
1826+
Micro = 0;
1827+
} else
1828+
Triple.getiOSVersion(Major, Minor, Micro);
18241829
break;
18251830
case llvm::Triple::TvOS:
18261831
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)