[compiler-rt] [sanitizer_common] [Darwin] Update version mapping for macOS 27-aligned releases (PR #204608)

Andrew Haberlandt via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 18 07:29:32 PDT 2026


https://github.com/ndrewh created https://github.com/llvm/llvm-project/pull/204608

This updates `MapToMacos` et. al. to produce correct results for macOS 26 and macOS 27-aligned releases.

rdar://177997021
rdar://169356606

>From cf965c4044bfe8ecd30ff71aa8aef4b6a8d5a073 Mon Sep 17 00:00:00 2001
From: Andrew Haberlandt <ahaberlandt at apple.com>
Date: Thu, 18 Jun 2026 10:26:31 -0400
Subject: [PATCH] [sanitizer_common] [Darwin] Update version mapping for macOS
 27-aligned releases

This updates MapToMacos et. al. to produce correct results for
macOS 26 and macOS 27-aligned releases.

rdar://177997021
rdar://169356606
---
 .../lib/sanitizer_common/sanitizer_mac.cpp    | 26 ++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index f00d375ef4e2f..2fe93c4cd9808 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -613,7 +613,13 @@ static uptr ApproximateOSVersionViaKernelVersion(VersStr vers) {
   u16 os_major = kernel_major - offset;
 
   const char *format = "%d.0";
-  if (TARGET_OS_OSX) {
+  if (kernel_major >= 27) {
+    // with kernel major 27 <=> OSes 27.0, OS versions are aligned with kernel
+    os_major = kernel_major;
+  } else if (kernel_major >= 25) {
+    // with kernel_major 25 <=> OSes 26.0, OS versions are aligned
+    os_major = kernel_major + 1;
+  } else if (TARGET_OS_OSX) {
     if (os_major >= 16) {  // macOS 11+
       os_major -= 5;
     } else {  // macOS 10.15 and below
@@ -670,6 +676,24 @@ static void MapToMacos(u16 *major, u16 *minor) {
   if (TARGET_OS_OSX)
     return;
 
+  // All supported platforms (including DriverKit) have
+  // aligned version numbers in macOS 27+
+  if (*major >= 27)
+    return;
+
+#  if TARGET_OS_DRIVERKIT
+  // Driverkit 25.0+ aligns with macOS 26+
+  if (*major >= 25) {
+    *major += 1;
+    return;
+  }
+#  else
+   // macOS 26 and later have aligned version strings.
+   if (*major >= 26)
+     return;
+#  endif
+
+  // Below are mappings for pre-macOS-25-aligned releases
   if (TARGET_OS_IOS || TARGET_OS_TV)
     *major += 2;
   else if (TARGET_OS_WATCH)



More information about the llvm-commits mailing list