[compiler-rt] [compiler-rt] Move sanitizer ignorelists to sanitizer-ignorelists target (PR #200518)
Andrew Haberlandt via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 17 13:53:28 PDT 2026
https://github.com/ndrewh updated https://github.com/llvm/llvm-project/pull/200518
>From c84cce2d28fb28de66bd469ecd699d6cddd85def Mon Sep 17 00:00:00 2001
From: Andrew Haberlandt <ahaberlandt at apple.com>
Date: Fri, 29 May 2026 14:52:02 -0700
Subject: [PATCH 1/4] [compiler-rt] Move ignorelists to sanitizer-ignorelists
target
This adds a sanitizer-ignorelists target to compiler-rt, allowing
the ignorelists to be built independently of compiler-rt
---
compiler-rt/CMakeLists.txt | 4 ++
compiler-rt/cmake/Modules/AddCompilerRT.cmake | 17 ------
compiler-rt/lib/CMakeLists.txt | 9 +++
compiler-rt/lib/asan/CMakeLists.txt | 10 +++-
compiler-rt/lib/cfi/CMakeLists.txt | 10 +++-
compiler-rt/lib/hwasan/CMakeLists.txt | 10 +++-
compiler-rt/lib/msan/CMakeLists.txt | 12 +++-
.../lib/sanitizer_ignorelists/CMakeLists.txt | 56 +++++++++++++++++++
.../asan_ignorelist.txt | 0
.../cfi_ignorelist.txt | 0
.../hwasan_ignorelist.txt | 0
.../msan_ignorelist.txt | 0
12 files changed, 106 insertions(+), 22 deletions(-)
create mode 100644 compiler-rt/lib/sanitizer_ignorelists/CMakeLists.txt
rename compiler-rt/lib/{asan => sanitizer_ignorelists}/asan_ignorelist.txt (100%)
rename compiler-rt/lib/{cfi => sanitizer_ignorelists}/cfi_ignorelist.txt (100%)
rename compiler-rt/lib/{hwasan => sanitizer_ignorelists}/hwasan_ignorelist.txt (100%)
rename compiler-rt/lib/{msan => sanitizer_ignorelists}/msan_ignorelist.txt (100%)
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index e88321d822f84..f8cf1a19016db 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -74,6 +74,10 @@ option(COMPILER_RT_DISABLE_AARCH64_FMV "Disable AArch64 Function Multi Versionin
mark_as_advanced(COMPILER_RT_DISABLE_AARCH64_FMV)
option(COMPILER_RT_BUILD_SANITIZERS "Build sanitizers" ON)
mark_as_advanced(COMPILER_RT_BUILD_SANITIZERS)
+option(COMPILER_RT_BUILD_SANITIZER_IGNORELISTS
+ "Build the default sanitizer ignorelists consumed by the compiler driver. Can be built independently of the sanitizer runtimes."
+ ${COMPILER_RT_BUILD_SANITIZERS})
+mark_as_advanced(COMPILER_RT_BUILD_SANITIZER_IGNORELISTS)
option(COMPILER_RT_BUILD_XRAY "Build xray" ON)
mark_as_advanced(COMPILER_RT_BUILD_XRAY)
option(COMPILER_RT_BUILD_LIBFUZZER "Build libFuzzer" ON)
diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index 1d4ad85868b29..d1de769f150e4 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -561,23 +561,6 @@ function(add_compiler_rt_test test_suite test_name arch)
add_dependencies(${test_suite} T${test_name})
endfunction()
-macro(add_compiler_rt_resource_file target_name file_name component)
- set(src_file "${CMAKE_CURRENT_SOURCE_DIR}/${file_name}")
- set(dst_file "${COMPILER_RT_OUTPUT_DIR}/share/${file_name}")
- add_custom_command(OUTPUT ${dst_file}
- DEPENDS ${src_file}
- COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src_file} ${dst_file}
- COMMENT "Copying ${file_name}...")
- add_custom_target(${target_name} DEPENDS ${dst_file})
- # Install in Clang resource directory.
- install(FILES ${file_name}
- DESTINATION ${COMPILER_RT_INSTALL_DATA_DIR}
- COMPONENT ${component})
- add_dependencies(${component} ${target_name})
-
- set_target_properties(${target_name} PROPERTIES FOLDER "Compiler-RT/Resources")
-endmacro()
-
macro(add_compiler_rt_script name)
set(dst ${COMPILER_RT_EXEC_OUTPUT_DIR}/${name})
set(src ${CMAKE_CURRENT_SOURCE_DIR}/${name})
diff --git a/compiler-rt/lib/CMakeLists.txt b/compiler-rt/lib/CMakeLists.txt
index e6158ec408895..e60a5959e4ceb 100644
--- a/compiler-rt/lib/CMakeLists.txt
+++ b/compiler-rt/lib/CMakeLists.txt
@@ -35,6 +35,15 @@ if(COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_MEMPROF)
compiler_rt_build_runtime(interception)
endif()
+# The sanitizer ignorelists are consumed by the compiler driver, not linked
+# into the runtimes. Build them as their own target so they can be built
+# independently of the runtime libraries. Gated by its own option (defaulting
+# to COMPILER_RT_BUILD_SANITIZERS) and added before the runtimes so the target
+# exists when they declare a dependency on it.
+if(COMPILER_RT_BUILD_SANITIZER_IGNORELISTS)
+ add_subdirectory(sanitizer_ignorelists)
+endif()
+
if(COMPILER_RT_BUILD_SANITIZERS)
if(COMPILER_RT_HAS_SANITIZER_COMMON)
add_subdirectory(stats)
diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt
index 6085f18426dff..2272235cc9e7a 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -392,7 +392,15 @@ else()
endif()
endif()
-add_compiler_rt_resource_file(asan_ignorelist asan_ignorelist.txt asan)
+# Build the sanitizer ignorelists alongside asan when they are enabled.
+if(TARGET sanitizer-ignorelists)
+ add_dependencies(asan sanitizer-ignorelists)
+ # Installing/distributing asan also installs the sanitizer ignorelists.
+ if(TARGET install-asan)
+ add_dependencies(install-asan install-sanitizer-ignorelists)
+ add_dependencies(install-asan-stripped install-sanitizer-ignorelists-stripped)
+ endif()
+endif()
# On AIX, static sanitizer libraries are not added to the DSO, so we need to put
# asan.link_with_main_exec.txt and asan_cxx.link_with_main_exec.txt to the build
diff --git a/compiler-rt/lib/cfi/CMakeLists.txt b/compiler-rt/lib/cfi/CMakeLists.txt
index 2197fa4a5c758..7d21d16c95f67 100644
--- a/compiler-rt/lib/cfi/CMakeLists.txt
+++ b/compiler-rt/lib/cfi/CMakeLists.txt
@@ -43,4 +43,12 @@ if(OS_NAME MATCHES "Linux" OR OS_NAME MATCHES "FreeBSD" OR OS_NAME MATCHES "NetB
endforeach()
endif()
-add_compiler_rt_resource_file(cfi_ignorelist cfi_ignorelist.txt cfi)
+# Build the sanitizer ignorelists alongside cfi when they are enabled.
+if(TARGET sanitizer-ignorelists)
+ add_dependencies(cfi sanitizer-ignorelists)
+ # Installing/distributing cfi also installs the sanitizer ignorelists.
+ if(TARGET install-cfi)
+ add_dependencies(install-cfi install-sanitizer-ignorelists)
+ add_dependencies(install-cfi-stripped install-sanitizer-ignorelists-stripped)
+ endif()
+endif()
diff --git a/compiler-rt/lib/hwasan/CMakeLists.txt b/compiler-rt/lib/hwasan/CMakeLists.txt
index 207394130d035..c04603e91e3a9 100644
--- a/compiler-rt/lib/hwasan/CMakeLists.txt
+++ b/compiler-rt/lib/hwasan/CMakeLists.txt
@@ -259,7 +259,15 @@ add_compiler_rt_runtime(clang_rt.hwasan-preinit
CFLAGS ${HWASAN_RTL_CFLAGS}
PARENT_TARGET hwasan)
-add_compiler_rt_resource_file(hwasan_ignorelist hwasan_ignorelist.txt hwasan)
+# Build the sanitizer ignorelists alongside hwasan when they are enabled.
+if(TARGET sanitizer-ignorelists)
+ add_dependencies(hwasan sanitizer-ignorelists)
+ # Installing/distributing hwasan also installs the sanitizer ignorelists.
+ if(TARGET install-hwasan)
+ add_dependencies(install-hwasan install-sanitizer-ignorelists)
+ add_dependencies(install-hwasan-stripped install-sanitizer-ignorelists-stripped)
+ endif()
+endif()
add_subdirectory("scripts")
diff --git a/compiler-rt/lib/msan/CMakeLists.txt b/compiler-rt/lib/msan/CMakeLists.txt
index a0b9c61584c98..c2ac6debbf650 100644
--- a/compiler-rt/lib/msan/CMakeLists.txt
+++ b/compiler-rt/lib/msan/CMakeLists.txt
@@ -83,8 +83,16 @@ foreach(arch ${MSAN_SUPPORTED_ARCH})
endif()
endforeach()
-add_compiler_rt_resource_file(msan_ignorelist msan_ignorelist.txt msan)
-list(APPEND MSAN_RUNTIME_LIBRARIES msan_ignorelist)
+# Build the sanitizer ignorelists alongside msan when they are enabled.
+if(TARGET sanitizer-ignorelists)
+ add_dependencies(msan sanitizer-ignorelists)
+ list(APPEND MSAN_RUNTIME_LIBRARIES sanitizer-ignorelists)
+ # Installing/distributing msan also installs the sanitizer ignorelists.
+ if(TARGET install-msan)
+ add_dependencies(install-msan install-sanitizer-ignorelists)
+ add_dependencies(install-msan-stripped install-sanitizer-ignorelists-stripped)
+ endif()
+endif()
if(COMPILER_RT_INCLUDE_TESTS)
add_subdirectory(tests)
diff --git a/compiler-rt/lib/sanitizer_ignorelists/CMakeLists.txt b/compiler-rt/lib/sanitizer_ignorelists/CMakeLists.txt
new file mode 100644
index 0000000000000..44517e76ae4b2
--- /dev/null
+++ b/compiler-rt/lib/sanitizer_ignorelists/CMakeLists.txt
@@ -0,0 +1,56 @@
+# The sanitizer ignorelists are default special-case lists that the Clang
+# driver passes to the compiler (via -fsanitize-system-ignorelist) when the
+# corresponding sanitizer is enabled. They are consumed by the compiler rather
+# than linked into any runtime library, so they are built by their own target
+# that does not depend on the sanitizer runtimes and can be built on its own.
+add_compiler_rt_component(sanitizer-ignorelists)
+
+set(SANITIZER_IGNORELIST_FILES
+ asan_ignorelist.txt
+ cfi_ignorelist.txt
+ hwasan_ignorelist.txt
+ msan_ignorelist.txt
+ )
+
+set(sanitizer_ignorelist_outputs)
+foreach(file_name ${SANITIZER_IGNORELIST_FILES})
+ set(src_file "${CMAKE_CURRENT_SOURCE_DIR}/${file_name}")
+ set(dst_file "${COMPILER_RT_OUTPUT_DIR}/share/${file_name}")
+ add_custom_command(OUTPUT ${dst_file}
+ DEPENDS ${src_file}
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src_file} ${dst_file}
+ COMMENT "Copying ${file_name}...")
+ list(APPEND sanitizer_ignorelist_outputs ${dst_file})
+endforeach()
+
+add_custom_target(sanitizer-ignorelist-files DEPENDS ${sanitizer_ignorelist_outputs})
+set_target_properties(sanitizer-ignorelist-files PROPERTIES FOLDER "Compiler-RT/Resources")
+add_dependencies(sanitizer-ignorelists sanitizer-ignorelist-files)
+
+# Install in the Clang resource directory. Each sanitizer runtime's install
+# target (install-asan, install-hwasan, ...) depends on
+# install-sanitizer-ignorelists, so installing or distributing any sanitizer
+# also installs the ignorelists. These install targets are created
+# unconditionally (like compiler-rt's other parent install targets) so the
+# runtime install targets can depend on them under multi-config generators too.
+install(FILES ${SANITIZER_IGNORELIST_FILES}
+ DESTINATION ${COMPILER_RT_INSTALL_DATA_DIR}
+ COMPONENT sanitizer-ignorelists)
+
+add_custom_target(install-sanitizer-ignorelists
+ DEPENDS sanitizer-ignorelists
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=sanitizer-ignorelists
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+add_custom_target(install-sanitizer-ignorelists-stripped
+ DEPENDS sanitizer-ignorelists
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=sanitizer-ignorelists
+ -DCMAKE_INSTALL_DO_STRIP=1
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+set_target_properties(install-sanitizer-ignorelists PROPERTIES
+ FOLDER "Compiler-RT/Installation")
+set_target_properties(install-sanitizer-ignorelists-stripped PROPERTIES
+ FOLDER "Compiler-RT/Installation")
+add_dependencies(install-compiler-rt install-sanitizer-ignorelists)
+add_dependencies(install-compiler-rt-stripped install-sanitizer-ignorelists-stripped)
diff --git a/compiler-rt/lib/asan/asan_ignorelist.txt b/compiler-rt/lib/sanitizer_ignorelists/asan_ignorelist.txt
similarity index 100%
rename from compiler-rt/lib/asan/asan_ignorelist.txt
rename to compiler-rt/lib/sanitizer_ignorelists/asan_ignorelist.txt
diff --git a/compiler-rt/lib/cfi/cfi_ignorelist.txt b/compiler-rt/lib/sanitizer_ignorelists/cfi_ignorelist.txt
similarity index 100%
rename from compiler-rt/lib/cfi/cfi_ignorelist.txt
rename to compiler-rt/lib/sanitizer_ignorelists/cfi_ignorelist.txt
diff --git a/compiler-rt/lib/hwasan/hwasan_ignorelist.txt b/compiler-rt/lib/sanitizer_ignorelists/hwasan_ignorelist.txt
similarity index 100%
rename from compiler-rt/lib/hwasan/hwasan_ignorelist.txt
rename to compiler-rt/lib/sanitizer_ignorelists/hwasan_ignorelist.txt
diff --git a/compiler-rt/lib/msan/msan_ignorelist.txt b/compiler-rt/lib/sanitizer_ignorelists/msan_ignorelist.txt
similarity index 100%
rename from compiler-rt/lib/msan/msan_ignorelist.txt
rename to compiler-rt/lib/sanitizer_ignorelists/msan_ignorelist.txt
>From fa0d253465d61cdc07e65253f93180f0560ab746 Mon Sep 17 00:00:00 2001
From: Andrew Haberlandt <ahaberlandt at apple.com>
Date: Mon, 29 Jun 2026 10:43:43 -0700
Subject: [PATCH 2/4] Remove -stripped target
---
compiler-rt/lib/asan/CMakeLists.txt | 2 +-
compiler-rt/lib/cfi/CMakeLists.txt | 2 +-
compiler-rt/lib/hwasan/CMakeLists.txt | 2 +-
compiler-rt/lib/msan/CMakeLists.txt | 2 +-
.../lib/sanitizer_ignorelists/CMakeLists.txt | 19 ++++---------------
5 files changed, 8 insertions(+), 19 deletions(-)
diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt
index 2272235cc9e7a..b315b5f4fe196 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -398,7 +398,7 @@ if(TARGET sanitizer-ignorelists)
# Installing/distributing asan also installs the sanitizer ignorelists.
if(TARGET install-asan)
add_dependencies(install-asan install-sanitizer-ignorelists)
- add_dependencies(install-asan-stripped install-sanitizer-ignorelists-stripped)
+ add_dependencies(install-asan-stripped install-sanitizer-ignorelists)
endif()
endif()
diff --git a/compiler-rt/lib/cfi/CMakeLists.txt b/compiler-rt/lib/cfi/CMakeLists.txt
index 7d21d16c95f67..9b1ee0abfd0e3 100644
--- a/compiler-rt/lib/cfi/CMakeLists.txt
+++ b/compiler-rt/lib/cfi/CMakeLists.txt
@@ -49,6 +49,6 @@ if(TARGET sanitizer-ignorelists)
# Installing/distributing cfi also installs the sanitizer ignorelists.
if(TARGET install-cfi)
add_dependencies(install-cfi install-sanitizer-ignorelists)
- add_dependencies(install-cfi-stripped install-sanitizer-ignorelists-stripped)
+ add_dependencies(install-cfi-stripped install-sanitizer-ignorelists)
endif()
endif()
diff --git a/compiler-rt/lib/hwasan/CMakeLists.txt b/compiler-rt/lib/hwasan/CMakeLists.txt
index c04603e91e3a9..1da4d77399bbe 100644
--- a/compiler-rt/lib/hwasan/CMakeLists.txt
+++ b/compiler-rt/lib/hwasan/CMakeLists.txt
@@ -265,7 +265,7 @@ if(TARGET sanitizer-ignorelists)
# Installing/distributing hwasan also installs the sanitizer ignorelists.
if(TARGET install-hwasan)
add_dependencies(install-hwasan install-sanitizer-ignorelists)
- add_dependencies(install-hwasan-stripped install-sanitizer-ignorelists-stripped)
+ add_dependencies(install-hwasan-stripped install-sanitizer-ignorelists)
endif()
endif()
diff --git a/compiler-rt/lib/msan/CMakeLists.txt b/compiler-rt/lib/msan/CMakeLists.txt
index c2ac6debbf650..5bdb19c6aa98b 100644
--- a/compiler-rt/lib/msan/CMakeLists.txt
+++ b/compiler-rt/lib/msan/CMakeLists.txt
@@ -90,7 +90,7 @@ if(TARGET sanitizer-ignorelists)
# Installing/distributing msan also installs the sanitizer ignorelists.
if(TARGET install-msan)
add_dependencies(install-msan install-sanitizer-ignorelists)
- add_dependencies(install-msan-stripped install-sanitizer-ignorelists-stripped)
+ add_dependencies(install-msan-stripped install-sanitizer-ignorelists)
endif()
endif()
diff --git a/compiler-rt/lib/sanitizer_ignorelists/CMakeLists.txt b/compiler-rt/lib/sanitizer_ignorelists/CMakeLists.txt
index 44517e76ae4b2..0681e624f3119 100644
--- a/compiler-rt/lib/sanitizer_ignorelists/CMakeLists.txt
+++ b/compiler-rt/lib/sanitizer_ignorelists/CMakeLists.txt
@@ -27,12 +27,9 @@ add_custom_target(sanitizer-ignorelist-files DEPENDS ${sanitizer_ignorelist_outp
set_target_properties(sanitizer-ignorelist-files PROPERTIES FOLDER "Compiler-RT/Resources")
add_dependencies(sanitizer-ignorelists sanitizer-ignorelist-files)
-# Install in the Clang resource directory. Each sanitizer runtime's install
-# target (install-asan, install-hwasan, ...) depends on
-# install-sanitizer-ignorelists, so installing or distributing any sanitizer
-# also installs the ignorelists. These install targets are created
-# unconditionally (like compiler-rt's other parent install targets) so the
-# runtime install targets can depend on them under multi-config generators too.
+# Install in the Clang resource directory. No -stripped variant: the ignorelists
+# are plain text, so both the stripped and unstripped install targets depend on
+# this one.
install(FILES ${SANITIZER_IGNORELIST_FILES}
DESTINATION ${COMPILER_RT_INSTALL_DATA_DIR}
COMPONENT sanitizer-ignorelists)
@@ -42,15 +39,7 @@ add_custom_target(install-sanitizer-ignorelists
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=sanitizer-ignorelists
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
-add_custom_target(install-sanitizer-ignorelists-stripped
- DEPENDS sanitizer-ignorelists
- COMMAND "${CMAKE_COMMAND}"
- -DCMAKE_INSTALL_COMPONENT=sanitizer-ignorelists
- -DCMAKE_INSTALL_DO_STRIP=1
- -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
set_target_properties(install-sanitizer-ignorelists PROPERTIES
FOLDER "Compiler-RT/Installation")
-set_target_properties(install-sanitizer-ignorelists-stripped PROPERTIES
- FOLDER "Compiler-RT/Installation")
add_dependencies(install-compiler-rt install-sanitizer-ignorelists)
-add_dependencies(install-compiler-rt-stripped install-sanitizer-ignorelists-stripped)
+add_dependencies(install-compiler-rt-stripped install-sanitizer-ignorelists)
>From 17542621470746a4df78630001d6bf45dcc10cb0 Mon Sep 17 00:00:00 2001
From: Andrew Haberlandt <ahaberlandt at apple.com>
Date: Thu, 9 Jul 2026 09:58:00 -0700
Subject: [PATCH 3/4] Remove unnecessary CMake option + macroize w/
add_sanitizer_ignorelists_dependency
---
compiler-rt/CMakeLists.txt | 4 ----
compiler-rt/cmake/Modules/AddCompilerRT.cmake | 11 +++++++++++
compiler-rt/lib/CMakeLists.txt | 14 +++++---------
compiler-rt/lib/asan/CMakeLists.txt | 10 +---------
compiler-rt/lib/cfi/CMakeLists.txt | 10 +---------
compiler-rt/lib/hwasan/CMakeLists.txt | 10 +---------
compiler-rt/lib/msan/CMakeLists.txt | 12 ++----------
7 files changed, 21 insertions(+), 50 deletions(-)
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index f8cf1a19016db..e88321d822f84 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -74,10 +74,6 @@ option(COMPILER_RT_DISABLE_AARCH64_FMV "Disable AArch64 Function Multi Versionin
mark_as_advanced(COMPILER_RT_DISABLE_AARCH64_FMV)
option(COMPILER_RT_BUILD_SANITIZERS "Build sanitizers" ON)
mark_as_advanced(COMPILER_RT_BUILD_SANITIZERS)
-option(COMPILER_RT_BUILD_SANITIZER_IGNORELISTS
- "Build the default sanitizer ignorelists consumed by the compiler driver. Can be built independently of the sanitizer runtimes."
- ${COMPILER_RT_BUILD_SANITIZERS})
-mark_as_advanced(COMPILER_RT_BUILD_SANITIZER_IGNORELISTS)
option(COMPILER_RT_BUILD_XRAY "Build xray" ON)
mark_as_advanced(COMPILER_RT_BUILD_XRAY)
option(COMPILER_RT_BUILD_LIBFUZZER "Build libFuzzer" ON)
diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index d1de769f150e4..88c8dab225a88 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -794,6 +794,17 @@ function(rt_externalize_debuginfo name)
endfunction()
+# Wire a sanitizer runtime target up to the sanitizer-ignorelists target so
+# that building/installing the runtime also builds/installs the ignorelists.
+macro(add_sanitizer_ignorelists_dependency name)
+ add_dependencies(${name} sanitizer-ignorelists)
+ if(TARGET install-${name})
+ add_dependencies(install-${name} install-sanitizer-ignorelists)
+ add_dependencies(install-${name}-stripped install-sanitizer-ignorelists)
+ endif()
+endmacro()
+
+
# Configure lit configuration files, including compiler-rt specific variables.
function(configure_compiler_rt_lit_site_cfg input output)
set_llvm_build_mode()
diff --git a/compiler-rt/lib/CMakeLists.txt b/compiler-rt/lib/CMakeLists.txt
index e60a5959e4ceb..f2880852975a1 100644
--- a/compiler-rt/lib/CMakeLists.txt
+++ b/compiler-rt/lib/CMakeLists.txt
@@ -35,15 +35,6 @@ if(COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_MEMPROF)
compiler_rt_build_runtime(interception)
endif()
-# The sanitizer ignorelists are consumed by the compiler driver, not linked
-# into the runtimes. Build them as their own target so they can be built
-# independently of the runtime libraries. Gated by its own option (defaulting
-# to COMPILER_RT_BUILD_SANITIZERS) and added before the runtimes so the target
-# exists when they declare a dependency on it.
-if(COMPILER_RT_BUILD_SANITIZER_IGNORELISTS)
- add_subdirectory(sanitizer_ignorelists)
-endif()
-
if(COMPILER_RT_BUILD_SANITIZERS)
if(COMPILER_RT_HAS_SANITIZER_COMMON)
add_subdirectory(stats)
@@ -56,6 +47,11 @@ if(COMPILER_RT_BUILD_SANITIZERS)
foreach(sanitizer ${COMPILER_RT_SANITIZERS_TO_BUILD})
compiler_rt_build_runtime(${sanitizer})
endforeach()
+
+ # The sanitizer ignorelists are consumed by the compiler driver, not linked
+ # into the runtimes. Build them as their own target so they can be built
+ # independently of the runtime libraries.
+ add_subdirectory(sanitizer_ignorelists)
endif()
if(COMPILER_RT_BUILD_PROFILE)
diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt
index b315b5f4fe196..fc777ed33099e 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -392,15 +392,7 @@ else()
endif()
endif()
-# Build the sanitizer ignorelists alongside asan when they are enabled.
-if(TARGET sanitizer-ignorelists)
- add_dependencies(asan sanitizer-ignorelists)
- # Installing/distributing asan also installs the sanitizer ignorelists.
- if(TARGET install-asan)
- add_dependencies(install-asan install-sanitizer-ignorelists)
- add_dependencies(install-asan-stripped install-sanitizer-ignorelists)
- endif()
-endif()
+add_sanitizer_ignorelists_dependency(asan)
# On AIX, static sanitizer libraries are not added to the DSO, so we need to put
# asan.link_with_main_exec.txt and asan_cxx.link_with_main_exec.txt to the build
diff --git a/compiler-rt/lib/cfi/CMakeLists.txt b/compiler-rt/lib/cfi/CMakeLists.txt
index 9b1ee0abfd0e3..9bdde05728cd5 100644
--- a/compiler-rt/lib/cfi/CMakeLists.txt
+++ b/compiler-rt/lib/cfi/CMakeLists.txt
@@ -43,12 +43,4 @@ if(OS_NAME MATCHES "Linux" OR OS_NAME MATCHES "FreeBSD" OR OS_NAME MATCHES "NetB
endforeach()
endif()
-# Build the sanitizer ignorelists alongside cfi when they are enabled.
-if(TARGET sanitizer-ignorelists)
- add_dependencies(cfi sanitizer-ignorelists)
- # Installing/distributing cfi also installs the sanitizer ignorelists.
- if(TARGET install-cfi)
- add_dependencies(install-cfi install-sanitizer-ignorelists)
- add_dependencies(install-cfi-stripped install-sanitizer-ignorelists)
- endif()
-endif()
+add_sanitizer_ignorelists_dependency(cfi)
diff --git a/compiler-rt/lib/hwasan/CMakeLists.txt b/compiler-rt/lib/hwasan/CMakeLists.txt
index 1da4d77399bbe..e7383d87c51d9 100644
--- a/compiler-rt/lib/hwasan/CMakeLists.txt
+++ b/compiler-rt/lib/hwasan/CMakeLists.txt
@@ -259,15 +259,7 @@ add_compiler_rt_runtime(clang_rt.hwasan-preinit
CFLAGS ${HWASAN_RTL_CFLAGS}
PARENT_TARGET hwasan)
-# Build the sanitizer ignorelists alongside hwasan when they are enabled.
-if(TARGET sanitizer-ignorelists)
- add_dependencies(hwasan sanitizer-ignorelists)
- # Installing/distributing hwasan also installs the sanitizer ignorelists.
- if(TARGET install-hwasan)
- add_dependencies(install-hwasan install-sanitizer-ignorelists)
- add_dependencies(install-hwasan-stripped install-sanitizer-ignorelists)
- endif()
-endif()
+add_sanitizer_ignorelists_dependency(hwasan)
add_subdirectory("scripts")
diff --git a/compiler-rt/lib/msan/CMakeLists.txt b/compiler-rt/lib/msan/CMakeLists.txt
index 5bdb19c6aa98b..c5e6ab31ef5db 100644
--- a/compiler-rt/lib/msan/CMakeLists.txt
+++ b/compiler-rt/lib/msan/CMakeLists.txt
@@ -83,16 +83,8 @@ foreach(arch ${MSAN_SUPPORTED_ARCH})
endif()
endforeach()
-# Build the sanitizer ignorelists alongside msan when they are enabled.
-if(TARGET sanitizer-ignorelists)
- add_dependencies(msan sanitizer-ignorelists)
- list(APPEND MSAN_RUNTIME_LIBRARIES sanitizer-ignorelists)
- # Installing/distributing msan also installs the sanitizer ignorelists.
- if(TARGET install-msan)
- add_dependencies(install-msan install-sanitizer-ignorelists)
- add_dependencies(install-msan-stripped install-sanitizer-ignorelists)
- endif()
-endif()
+add_sanitizer_ignorelists_dependency(msan)
+list(APPEND MSAN_RUNTIME_LIBRARIES sanitizer-ignorelists)
if(COMPILER_RT_INCLUDE_TESTS)
add_subdirectory(tests)
>From c42278890a7b137b702e389e19f3ac5d30fee7dd Mon Sep 17 00:00:00 2001
From: Andrew Haberlandt <ahaberlandt at apple.com>
Date: Fri, 17 Jul 2026 13:52:56 -0700
Subject: [PATCH 4/4] Fix sanitizer_ignorelists target oder
---
compiler-rt/lib/CMakeLists.txt | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/compiler-rt/lib/CMakeLists.txt b/compiler-rt/lib/CMakeLists.txt
index f2880852975a1..a5b2fbb38762c 100644
--- a/compiler-rt/lib/CMakeLists.txt
+++ b/compiler-rt/lib/CMakeLists.txt
@@ -36,6 +36,11 @@ if(COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_MEMPROF)
endif()
if(COMPILER_RT_BUILD_SANITIZERS)
+ # The sanitizer ignorelists are consumed by the compiler driver, not linked
+ # into the runtimes. Build them as their own target so they can be built
+ # independently of the runtime libraries.
+ add_subdirectory(sanitizer_ignorelists)
+
if(COMPILER_RT_HAS_SANITIZER_COMMON)
add_subdirectory(stats)
# Contains RTLSanCommon used even without COMPILER_RT_HAS_LSAN.
@@ -47,11 +52,6 @@ if(COMPILER_RT_BUILD_SANITIZERS)
foreach(sanitizer ${COMPILER_RT_SANITIZERS_TO_BUILD})
compiler_rt_build_runtime(${sanitizer})
endforeach()
-
- # The sanitizer ignorelists are consumed by the compiler driver, not linked
- # into the runtimes. Build them as their own target so they can be built
- # independently of the runtime libraries.
- add_subdirectory(sanitizer_ignorelists)
endif()
if(COMPILER_RT_BUILD_PROFILE)
More information about the llvm-commits
mailing list