[compiler-rt] [ASan] Make duplicate_os_log_reports.cpp work with the internal shell (PR #168656)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 19 09:09:53 PST 2025


https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/168656

>From 56c965578ece9c61e0770b5e33e9f808d2921e15 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Wed, 19 Nov 2025 04:11:28 +0000
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.7

[skip ci]
---
 .../Darwin/dyld_insert_libraries_reexec.cpp   | 15 ++---------
 .../Darwin/interface_symbols_darwin.cpp       | 18 +++++++------
 .../asan/TestCases/Darwin/lit.local.cfg.py    | 25 +++++++++++++++++++
 3 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cpp b/compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cpp
index 145e162a21c0e..89ee7a178525a 100644
--- a/compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cpp
+++ b/compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cpp
@@ -14,23 +14,12 @@
 // RUN:       %run %t/a.out 2>&1 \
 // RUN:   | FileCheck %s
 
-// RUN: MACOS_MAJOR=$(sw_vers -productVersion | cut -d'.' -f1)
-// RUN: MACOS_MINOR=$(sw_vers -productVersion | cut -d'.' -f2)
-
-// RUN: IS_MACOS_10_11_OR_HIGHER=$([ $MACOS_MAJOR -eq 10 ] && [ $MACOS_MINOR -lt 11 ]; echo $?)
-
 // On OS X 10.10 and lower, if the dylib is not DYLD-inserted, ASan will re-exec.
-// RUN: if [ $IS_MACOS_10_11_OR_HIGHER == 0 ]; then \
-// RUN:   %env_asan_opts=verbosity=1 %run %t/a.out 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-NOINSERT %s; \
-// RUN:   fi
+// RUN: %if mac-os-10-11-or-higher %{ %env_asan_opts=verbosity=1 %run %t/a.out 2>&1 | FileCheck --check-prefix=CHECK-NOINSERT %s %}
 
 // On OS X 10.11 and higher, we don't need to DYLD-insert anymore, and the interceptors
 // still installed correctly. Let's just check that things work and we don't try to re-exec.
-// RUN: if [ $IS_MACOS_10_11_OR_HIGHER == 1 ]; then \
-// RUN:   %env_asan_opts=verbosity=1 %run %t/a.out 2>&1 \
-// RUN:   | FileCheck %s; \
-// RUN:   fi
+// RUN: %if mac-os-10-10-or-lower %{ %env_asan_opts=verbosity=1 %run %t/a.out 2>&1 | FileCheck %s %}
 
 #include <stdio.h>
 
diff --git a/compiler-rt/test/asan/TestCases/Darwin/interface_symbols_darwin.cpp b/compiler-rt/test/asan/TestCases/Darwin/interface_symbols_darwin.cpp
index 59dca32672901..ddf93881555f9 100644
--- a/compiler-rt/test/asan/TestCases/Darwin/interface_symbols_darwin.cpp
+++ b/compiler-rt/test/asan/TestCases/Darwin/interface_symbols_darwin.cpp
@@ -9,13 +9,17 @@
 // RUN: %clangxx_asan -dead_strip -O2 %s -o %t.exe
 //
 // note: we can not use -D on Darwin.
-// RUN: nm -g `%clang_asan %s -fsanitize=address -### 2>&1 | grep "libclang_rt.asan_osx_dynamic.dylib" | sed -e 's/.*"\(.*libclang_rt.asan_osx_dynamic.dylib\)".*/\1/'` \
-// RUN:  | grep " [TU] "                                                       \
-// RUN:  | grep -o "\(__asan_\|__ubsan_\|__sancov_\|__sanitizer_\)[^ ]*"       \
-// RUN:  | grep -v "__sanitizer_syscall"                                       \
-// RUN:  | grep -v "__sanitizer_weak_hook"                                     \
-// RUN:  | grep -v "__sanitizer_mz"                                            \
-// RUN:  | grep -v "__sancov_lowest_stack"                                     \
+// RUN: %clang_asan %s -fsanitize=address -### 2>&1                       \
+// RUN:   | grep "libclang_rt.asan_osx_dynamic.dylib"                     \
+// RUN:   | sed -e 's/.*"\(.*libclang_rt.asan_osx_dynamic.dylib\)".*/\1/' \
+// RUN:   | tr -d '\n' > %t.compiler_runtime_path
+// RUN: nm -g %{readfile:%t.compiler_runtime_path}                                         \
+// RUN:  | grep " [TU] "                                                                   \
+// RUN:  | grep -o "\(__asan_\|__ubsan_\|__sancov_\|__sanitizer_\)[^ ]*"                   \
+// RUN:  | grep -v "__sanitizer_syscall"                                                   \
+// RUN:  | grep -v "__sanitizer_weak_hook"                                                 \
+// RUN:  | grep -v "__sanitizer_mz"                                                        \
+// RUN:  | grep -v "__sancov_lowest_stack"                                                 \
 // RUN:  | sed -e "s/__asan_version_mismatch_check_v[0-9]+/__asan_version_mismatch_check/" \
 // RUN:  > %t.exports
 //
diff --git a/compiler-rt/test/asan/TestCases/Darwin/lit.local.cfg.py b/compiler-rt/test/asan/TestCases/Darwin/lit.local.cfg.py
index af82d30cf4de9..b09c1f7cd3daa 100644
--- a/compiler-rt/test/asan/TestCases/Darwin/lit.local.cfg.py
+++ b/compiler-rt/test/asan/TestCases/Darwin/lit.local.cfg.py
@@ -1,3 +1,6 @@
+import subprocess
+
+
 def getRoot(config):
     if not config.parent:
         return config
@@ -8,3 +11,25 @@ def getRoot(config):
 
 if root.target_os not in ["Darwin"]:
     config.unsupported = True
+
+
+def get_product_version():
+    try:
+        version_process = subprocess.run(
+            ["sw_vers", "-productVersion"],
+            check=True,
+            stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE,
+        )
+        version_string = version_process.stdout.decode("utf-8").split("\n")[0]
+        version_split = version_string.split(".")
+        return (int(version_split[0]), int(version_split[1]))
+    except:
+        return (0, 0)
+
+
+macos_version_major, macos_version_minor = get_product_version()
+if macos_version_major > 10 and macos_version_minor > 11:
+    config.available_features.add("mac-os-10-11-or-higher")
+else:
+    config.available_features.add("mac-os-10-10-or-lower")

>From e25e84c79a2db8203fef44fe194e645bc4b2b757 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Wed, 19 Nov 2025 16:55:22 +0000
Subject: [PATCH 2/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20introduced=20through=20rebase?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.7

[skip ci]
---
 compiler-rt/test/asan/TestCases/Darwin/lit.local.cfg.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/compiler-rt/test/asan/TestCases/Darwin/lit.local.cfg.py b/compiler-rt/test/asan/TestCases/Darwin/lit.local.cfg.py
index b09c1f7cd3daa..fc99cd78808e3 100644
--- a/compiler-rt/test/asan/TestCases/Darwin/lit.local.cfg.py
+++ b/compiler-rt/test/asan/TestCases/Darwin/lit.local.cfg.py
@@ -29,7 +29,8 @@ def get_product_version():
 
 
 macos_version_major, macos_version_minor = get_product_version()
-if macos_version_major > 10 and macos_version_minor > 11:
-    config.available_features.add("mac-os-10-11-or-higher")
-else:
-    config.available_features.add("mac-os-10-10-or-lower")
+if config.apple_platform == "osx":
+    if macos_version_major > 10 and macos_version_minor > 11:
+        config.available_features.add("mac-os-10-11-or-higher")
+    else:
+        config.available_features.add("mac-os-10-10-or-lower")



More information about the llvm-commits mailing list