[libcxx-commits] [libcxx] [libc++] Build the dylib with sanitizers when requested (PR #73656)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Nov 28 07:02:10 PST 2023
https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/73656
We were detecting which sanitizer flags to use when building libc++.dylib but we were never actually adding those flags to the targets, which means that our sanitized builds would basically build the dylib without any sanitizers enabled.
>From f14d36a750b1fedd4013c938233610c2eb60014d Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 28 Nov 2023 10:00:37 -0500
Subject: [PATCH] [libc++] Build the dylib with sanitizers when requested
We were detecting which sanitizer flags to use when building libc++.dylib
but we were never actually adding those flags to the targets, which means
that our sanitized builds would basically build the dylib without any
sanitizers enabled.
---
libcxx/CMakeLists.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 843ccbd0ed92edb..f32f9dc22e8bea6 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -639,6 +639,8 @@ function(get_sanitizer_flags OUT_VAR USE_SANITIZER)
endfunction()
get_sanitizer_flags(SANITIZER_FLAGS "${LLVM_USE_SANITIZER}")
+add_library(cxx-sanitizer-flags INTERFACE)
+target_compile_options(cxx-sanitizer-flags INTERFACE ${SANITIZER_FLAGS})
# Link system libraries =======================================================
function(cxx_link_system_libraries target)
@@ -821,6 +823,7 @@ function(cxx_add_common_build_flags target)
cxx_add_rtti_flags(${target})
cxx_add_module_flags(${target})
cxx_link_system_libraries(${target})
+ target_link_libraries(${target} PRIVATE cxx-sanitizer-flags)
endfunction()
#===============================================================================
More information about the libcxx-commits
mailing list