[compiler-rt] [compiler-rt] [CMake] Add option to disable sanitizer-common builds by default (PR #160962)
Andrew Haberlandt via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 30 10:15:44 PDT 2025
https://github.com/ndrewh updated https://github.com/llvm/llvm-project/pull/160962
>From e2445ea1f847718ab9744e116af1ec1082c65936 Mon Sep 17 00:00:00 2001
From: Andrew Haberlandt <ahaberlandt at apple.com>
Date: Tue, 30 Sep 2025 10:10:35 -0700
Subject: [PATCH] [compiler-rt] [CMake] Only configure sanitizer-common if
_BUILD_ and _HAS_ a dep
LLVM_ENABLE_RUNTIMES uses the default build target for building compiler-rt,
which means a bunch of stuff gets built that isn't necessarily depended upon
(and wasn't getting built under LLVM_ENABLE_PROJECTS).
Right now, we configure sanitizer_common (and thus it gets built in the default
build) based on COMPILER_RT_BUILD_* options. However, compiler_rt_build_runtime
also uses the _HAS option to determine whether to configure a project.
Thus, there are cases where we are configuring (and building with the default
target) sanitizer-common when we do not need it. This change helps to slim
down builds of compiler-rt that do not need sanitizer-common built.
---
compiler-rt/lib/CMakeLists.txt | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/compiler-rt/lib/CMakeLists.txt b/compiler-rt/lib/CMakeLists.txt
index e6158ec408895..42a57eaa70384 100644
--- a/compiler-rt/lib/CMakeLists.txt
+++ b/compiler-rt/lib/CMakeLists.txt
@@ -9,7 +9,10 @@ include(SanitizerUtils)
#
#TODO: Refactor sanitizer_common into smaller pieces (e.g. flag parsing, utils).
if (COMPILER_RT_HAS_SANITIZER_COMMON AND
- (COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_XRAY OR COMPILER_RT_BUILD_MEMPROF OR COMPILER_RT_BUILD_CTX_PROFILE))
+ (COMPILER_RT_BUILD_SANITIZERS OR
+ (COMPILER_RT_HAS_XRAY AND COMPILER_RT_BUILD_XRAY) OR
+ (COMPILER_RT_HAS_MEMPROF AND COMPILER_RT_BUILD_MEMPROF) OR
+ (COMPILER_RT_HAS_CTX_PROFILE AND COMPILER_RT_BUILD_CTX_PROFILE)))
add_subdirectory(sanitizer_common)
endif()
More information about the llvm-commits
mailing list