diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -31,6 +31,7 @@ include(SetPlatformToolchainTools) include(base-config-ix) include(CompilerRTUtils) +include(CMakeDependentOption) option(COMPILER_RT_BUILD_BUILTINS "Build builtins" ON) mark_as_advanced(COMPILER_RT_BUILD_BUILTINS) @@ -211,6 +212,11 @@ set_property(CACHE SANITIZER_TEST_CXX PROPERTY STRINGS ;${CXXLIBS}) handle_default_cxx_lib(SANITIZER_TEST_CXX) +option(COMPILER_RT_USE_LLVM_UNWINDER "Use the LLVM unwinder." OFF) +cmake_dependent_option(COMPILER_RT_ENABLE_STATIC_UNWINDER + "Statically link the LLVM unwinder." OFF + "COMPILER_RT_USE_LLVM_UNWINDER" OFF) + set(DEFAULT_SANITIZER_USE_STATIC_LLVM_UNWINDER OFF) if (FUCHSIA) set(DEFAULT_SANITIZER_USE_STATIC_LLVM_UNWINDER ON) @@ -504,6 +510,16 @@ list(APPEND COMPILER_RT_COMMON_CFLAGS ${stdlib_flag}) list(APPEND COMPILER_RT_COMMON_LINK_FLAGS ${stdlib_flag}) +if(COMPILER_RT_USE_LLVM_UNWINDER) + # TODO: set --unwindlib=none after https://reviews.llvm.org/D115674 lands. + if (COMPILER_RT_ENABLE_STATIC_UNWINDER) + set(unwinder_target unwind_static) + else() + set(unwinder_target unwind_shared) + endif() + list(APPEND SANITIZER_CXX_ABI_LIBRARIES "$<$:$>") +endif() + macro(append_libcxx_libs var) if (${var}_INTREE) if (SANITIZER_USE_STATIC_LLVM_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND))