[compiler-rt] [compiler-rt][sanitizer-common] Use os_log for DriverKit as os_log_error is undefined (PR #148848)

Dan Blackwell via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 15 06:29:18 PDT 2025


https://github.com/DanBlackwell created https://github.com/llvm/llvm-project/pull/148848

None

>From 8d7ea6209a991c72b26d47cf841e726d31b14b57 Mon Sep 17 00:00:00 2001
From: Dan Blackwell <dan_blackwell at apple.com>
Date: Tue, 15 Jul 2025 11:09:38 +0100
Subject: [PATCH] [compiler-rt][sanitizer-common] Use os_log for DriverKit as
 os_log_error is undefined

---
 .../lib/sanitizer_common/sanitizer_mac.cpp    | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index bb71af5ad8b6a..2751485af399f 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -837,22 +837,29 @@ void LogMessageOnPrintf(const char *str) {
 
 void LogFullErrorReport(const char *buffer) {
 #  if !SANITIZER_GO
-  // Log with os_log_error. This will make it into the crash log.
+#    if SANITIZER_DRIVERKIT
+#      define SANITIZER_OS_LOG os_log
+#    else
+#      define SANITIZER_OS_LOG os_log_error
+#    endif
+
+  // Log with os_log.*. This will make it into the crash log.
   if (internal_strncmp(SanitizerToolName, "AddressSanitizer",
                        sizeof("AddressSanitizer") - 1) == 0)
-    os_log_error(OS_LOG_DEFAULT, "Address Sanitizer reported a failure.");
+    SANITIZER_OS_LOG(OS_LOG_DEFAULT, "Address Sanitizer reported a failure.");
   else if (internal_strncmp(SanitizerToolName, "UndefinedBehaviorSanitizer",
                             sizeof("UndefinedBehaviorSanitizer") - 1) == 0)
-    os_log_error(OS_LOG_DEFAULT,
+    SANITIZER_OS_LOG(OS_LOG_DEFAULT,
                  "Undefined Behavior Sanitizer reported a failure.");
   else if (internal_strncmp(SanitizerToolName, "ThreadSanitizer",
                             sizeof("ThreadSanitizer") - 1) == 0)
-    os_log_error(OS_LOG_DEFAULT, "Thread Sanitizer reported a failure.");
+    SANITIZER_OS_LOG(OS_LOG_DEFAULT, "Thread Sanitizer reported a failure.");
   else
-    os_log_error(OS_LOG_DEFAULT, "Sanitizer tool reported a failure.");
+    SANITIZER_OS_LOG(OS_LOG_DEFAULT, "Sanitizer tool reported a failure.");
 
   if (common_flags()->log_to_syslog)
-    os_log_error(OS_LOG_DEFAULT, "Consult syslog for more information.");
+    SANITIZER_OS_LOG(OS_LOG_DEFAULT, "Consult syslog for more information.");
+#    undef SANITIZER_OS_LOG
 
   // Log to syslog.
   // The logging on OS X may call pthread_create so we need the threading



More information about the llvm-commits mailing list