[libcxxabi] r318563 - [CMake][libcxxabi] Support merging objects when statically linking unwinder

Petr Hosek via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 17 14:49:39 PST 2017


Author: phosek
Date: Fri Nov 17 14:49:39 2017
New Revision: 318563

URL: http://llvm.org/viewvc/llvm-project?rev=318563&view=rev
Log:
[CMake][libcxxabi] Support merging objects when statically linking unwinder

When using LLVM unwinder and static unwinder option is set, merge
libunwind and libc++abi objects into a single archive. libc++ already
supports merging libc++abi.a and libc++.a into a single archive; with
this change, it is possible to also include libunwind.a in the same
archive which is useful when doing static link and using libc++ as
a default C++ library and compiler-rt as a default runtime library.

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

Modified:
    libcxxabi/trunk/src/CMakeLists.txt

Modified: libcxxabi/trunk/src/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/CMakeLists.txt?rev=318563&r1=318562&r2=318563&view=diff
==============================================================================
--- libcxxabi/trunk/src/CMakeLists.txt (original)
+++ libcxxabi/trunk/src/CMakeLists.txt Fri Nov 17 14:49:39 2017
@@ -151,7 +151,13 @@ endif()
 
 # Build the static library.
 if (LIBCXXABI_ENABLE_STATIC)
-  add_library(cxxabi_static STATIC $<TARGET_OBJECTS:cxxabi_objects>)
+  set(cxxabi_static_sources $<TARGET_OBJECTS:cxxabi_objects>)
+  if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_ENABLE_STATIC_UNWINDER)
+    if (TARGET unwind_static OR HAVE_LIBUNWIND)
+      list(APPEND cxxabi_static_sources $<TARGET_OBJECTS:unwind_objects>)
+    endif()
+  endif()
+  add_library(cxxabi_static STATIC ${cxxabi_static_sources})
   target_link_libraries(cxxabi_static ${LIBCXXABI_LIBRARIES})
   set_target_properties(cxxabi_static
                         PROPERTIES




More information about the cfe-commits mailing list