diff options
author | Jonas Hahnfeld <hahnjo@hahnjo.de> | 2019-02-16 08:34:26 +0000 |
---|---|---|
committer | Jonas Hahnfeld <hahnjo@hahnjo.de> | 2019-02-16 08:34:26 +0000 |
commit | 3b34e7c533ea8837a1e11e14131edeb565a9a562 (patch) | |
tree | 56b375db2b68b8337298279611e639124ddcceb4 /CMakeLists.txt | |
parent | aa02904f11073a76cf36bd35b66f42bbed36a9f1 (diff) | |
download | compiler-rt-3b34e7c533ea8837a1e11e14131edeb565a9a562.tar.gz |
[compiler-rt] Cleanup usage of C++ ABI library
Add missed value "libcxxabi" and introduce SANITIZER_TEST_CXX for linking
unit tests. This needs to be a full C++ library and cannot be libcxxabi.
Recommit r354132 which I reverted in r354153 because it broke a sanitizer
bot. This was because of the "fixes" for pthread linking, so I've removed
these changes.
Differential Revision: https://reviews.llvm.org/D58012
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@354198 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 72 |
1 files changed, 47 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b2b5145f..7a8face86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,26 +197,38 @@ if (cxxabi_supported AND SANITIZER_ALLOW_CXXABI) endif() pythonize_bool(SANITIZER_CAN_USE_CXXABI) +macro(handle_default_cxx_lib var) + if (${var} STREQUAL "default") + if (APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + set(${var}_LIBNAME "libc++") + set(${var}_SYSTEM 1) + elseif (FUCHSIA) + set(${var}_LIBNAME "libc++") + set(${var}_INTREE 1) + else() + set(${var}_LIBNAME "libstdc++") + set(${var}_SYSTEM 1) + endif() + else() + set(${var}_LIBNAME "${${var}}") + set(${var}_SYSTEM 1) + endif() +endmacro() + +# This is either directly the C++ ABI library or the full C++ library +# which pulls in the ABI transitively. set(SANITIZER_CXX_ABI "default" CACHE STRING "Specify C++ ABI library to use.") -set(CXXABIS none default libstdc++ libc++) +set(CXXABIS none default libstdc++ libc++ libcxxabi) set_property(CACHE SANITIZER_CXX_ABI PROPERTY STRINGS ;${CXXABIS}) +handle_default_cxx_lib(SANITIZER_CXX_ABI) -if (SANITIZER_CXX_ABI STREQUAL "default") - if (APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - set(SANITIZER_CXX_ABI_LIBNAME "libc++") - set(SANITIZER_CXX_ABI_SYSTEM 1) - elseif (FUCHSIA) - set(SANITIZER_CXX_ABI_LIBNAME "libc++") - set(SANITIZER_CXX_ABI_INTREE 1) - else() - set(SANITIZER_CXX_ABI_LIBNAME "libstdc++") - set(SANITIZER_CXX_ABI_SYSTEM 1) - endif() -else() - set(SANITIZER_CXX_ABI_LIBNAME "${SANITIZER_CXX_ABI}") - set(SANITIZER_CXX_ABI_SYSTEM 1) -endif() +# This needs to be a full C++ library for linking gtest and unit tests. +set(SANITIZER_TEST_CXX "default" CACHE STRING + "Specify C++ library to use for tests.") +set(CXXLIBS none default libstdc++ libc++) +set_property(CACHE SANITIZER_TEST_CXX PROPERTY STRINGS ;${CXXLIBS}) +handle_default_cxx_lib(SANITIZER_TEST_CXX) set(DEFAULT_SANITIZER_USE_STATIC_LLVM_UNWINDER OFF) if (FUCHSIA) @@ -412,26 +424,36 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia") list(APPEND SANITIZER_COMMON_LINK_LIBS zircon) endif() -if (SANITIZER_CXX_ABI_LIBNAME STREQUAL "libc++") - if (SANITIZER_CXX_ABI_INTREE) +macro(append_libcxx_libs var) + if (${var}_INTREE) if (SANITIZER_USE_STATIC_LLVM_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND)) - list(APPEND SANITIZER_CXX_ABI_LIBRARY unwind_static) + list(APPEND ${var}_LIBRARIES unwind_static) elseif (TARGET unwind_shared OR HAVE_LIBUNWIND) - list(APPEND SANITIZER_CXX_ABI_LIBRARY unwind_shared) + list(APPEND ${var}_LIBRARIES unwind_shared) endif() if (SANITIZER_USE_STATIC_CXX_ABI AND (TARGET cxxabi_static OR HAVE_LIBCXXABI)) - list(APPEND SANITIZER_CXX_ABI_LIBRARY cxxabi_static) + list(APPEND ${var}_LIBRARIES cxxabi_static) elseif (TARGET cxxabi_shared OR HAVE_LIBCXXABI) - list(APPEND SANITIZER_CXX_ABI_LIBRARY cxxabi_shared) + list(APPEND ${var}_LIBRARIES cxxabi_shared) endif() else() - append_list_if(COMPILER_RT_HAS_LIBCXX c++ SANITIZER_CXX_ABI_LIBRARY) + append_list_if(COMPILER_RT_HAS_LIBCXX c++ ${var}_LIBRARIES) endif() +endmacro() + +if (SANITIZER_CXX_ABI_LIBNAME STREQUAL "libc++") + append_libcxx_libs(SANITIZER_CXX_ABI) elseif (SANITIZER_CXX_ABI_LIBNAME STREQUAL "libcxxabi") - list(APPEND SANITIZER_CXX_ABI_LIBRARY "c++abi") + list(APPEND SANITIZER_CXX_ABI_LIBRARIES "c++abi") elseif (SANITIZER_CXX_ABI_LIBNAME STREQUAL "libstdc++") - append_list_if(COMPILER_RT_HAS_LIBSTDCXX stdc++ SANITIZER_CXX_ABI_LIBRARY) + append_list_if(COMPILER_RT_HAS_LIBSTDCXX stdc++ SANITIZER_CXX_ABI_LIBRARIES) +endif() + +if (SANITIZER_TEST_CXX_LIBNAME STREQUAL "libc++") + append_libcxx_libs(SANITIZER_TEST_CXX) +elseif (SANITIZER_TEST_CXX_LIBNAME STREQUAL "libstdc++") + append_list_if(COMPILER_RT_HAS_LIBSTDCXX stdc++ SANITIZER_TEST_CXX_LIBRARIES) endif() # Warnings to turn off for all libraries, not just sanitizers. |