[libcxx-commits] [libcxx] [libc++] Build the dylib with sanitizers when requested (PR #73656)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 28 07:02:41 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/73656.diff


1 Files Affected:

- (modified) libcxx/CMakeLists.txt (+3) 


``````````diff
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()
 
 #===============================================================================

``````````

</details>


https://github.com/llvm/llvm-project/pull/73656


More information about the libcxx-commits mailing list