[PATCH] D57492: [CMake][compiler-rt] Enable statically linking unwinder and c++abi

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 30 17:44:42 PST 2019


phosek created this revision.
phosek added reviewers: vitalybuka, morehouse, mcgrathr.
Herald added subscribers: Sanitizers, llvm-commits, mgorny, dberris.

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.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D57492

Files:
  compiler-rt/CMakeLists.txt


Index: compiler-rt/CMakeLists.txt
===================================================================
--- compiler-rt/CMakeLists.txt
+++ compiler-rt/CMakeLists.txt
@@ -215,6 +215,17 @@
   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)
+endif()
+
+option(SANITIZER_USE_STATIC_LLVM_UNWINDER
+  "Use static LLVM unwinder." ${DEFAULT_SANITIZER_USE_STATIC_LLVM_UNWINDER})
+
+option(SANITIZER_USE_STATIC_CXX_ABI
+  "Use static libc++abi." OFF)
+
 set(DEFAULT_COMPILER_RT_USE_BUILTINS_LIBRARY OFF)
 if (FUCHSIA)
   set(DEFAULT_COMPILER_RT_USE_BUILTINS_LIBRARY ON)
@@ -393,15 +404,18 @@
 
 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 OR NOT LIBUNWIND_ENABLE_SHARED) 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 OR NOT LIBCXXABI_ENABLE_SHARED) 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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57492.184423.patch
Type: text/x-patch
Size: 1985 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190131/38196be2/attachment.bin>


More information about the llvm-commits mailing list