Skip to content

Commit

Permalink
[clang][Driver] Add support for XROS_DEPLOYMENT_TARGET env var (#81011)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyndyishida committed Feb 9, 2024
1 parent 5afbed1 commit 1245f5f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 4 additions & 2 deletions clang/lib/Driver/ToolChains/Darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1902,6 +1902,7 @@ getDeploymentTargetFromEnvironmentVariables(const Driver &TheDriver,
"TVOS_DEPLOYMENT_TARGET",
"WATCHOS_DEPLOYMENT_TARGET",
"DRIVERKIT_DEPLOYMENT_TARGET",
"XROS_DEPLOYMENT_TARGET"
};
static_assert(std::size(EnvVars) == Darwin::LastDarwinPlatform + 1,
"Missing platform");
Expand All @@ -1914,14 +1915,15 @@ getDeploymentTargetFromEnvironmentVariables(const Driver &TheDriver,
// default platform.
if (!Targets[Darwin::MacOS].empty() &&
(!Targets[Darwin::IPhoneOS].empty() ||
!Targets[Darwin::WatchOS].empty() || !Targets[Darwin::TvOS].empty())) {
!Targets[Darwin::WatchOS].empty() || !Targets[Darwin::TvOS].empty() ||
!Targets[Darwin::XROS].empty())) {
if (Triple.getArch() == llvm::Triple::arm ||
Triple.getArch() == llvm::Triple::aarch64 ||
Triple.getArch() == llvm::Triple::thumb)
Targets[Darwin::MacOS] = "";
else
Targets[Darwin::IPhoneOS] = Targets[Darwin::WatchOS] =
Targets[Darwin::TvOS] = "";
Targets[Darwin::TvOS] = Targets[Darwin::XROS] = "";
} else {
// Don't allow conflicts in any other platform.
unsigned FirstTarget = std::size(Targets);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/Darwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
WatchOS,
DriverKit,
XROS,
LastDarwinPlatform = DriverKit
LastDarwinPlatform = XROS
};
enum DarwinEnvironmentKind {
NativeEnvironment,
Expand Down
13 changes: 13 additions & 0 deletions clang/test/Driver/xros-driver-requires-darwin-host.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// REQUIRES: system-darwin

// RUN: env XROS_DEPLOYMENT_TARGET=1.0 %clang -arch arm64 -c -### %s 2>&1 | FileCheck %s

// RUN: rm -rf %t.dir
// RUN: mkdir -p %t.dir/XROS1.0.sdk
// RUN: %clang -arch arm64 -isysroot %t.dir/XROS1.0.sdk -c -### %s 2>&1 | FileCheck %s
// RUN: mkdir -p %t.dir/XRSimulator1.0.sdk
// RUN: %clang -arch arm64 -isysroot %t.dir/XRSimulator1.0.sdk -c -### %s 2>&1 | FileCheck --check-prefix=CHECK_SIM %s


// CHECK: "-cc1"{{.*}} "-triple" "arm64-apple-xros1.0.0"
// CHECK_SIM: "-cc1"{{.*}} "-triple" "arm64-apple-xros1.0.0-simulator"

0 comments on commit 1245f5f

Please sign in to comment.