-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang] Extend define-target-os-macros to support XROS. #82833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Updates the extension feature `define-target-os-macros` to support the recently-added XROS target (TARGET_OS_VISION).
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-driver Author: None (rohit-rao) ChangesUpdates the extension feature Full diff: https://github.com/llvm/llvm-project/pull/82833.diff 2 Files Affected:
diff --git a/clang/include/clang/Basic/TargetOSMacros.def b/clang/include/clang/Basic/TargetOSMacros.def
index dfc2e033f6fd0d..58dce330f9c8fd 100644
--- a/clang/include/clang/Basic/TargetOSMacros.def
+++ b/clang/include/clang/Basic/TargetOSMacros.def
@@ -34,18 +34,19 @@ TARGET_OS(TARGET_OS_UNIX, Triple.isOSNetBSD() ||
TARGET_OS(TARGET_OS_MAC, Triple.isOSDarwin())
TARGET_OS(TARGET_OS_OSX, Triple.isMacOSX())
TARGET_OS(TARGET_OS_IPHONE, Triple.isiOS() || Triple.isTvOS() ||
- Triple.isWatchOS())
+ Triple.isWatchOS() || Triple.isXROS())
// Triple::isiOS() also includes tvOS
TARGET_OS(TARGET_OS_IOS, Triple.getOS() == llvm::Triple::IOS)
TARGET_OS(TARGET_OS_TV, Triple.isTvOS())
TARGET_OS(TARGET_OS_WATCH, Triple.isWatchOS())
+TARGET_OS(TARGET_OS_VISION, Triple.isXROS())
TARGET_OS(TARGET_OS_DRIVERKIT, Triple.isDriverKit())
TARGET_OS(TARGET_OS_MACCATALYST, Triple.isMacCatalystEnvironment())
TARGET_OS(TARGET_OS_SIMULATOR, Triple.isSimulatorEnvironment())
// Deprecated Apple target conditionals.
TARGET_OS(TARGET_OS_EMBEDDED, (Triple.isiOS() || Triple.isTvOS() \
- || Triple.isWatchOS()) \
+ || Triple.isWatchOS() || Triple.isXROS()) \
&& !Triple.isMacCatalystEnvironment() \
&& !Triple.isSimulatorEnvironment())
TARGET_OS(TARGET_OS_NANO, Triple.isWatchOS())
diff --git a/clang/test/Driver/fdefine-target-os-macros.c b/clang/test/Driver/fdefine-target-os-macros.c
index d7379dd3d5396b..a4de51e8e7244b 100644
--- a/clang/test/Driver/fdefine-target-os-macros.c
+++ b/clang/test/Driver/fdefine-target-os-macros.c
@@ -12,6 +12,7 @@
// RUN: -DIOS=0 \
// RUN: -DTV=0 \
// RUN: -DWATCH=0 \
+// RUN: -DVISION=0 \
// RUN: -DDRIVERKIT=0 \
// RUN: -DMACCATALYST=0 \
// RUN: -DEMBEDDED=0 \
@@ -27,6 +28,7 @@
// RUN: -DIOS=1 \
// RUN: -DTV=0 \
// RUN: -DWATCH=0 \
+// RUN: -DVISION=0 \
// RUN: -DDRIVERKIT=0 \
// RUN: -DMACCATALYST=0 \
// RUN: -DEMBEDDED=1 \
@@ -42,6 +44,7 @@
// RUN: -DIOS=1 \
// RUN: -DTV=0 \
// RUN: -DWATCH=0 \
+// RUN: -DVISION=0 \
// RUN: -DDRIVERKIT=0 \
// RUN: -DMACCATALYST=1 \
// RUN: -DEMBEDDED=0 \
@@ -57,6 +60,7 @@
// RUN: -DIOS=1 \
// RUN: -DTV=0 \
// RUN: -DWATCH=0 \
+// RUN: -DVISION=0 \
// RUN: -DDRIVERKIT=0 \
// RUN: -DMACCATALYST=0 \
// RUN: -DEMBEDDED=0 \
@@ -72,6 +76,7 @@
// RUN: -DIOS=0 \
// RUN: -DTV=1 \
// RUN: -DWATCH=0 \
+// RUN: -DVISION=0 \
// RUN: -DDRIVERKIT=0 \
// RUN: -DMACCATALYST=0 \
// RUN: -DEMBEDDED=1 \
@@ -87,6 +92,7 @@
// RUN: -DIOS=0 \
// RUN: -DTV=1 \
// RUN: -DWATCH=0 \
+// RUN: -DVISION=0 \
// RUN: -DDRIVERKIT=0 \
// RUN: -DMACCATALYST=0 \
// RUN: -DEMBEDDED=0 \
@@ -102,6 +108,7 @@
// RUN: -DIOS=0 \
// RUN: -DTV=0 \
// RUN: -DWATCH=1 \
+// RUN: -DVISION=0 \
// RUN: -DDRIVERKIT=0 \
// RUN: -DMACCATALYST=0 \
// RUN: -DEMBEDDED=1 \
@@ -117,6 +124,39 @@
// RUN: -DIOS=0 \
// RUN: -DTV=0 \
// RUN: -DWATCH=1 \
+// RUN: -DVISION=0 \
+// RUN: -DDRIVERKIT=0 \
+// RUN: -DMACCATALYST=0 \
+// RUN: -DEMBEDDED=0 \
+// RUN: -DSIMULATOR=1 \
+// RUN: -DWINDOWS=0 \
+// RUN: -DLINUX=0 \
+// RUN: -DUNIX=0
+
+// RUN: %clang -dM -E --target=arm64-apple-xros %s 2>&1 \
+// RUN: | FileCheck %s -DMAC=1 \
+// RUN: -DOSX=0 \
+// RUN: -DIPHONE=1 \
+// RUN: -DIOS=0 \
+// RUN: -DTV=0 \
+// RUN: -DWATCH=0 \
+// RUN: -DVISION=1 \
+// RUN: -DDRIVERKIT=0 \
+// RUN: -DMACCATALYST=0 \
+// RUN: -DEMBEDDED=1 \
+// RUN: -DSIMULATOR=0 \
+// RUN: -DWINDOWS=0 \
+// RUN: -DLINUX=0 \
+// RUN: -DUNIX=0
+
+// RUN: %clang -dM -E --target=arm64-apple-xros-simulator %s 2>&1 \
+// RUN: | FileCheck %s -DMAC=1 \
+// RUN: -DOSX=0 \
+// RUN: -DIPHONE=1 \
+// RUN: -DIOS=0 \
+// RUN: -DTV=0 \
+// RUN: -DWATCH=0 \
+// RUN: -DVISION=1 \
// RUN: -DDRIVERKIT=0 \
// RUN: -DMACCATALYST=0 \
// RUN: -DEMBEDDED=0 \
@@ -132,6 +172,7 @@
// RUN: -DIOS=0 \
// RUN: -DTV=0 \
// RUN: -DWATCH=0 \
+// RUN: -DVISION=0 \
// RUN: -DDRIVERKIT=1 \
// RUN: -DMACCATALYST=0 \
// RUN: -DEMBEDDED=0 \
@@ -148,6 +189,7 @@
// RUN: -DIOS=0 \
// RUN: -DTV=0 \
// RUN: -DWATCH=0 \
+// RUN: -DVISION=0 \
// RUN: -DDRIVERKIT=0 \
// RUN: -DMACCATALYST=0 \
// RUN: -DEMBEDDED=0 \
@@ -164,6 +206,7 @@
// RUN: -DIOS=0 \
// RUN: -DTV=0 \
// RUN: -DWATCH=0 \
+// RUN: -DVISION=0 \
// RUN: -DDRIVERKIT=0 \
// RUN: -DMACCATALYST=0 \
// RUN: -DEMBEDDED=0 \
@@ -180,6 +223,7 @@
// RUN: -DIOS=0 \
// RUN: -DTV=0 \
// RUN: -DWATCH=0 \
+// RUN: -DVISION=0 \
// RUN: -DDRIVERKIT=0 \
// RUN: -DMACCATALYST=0 \
// RUN: -DEMBEDDED=0 \
@@ -196,6 +240,7 @@
// RUN: -DIOS=0 \
// RUN: -DTV=0 \
// RUN: -DWATCH=0 \
+// RUN: -DVISION=0 \
// RUN: -DDRIVERKIT=0 \
// RUN: -DMACCATALYST=0 \
// RUN: -DEMBEDDED=0 \
@@ -226,6 +271,7 @@
// CHECK-DAG: #define TARGET_OS_IOS [[IOS]]
// CHECK-DAG: #define TARGET_OS_TV [[TV]]
// CHECK-DAG: #define TARGET_OS_WATCH [[WATCH]]
+// CHECK-DAG: #define TARGET_OS_VISION [[VISION]]
// CHECK-DAG: #define TARGET_OS_DRIVERKIT [[DRIVERKIT]]
// CHECK-DAG: #define TARGET_OS_MACCATALYST [[MACCATALYST]]
// CHECK-DAG: #define TARGET_OS_SIMULATOR [[SIMULATOR]]
|
@zixu-w please take a look if you have a minute, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for making the change!
@rohit-rao Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested Please check whether problems have been caused by your change specifically, as How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
commit e5ed7b6 Author: rohit-rao <[email protected]> Date: Tue Feb 27 15:23:00 2024 -0500 [clang] Extend define-target-os-macros to support XROS. (llvm#82833)
Fixup faulty target macro initialization in Apple SDK since v14.4 (as of 15.0 beta). The SDK target detection in `TargetConditionals.h` correctly detects macOS, but fails to set the macro's old name `TARGET_OS_OSX`, then continues to set it to a default value of 0. Other parts of the SDK still rely on the old name, and with this inconsistency our builds fail due to missing declarations. It happens when using mainline llvm older than v18. Later versions fixed it by predefining these target macros, avoiding the faulty dynamic detection. gcc is not affected (for now) because it lacks the necessary dynamic detection features, so the SDK falls back to a codepath that sets both the old and new macro to 1. Also move the `TargetConditionals.h` include to the top of to make sure including it also for c-ares builds, combined with SecureTransport or other curl features that may call use the Apple SDK. Before this patch, affected build combinations (e.g. llvm@15 + Xcode 15.3, 15.4, 16.0 with their default SDKs + SecureTransport) fail with: error: use of undeclared identifier 'noErr' / 'SecCertificateCopyLongDescription' / 'SecItemImportExportKeyParameters' / 'SecExternalFormat' / 'SecExternalItemType' / 'SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION' Example: ``` curl/lib/vtls/sectransp.c:311:18: error: use of undeclared identifier 'noErr' OSStatus rtn = noErr; ^ curl/lib/vtls/sectransp.c:379:7: error: use of undeclared identifier 'SecCertificateCopyLongDescription' if(&SecCertificateCopyLongDescription) ^ curl/lib/vtls/sectransp.c:381:7: error: call to undeclared function 'SecCertificateCopyLongDescription'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] SecCertificateCopyLongDescription(NULL, cert, NULL); ^ curl/lib/vtls/sectransp.c:380:25: error: incompatible integer to pointer conversion assigning to 'CFStringRef' (aka 'const struct __CFString *') from 'int' [-Wint-conversion] server_cert_summary = ^ [...] ``` Ref: https://github.com/curl/curl/actions/runs/9893867519/job/27330135969#step:10:22 llvm v18 patches implementing the predefined macros: llvm/llvm-project#74676 llvm/llvm-project@6e1f191 llvm/llvm-project#82833 llvm/llvm-project@e5ed7b6 Cherry-picked from curl#14097 Closes #xxxxx
Fixup faulty target macro initialization in macOS SDK since v14.4 (as of 15.0 beta). The SDK target detection in `TargetConditionals.h` correctly detects macOS, but fails to set the macro's old name `TARGET_OS_OSX`, then continues to set it to a default value of 0. Other parts of the SDK still rely on the old name, and with this inconsistency our builds fail due to missing declarations. It happens when using mainline llvm older than v18. Later versions fixed it by predefining these target macros, avoiding the faulty dynamic detection. gcc is not affected (for now) because it lacks the necessary dynamic detection features, so the SDK falls back to a codepath that sets both the old and new macro to 1. Also move the `TargetConditionals.h` include to the top of to make sure including it also for c-ares builds, combined with SecureTransport or other curl features that may call use an Apple SDK. Before this patch, affected build combinations (e.g. in GHA runners, llvm@15 + Xcode 15.3, 15.4, 16.0 with their default SDKs + SecureTransport) fail with: ``` error: use of undeclared identifier 'noErr' or 'SecCertificateCopyLongDescription' or 'SecItemImportExportKeyParameters' or 'SecExternalFormat' or 'SecExternalItemType' or 'SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION' ``` Example: ``` curl/lib/vtls/sectransp.c:311:18: error: use of undeclared identifier 'noErr' OSStatus rtn = noErr; ^ curl/lib/vtls/sectransp.c:379:7: error: use of undeclared identifier 'SecCertificateCopyLongDescription' if(&SecCertificateCopyLongDescription) ^ curl/lib/vtls/sectransp.c:381:7: error: call to undeclared function 'SecCertificateCopyLongDescription'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] SecCertificateCopyLongDescription(NULL, cert, NULL); ^ curl/lib/vtls/sectransp.c:380:25: error: incompatible integer to pointer conversion assigning to 'CFStringRef' (aka 'const struct __CFString *') from 'int' [-Wint-conversion] server_cert_summary = ^ [...] ``` Ref: https://github.com/curl/curl/actions/runs/9893867519/job/27330135969#step:10:22 llvm v18 patches implementing the predefined macros: llvm/llvm-project#74676 llvm/llvm-project@6e1f191 llvm/llvm-project#82833 llvm/llvm-project@e5ed7b6 Cherry-picked from #14097 Closes #14159
Updates the extension feature
define-target-os-macros
to support the recently-added XROS target (TARGET_OS_VISION).