[libcxx-commits] [libcxx] fa712b0 - [libc++] Build the dylib with sanitizers when requested (#73656)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Nov 29 06:29:48 PST 2023
Author: Louis Dionne
Date: 2023-11-29T09:29:44-05:00
New Revision: fa712b0764d30e415159537d3e89c994cdef73f9
URL: https://github.com/llvm/llvm-project/commit/fa712b0764d30e415159537d3e89c994cdef73f9
DIFF: https://github.com/llvm/llvm-project/commit/fa712b0764d30e415159537d3e89c994cdef73f9.diff
LOG: [libc++] Build the dylib with sanitizers when requested (#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.
Added:
Modified:
libcxx/CMakeLists.txt
Removed:
################################################################################
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 843ccbd0ed92edb..8572e7530fd363e 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -621,10 +621,10 @@ function(get_sanitizer_flags OUT_VAR USE_SANITIZER)
append_flags(SANITIZER_FLAGS "-fsanitize-memory-track-origins")
endif()
elseif (USE_SANITIZER STREQUAL "Undefined")
- append_flags(SANITIZER_FLAGS "-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all")
+ append_flags(SANITIZER_FLAGS "-fsanitize=undefined" "-fno-sanitize=vptr,function" "-fno-sanitize-recover=all")
elseif (USE_SANITIZER STREQUAL "Address;Undefined" OR
USE_SANITIZER STREQUAL "Undefined;Address")
- append_flags(SANITIZER_FLAGS "-fsanitize=address,undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all")
+ append_flags(SANITIZER_FLAGS "-fsanitize=address,undefined" "-fno-sanitize=vptr,function" "-fno-sanitize-recover=all")
elseif (USE_SANITIZER STREQUAL "Thread")
append_flags(SANITIZER_FLAGS -fsanitize=thread)
elseif (USE_SANITIZER STREQUAL "DataFlow")
@@ -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