[clang] 1245f5f - [clang][Driver] Add support for XROS_DEPLOYMENT_TARGET env var (#81011)

via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 9 08:52:11 PST 2024


Author: Cyndy Ishida
Date: 2024-02-09T08:52:06-08:00
New Revision: 1245f5f4da8f88d031c0a69388d97e8a6d7f00b5

URL: https://github.com/llvm/llvm-project/commit/1245f5f4da8f88d031c0a69388d97e8a6d7f00b5
DIFF: https://github.com/llvm/llvm-project/commit/1245f5f4da8f88d031c0a69388d97e8a6d7f00b5.diff

LOG: [clang][Driver] Add support for XROS_DEPLOYMENT_TARGET env var (#81011)

Added: 
    clang/test/Driver/xros-driver-requires-darwin-host.c

Modified: 
    clang/lib/Driver/ToolChains/Darwin.cpp
    clang/lib/Driver/ToolChains/Darwin.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index fae8ad1a958ade..cc1219d69d9910 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -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");
@@ -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);

diff  --git a/clang/lib/Driver/ToolChains/Darwin.h b/clang/lib/Driver/ToolChains/Darwin.h
index 5e60b0841d6d5f..10d4b69e5d5f10 100644
--- a/clang/lib/Driver/ToolChains/Darwin.h
+++ b/clang/lib/Driver/ToolChains/Darwin.h
@@ -300,7 +300,7 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
     WatchOS,
     DriverKit,
     XROS,
-    LastDarwinPlatform = DriverKit
+    LastDarwinPlatform = XROS
   };
   enum DarwinEnvironmentKind {
     NativeEnvironment,

diff  --git a/clang/test/Driver/xros-driver-requires-darwin-host.c b/clang/test/Driver/xros-driver-requires-darwin-host.c
new file mode 100644
index 00000000000000..e5bfccae2c2092
--- /dev/null
+++ b/clang/test/Driver/xros-driver-requires-darwin-host.c
@@ -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"


        


More information about the cfe-commits mailing list