[compiler-rt] [compiler-rt] Replace deprecated os_trace calls on mac (PR #138908)
Dan Blackwell via llvm-commits
llvm-commits at lists.llvm.org
Fri May 9 06:10:25 PDT 2025
https://github.com/DanBlackwell updated https://github.com/llvm/llvm-project/pull/138908
>From 598eb65471ca9a43f0023c8e38964e6ece408f83 Mon Sep 17 00:00:00 2001
From: Dan Blackwell <dan_blackwell at apple.com>
Date: Wed, 7 May 2025 16:10:59 +0100
Subject: [PATCH 1/3] [compiler-rt] Replace deprecated os_trace calls on mac
---
.../lib/sanitizer_common/sanitizer_mac.cpp | 44 +++++++++----------
1 file changed, 20 insertions(+), 24 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index 0b8a75391136d..f02f78c4e19b4 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -844,30 +844,26 @@ void LogMessageOnPrintf(const char *str) {
void LogFullErrorReport(const char *buffer) {
#if !SANITIZER_GO
- // Log with os_trace. This will make it into the crash log.
-#if SANITIZER_OS_TRACE
-#pragma clang diagnostic push
-// os_trace is deprecated.
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- if (GetMacosAlignedVersion() >= MacosVersion(10, 10)) {
- // os_trace requires the message (format parameter) to be a string literal.
- if (internal_strncmp(SanitizerToolName, "AddressSanitizer",
- sizeof("AddressSanitizer") - 1) == 0)
- os_trace("Address Sanitizer reported a failure.");
- else if (internal_strncmp(SanitizerToolName, "UndefinedBehaviorSanitizer",
- sizeof("UndefinedBehaviorSanitizer") - 1) == 0)
- os_trace("Undefined Behavior Sanitizer reported a failure.");
- else if (internal_strncmp(SanitizerToolName, "ThreadSanitizer",
- sizeof("ThreadSanitizer") - 1) == 0)
- os_trace("Thread Sanitizer reported a failure.");
- else
- os_trace("Sanitizer tool reported a failure.");
-
- if (common_flags()->log_to_syslog)
- os_trace("Consult syslog for more information.");
- }
-#pragma clang diagnostic pop
-#endif
+# if SANITIZER_OS_TRACE
+ // Log with os_log_error. This will make it into the crash log.
+ if (GetMacosAlignedVersion() >= MacosVersion(10, 10)) {
+ if (internal_strncmp(SanitizerToolName, "AddressSanitizer",
+ sizeof("AddressSanitizer") - 1) == 0)
+ os_log_error(OS_LOG_DEFAULT, "Address Sanitizer reported a failure.");
+ else if (internal_strncmp(SanitizerToolName, "UndefinedBehaviorSanitizer",
+ sizeof("UndefinedBehaviorSanitizer") - 1) == 0)
+ os_log_error(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.");
+ else
+ os_log_error(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.");
+ }
+# endif // SANITIZER_OS_TRACE
// Log to syslog.
// The logging on OS X may call pthread_create so we need the threading
>From 86bb81f216ab99552cd208296032462a6b6e8c51 Mon Sep 17 00:00:00 2001
From: Dan Blackwell <dan_blackwell at apple.com>
Date: Fri, 9 May 2025 11:59:30 +0100
Subject: [PATCH 2/3] Updated 10.10 to 10.12 for min version
---
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index f02f78c4e19b4..c1a4d5ac39527 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -846,7 +846,7 @@ void LogFullErrorReport(const char *buffer) {
#if !SANITIZER_GO
# if SANITIZER_OS_TRACE
// Log with os_log_error. This will make it into the crash log.
- if (GetMacosAlignedVersion() >= MacosVersion(10, 10)) {
+ if (GetMacosAlignedVersion() >= MacosVersion(10, 12)) {
if (internal_strncmp(SanitizerToolName, "AddressSanitizer",
sizeof("AddressSanitizer") - 1) == 0)
os_log_error(OS_LOG_DEFAULT, "Address Sanitizer reported a failure.");
>From 42ccb48ccfefd2c9515a79265e89828bdb68d3a8 Mon Sep 17 00:00:00 2001
From: Dan Blackwell <dan_blackwell at apple.com>
Date: Fri, 9 May 2025 14:10:10 +0100
Subject: [PATCH 3/3] Formatting fix
---
.../lib/sanitizer_common/sanitizer_mac.cpp | 40 +++++++++----------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index c1a4d5ac39527..d9ff0c961e4ba 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -844,26 +844,26 @@ void LogMessageOnPrintf(const char *str) {
void LogFullErrorReport(const char *buffer) {
#if !SANITIZER_GO
-# if SANITIZER_OS_TRACE
- // Log with os_log_error. This will make it into the crash log.
- if (GetMacosAlignedVersion() >= MacosVersion(10, 12)) {
- if (internal_strncmp(SanitizerToolName, "AddressSanitizer",
- sizeof("AddressSanitizer") - 1) == 0)
- os_log_error(OS_LOG_DEFAULT, "Address Sanitizer reported a failure.");
- else if (internal_strncmp(SanitizerToolName, "UndefinedBehaviorSanitizer",
- sizeof("UndefinedBehaviorSanitizer") - 1) == 0)
- os_log_error(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.");
- else
- os_log_error(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.");
- }
-# endif // SANITIZER_OS_TRACE
+# if SANITIZER_OS_TRACE
+ // Log with os_log_error. This will make it into the crash log.
+ if (GetMacosAlignedVersion() >= MacosVersion(10, 12)) {
+ if (internal_strncmp(SanitizerToolName, "AddressSanitizer",
+ sizeof("AddressSanitizer") - 1) == 0)
+ os_log_error(OS_LOG_DEFAULT, "Address Sanitizer reported a failure.");
+ else if (internal_strncmp(SanitizerToolName, "UndefinedBehaviorSanitizer",
+ sizeof("UndefinedBehaviorSanitizer") - 1) == 0)
+ os_log_error(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.");
+ else
+ os_log_error(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.");
+ }
+# endif // SANITIZER_OS_TRACE
// 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