[libcxx-commits] [PATCH] D77296: [libc++abi] Make libunwind static linking possible in standalone builds

Raul Tambre via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 2 05:23:37 PDT 2020


tambre created this revision.
tambre added a reviewer: ldionne.
Herald added subscribers: libcxx-commits, dexonsmith, mgorny.
Herald added a project: libc++abi.
Herald added a reviewer: libc++abi.

This is the same way that libc++abi static linking is handled in libc++.

Resolves PR45348.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77296

Files:
  libcxxabi/src/CMakeLists.txt


Index: libcxxabi/src/CMakeLists.txt
===================================================================
--- libcxxabi/src/CMakeLists.txt
+++ libcxxabi/src/CMakeLists.txt
@@ -260,6 +260,16 @@
 
   # Merge the libc++abi.a and libunwind.a into one.
   if(LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY)
+    if(LIBCXXABI_UNWIND_LIBRARY_PATH)
+      set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXXABI_UNWIND_LIBRARY_PATH}")
+    endif()
+
+    if(TARGET unwind_static)
+      set(MERGE_ARCHIVES_UNWIND "$<TARGET_LINKER_FILE:unwind_static>")
+    else()
+      set(MERGE_ARCHIVES_UNWIND "${CMAKE_STATIC_LIBRARY_PREFIX}unwind${CMAKE_STATIC_LIBRARY_SUFFIX}")
+    endif()
+
     add_custom_command(TARGET cxxabi_static POST_BUILD
       COMMAND ${PYTHON_EXECUTABLE} ${LIBCXXABI_LIBCXX_PATH}/utils/merge_archives.py
       ARGS
@@ -267,7 +277,8 @@
         --ar "${CMAKE_AR}"
         ${MERGE_ARCHIVES_LIBTOOL}
         "$<TARGET_LINKER_FILE:cxxabi_static>"
-        "$<TARGET_LINKER_FILE:unwind_static>"
+        "${MERGE_ARCHIVES_UNWIND}"
+        "${MERGE_ARCHIVES_SEARCH_PATHS}"
       WORKING_DIRECTORY ${LIBCXXABI_BUILD_DIR}
     )
   endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77296.254491.patch
Type: text/x-patch
Size: 1175 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200402/6f734082/attachment.bin>


More information about the libcxx-commits mailing list