Skip to content

Commit

Permalink
[CMake][compiler-rt] Enable statically linking unwinder and c++abi
Browse files Browse the repository at this point in the history
Rather than guessing whether to use static or shared version of
unwinder and c++abi when using linking against the in-tree versions,
provide a CMake option to control this.

Differential Revision: https://reviews.llvm.org/D57492

llvm-svn: 352723
  • Loading branch information
petrhosek committed Jan 31, 2019
1 parent d81f230 commit e2c021d
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions compiler-rt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,24 @@ else()
set(SANITIZER_CXX_ABI_SYSTEM 1)
endif()

set(DEFAULT_SANITIZER_USE_STATIC_LLVM_UNWINDER OFF)
if (FUCHSIA)
set(DEFAULT_SANITIZER_USE_STATIC_LLVM_UNWINDER ON)
elseif (DEFINED LIBUNWIND_ENABLE_SHARED AND NOT LIBUNWIND_ENABLE_SHARED)
set(DEFAULT_SANITIZER_USE_STATIC_LLVM_UNWINDER ON)
endif()

option(SANITIZER_USE_STATIC_LLVM_UNWINDER
"Use static LLVM unwinder." ${DEFAULT_SANITIZER_USE_STATIC_LLVM_UNWINDER})

set(DEFAULT_SANITIZER_USE_STATIC_CXX_ABI OFF)
if (DEFINED LIBCXXABI_ENABLE_SHARED AND NOT LIBCXXABI_ENABLE_SHARED)
set(DEFAULT_SANITIZER_USE_STATIC_CXX_ABI ON)
endif()

option(SANITIZER_USE_STATIC_CXX_ABI
"Use static libc++abi." ${DEFAULT_SANITIZER_USE_STATIC_CXX_ABI})

set(DEFAULT_COMPILER_RT_USE_BUILTINS_LIBRARY OFF)
if (FUCHSIA)
set(DEFAULT_COMPILER_RT_USE_BUILTINS_LIBRARY ON)
Expand Down Expand Up @@ -393,15 +411,16 @@ endif()

if (SANITIZER_CXX_ABI_LIBNAME STREQUAL "libc++")
if (SANITIZER_CXX_ABI_INTREE)
if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
list(APPEND SANITIZER_CXX_ABI_LIBRARY unwind_shared)
elseif (LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND))
if (SANITIZER_USE_STATIC_LLVM_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND))
list(APPEND SANITIZER_CXX_ABI_LIBRARY unwind_static)
elseif (TARGET unwind_shared OR HAVE_LIBUNWIND)
list(APPEND SANITIZER_CXX_ABI_LIBRARY unwind_shared)
endif()
if (NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND (TARGET cxxabi_shared OR HAVE_LIBCXXABI))
list(APPEND SANITIZER_CXX_ABI_LIBRARY cxxabi_shared)
elseif (LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND (TARGET cxxabi_static OR HAVE_LIBCXXABI))

if (SANITIZER_USE_STATIC_CXX_ABI AND (TARGET cxxabi_static OR HAVE_LIBCXXABI))
list(APPEND SANITIZER_CXX_ABI_LIBRARY cxxabi_static)
elseif (TARGET cxxabi_shared OR HAVE_LIBCXXABI)
list(APPEND SANITIZER_CXX_ABI_LIBRARY cxxabi_shared)
endif()
else()
append_list_if(COMPILER_RT_HAS_LIBCXX c++ SANITIZER_CXX_ABI_LIBRARY)
Expand Down

0 comments on commit e2c021d

Please sign in to comment.