[PATCH] D39949: [CMake][libcxxabi] Support merging archives when statically linking unwinder

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 16:39:12 PST 2017


phosek updated this revision to Diff 122948.
phosek added reviewers: beanz, jroelofs.
phosek added a comment.

I've modified the patch to use plain CMake, PTAL.


Repository:
  rL LLVM

https://reviews.llvm.org/D39949

Files:
  src/CMakeLists.txt


Index: src/CMakeLists.txt
===================================================================
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -168,6 +168,29 @@
                           POSITION_INDEPENDENT_CODE
                             ON)
   list(APPEND LIBCXXABI_TARGETS "cxxabi_static")
+  # Attempt to merge the libc++abi.a archive and the libunwind.a archive into one.
+  if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_ENABLE_STATIC_UNWINDER)
+    if (TARGET unwind_static OR HAVE_LIBUNWIND)
+      set(MERGE_ARCHIVES_ABI_TARGET "$<TARGET_LINKER_FILE:unwind_static>")
+    endif()
+    set(cxxabi_merge_dir "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/cxxabi_merge.dir")
+    file(MAKE_DIRECTORY ${cxxabi_merge_dir})
+    add_custom_command(TARGET cxxabi_static POST_BUILD
+    COMMAND
+      ${CMAKE_AR}
+    ARGS
+      x ${MERGE_ARCHIVES_ABI_TARGET}
+    COMMAND
+      ${CMAKE_AR}
+    ARGS
+      x "$<TARGET_LINKER_FILE:cxxabi_static>"
+    COMMAND
+      ${CMAKE_AR}
+    ARGS
+      qcs "$<TARGET_LINKER_FILE:cxxabi_static>" *.o*
+    WORKING_DIRECTORY ${cxxabi_merge_dir}
+    )
+  endif()
 endif()
 
 # Add a meta-target for both libraries.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39949.122948.patch
Type: text/x-patch
Size: 1157 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171115/d63da2f4/attachment.bin>


More information about the llvm-commits mailing list