[compiler-rt] 0606817 - [CMake] Handle in-tree libc++ for sanitizer tests
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 26 13:09:49 PST 2022
Author: Petr Hosek
Date: 2022-01-26T13:09:17-08:00
New Revision: 0606817d0b02321eaaf905e9c8246c63a1c0482f
URL: https://github.com/llvm/llvm-project/commit/0606817d0b02321eaaf905e9c8246c63a1c0482f
DIFF: https://github.com/llvm/llvm-project/commit/0606817d0b02321eaaf905e9c8246c63a1c0482f.diff
LOG: [CMake] Handle in-tree libc++ for sanitizer tests
We have been relying on the logic for C++ ABI library for sanitizer
tests but that's incorrect since most tests require a full C++ library
and not just C++ ABI. This change tries to address this by using the
dependency on libc++ if available.
Differential Revision: https://reviews.llvm.org/D118163
Added:
Modified:
compiler-rt/CMakeLists.txt
Removed:
################################################################################
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 12946d74c797b..063d41bfc0fdd 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -231,6 +231,15 @@ option(SANITIZER_USE_STATIC_CXX_ABI
"Use static libc++abi." ${DEFAULT_SANITIZER_USE_STATIC_CXX_ABI})
pythonize_bool(SANITIZER_USE_STATIC_CXX_ABI)
+set(DEFAULT_SANITIZER_USE_STATIC_TEST_CXX OFF)
+if (DEFINED LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_SHARED)
+ set(DEFAULT_SANITIZER_USE_STATIC_TEST_CXX ON)
+endif()
+
+option(SANITIZER_USE_STATIC_TEST_CXX
+ "Use static libc++ for tests." ${DEFAULT_SANITIZER_USE_STATIC_TEST_CXX})
+pythonize_bool(SANITIZER_USE_STATIC_TEST_CXX)
+
set(DEFAULT_COMPILER_RT_USE_BUILTINS_LIBRARY OFF)
if (FUCHSIA)
set(DEFAULT_COMPILER_RT_USE_BUILTINS_LIBRARY ON)
@@ -522,7 +531,15 @@ elseif (SANITIZER_CXX_ABI_LIBNAME STREQUAL "libstdc++")
endif()
if (SANITIZER_TEST_CXX_LIBNAME STREQUAL "libc++")
- append_libcxx_libs(SANITIZER_TEST_CXX)
+ if (SANITIZER_TEST_CXX_INTREE)
+ if (SANITIZER_USE_STATIC_TEST_CXX AND (TARGET cxx_static OR HAVE_LIBCXX))
+ list(APPEND SANITIZER_TEST_CXX_LIBRARIES cxx_static)
+ elseif (TARGET cxx_shared OR HAVE_LIBCXX)
+ list(APPEND SANITIZER_TEST_CXX_LIBRARIES cxx_shared)
+ endif()
+ else()
+ append_list_if(COMPILER_RT_HAS_LIBCXX c++ SANITIZER_TEST_CXX_LIBRARIES)
+ endif()
elseif (SANITIZER_TEST_CXX_LIBNAME STREQUAL "libstdc++")
append_list_if(COMPILER_RT_HAS_LIBSTDCXX stdc++ SANITIZER_TEST_CXX_LIBRARIES)
endif()
More information about the llvm-commits
mailing list