[Lldb-commits] [lldb] [LLDB] Fix ASAN tests on newer versions of macOS (PR #165883)

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 31 09:48:35 PDT 2025


https://github.com/adrian-prantl created https://github.com/llvm/llvm-project/pull/165883

macOS forbids injecting the ASAN runtime into system processes when SIP is enabled. That includes the just-built libLTO that the just-built clang injects into the system linker.  Since we don't test the compiler here, just use the system (non-asanified) LTO library to make ASAN tests work for most users, including the bots.

>From 86cf6352ed661c5e261824b81421548c0f465d53 Mon Sep 17 00:00:00 2001
From: Adrian Prantl <aprantl at apple.com>
Date: Fri, 31 Oct 2025 09:46:51 -0700
Subject: [PATCH] [LLDB] Fix ASAN tests on newer versions of macOS

macOS forbids injecting the ASAN runtime into system processes when
SIP is enabled. That includes the just-built libLTO that the
just-built clang injects into the system linker.  Since we don't
test the compiler here, just use the system (non-asanified) LTO
library to make ASAN tests work for most users, including the bots.
---
 .../Python/lldbsuite/test/make/Makefile.rules         | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index 09939e29e5b75..28cae54776ac8 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -322,6 +322,17 @@ ifeq (,$(filter $(OS), Windows_NT Android Darwin))
 		LDFLAGS += -pthread
 	endif
 endif
+
+# macOS forbids injecting the ASAN runtime into system processes when
+# SIP is enabled. That includes the just-built libLTO that the
+# just-built clang injects into the system linker.  Since we don't
+# test the compiler here, just use the system (non-asanified) LTO
+# library to make ASAN tests work for most users, including the bots.
+ifeq "$(OS)" "Darwin"
+ifneq "$(ASAN_OPTIONS)" ""
+LD_FLAGS += -Wl,-lto_library -Wl,$(shell dirname $(shell xcrun -find clang))/../lib/libLTO.dylib
+endif
+endif
 OBJECTS =
 EXE ?= a.out
 



More information about the lldb-commits mailing list