Skip to content

Commit 1245f5f

Browse files
authored
[clang][Driver] Add support for XROS_DEPLOYMENT_TARGET env var (#81011)
1 parent 5afbed1 commit 1245f5f

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,6 +1902,7 @@ getDeploymentTargetFromEnvironmentVariables(const Driver &TheDriver,
19021902
"TVOS_DEPLOYMENT_TARGET",
19031903
"WATCHOS_DEPLOYMENT_TARGET",
19041904
"DRIVERKIT_DEPLOYMENT_TARGET",
1905+
"XROS_DEPLOYMENT_TARGET"
19051906
};
19061907
static_assert(std::size(EnvVars) == Darwin::LastDarwinPlatform + 1,
19071908
"Missing platform");
@@ -1914,14 +1915,15 @@ getDeploymentTargetFromEnvironmentVariables(const Driver &TheDriver,
19141915
// default platform.
19151916
if (!Targets[Darwin::MacOS].empty() &&
19161917
(!Targets[Darwin::IPhoneOS].empty() ||
1917-
!Targets[Darwin::WatchOS].empty() || !Targets[Darwin::TvOS].empty())) {
1918+
!Targets[Darwin::WatchOS].empty() || !Targets[Darwin::TvOS].empty() ||
1919+
!Targets[Darwin::XROS].empty())) {
19181920
if (Triple.getArch() == llvm::Triple::arm ||
19191921
Triple.getArch() == llvm::Triple::aarch64 ||
19201922
Triple.getArch() == llvm::Triple::thumb)
19211923
Targets[Darwin::MacOS] = "";
19221924
else
19231925
Targets[Darwin::IPhoneOS] = Targets[Darwin::WatchOS] =
1924-
Targets[Darwin::TvOS] = "";
1926+
Targets[Darwin::TvOS] = Targets[Darwin::XROS] = "";
19251927
} else {
19261928
// Don't allow conflicts in any other platform.
19271929
unsigned FirstTarget = std::size(Targets);

clang/lib/Driver/ToolChains/Darwin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
300300
WatchOS,
301301
DriverKit,
302302
XROS,
303-
LastDarwinPlatform = DriverKit
303+
LastDarwinPlatform = XROS
304304
};
305305
enum DarwinEnvironmentKind {
306306
NativeEnvironment,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// REQUIRES: system-darwin
2+
3+
// RUN: env XROS_DEPLOYMENT_TARGET=1.0 %clang -arch arm64 -c -### %s 2>&1 | FileCheck %s
4+
5+
// RUN: rm -rf %t.dir
6+
// RUN: mkdir -p %t.dir/XROS1.0.sdk
7+
// RUN: %clang -arch arm64 -isysroot %t.dir/XROS1.0.sdk -c -### %s 2>&1 | FileCheck %s
8+
// RUN: mkdir -p %t.dir/XRSimulator1.0.sdk
9+
// RUN: %clang -arch arm64 -isysroot %t.dir/XRSimulator1.0.sdk -c -### %s 2>&1 | FileCheck --check-prefix=CHECK_SIM %s
10+
11+
12+
// CHECK: "-cc1"{{.*}} "-triple" "arm64-apple-xros1.0.0"
13+
// CHECK_SIM: "-cc1"{{.*}} "-triple" "arm64-apple-xros1.0.0-simulator"

0 commit comments

Comments
 (0)