[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
Tue Apr 7 07:34:49 PDT 2020


tambre updated this revision to Diff 255674.
tambre marked 2 inline comments as done.
tambre added a comment.

Add cache variable for LIBCXXABI_UNWIND_LIBRARY_PATH to improve discoverability and clarify usage.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77296/new/

https://reviews.llvm.org/D77296

Files:
  libcxxabi/CMakeLists.txt
  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(NOT "${LIBCXXABI_UNWIND_LIBRARY_PATH}" STREQUAL "")
+      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()
Index: libcxxabi/CMakeLists.txt
===================================================================
--- libcxxabi/CMakeLists.txt
+++ libcxxabi/CMakeLists.txt
@@ -56,6 +56,7 @@
 option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
 option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
 option(LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM unwinder." OFF)
+set(LIBCXXABI_UNWIND_LIBRARY_PATH "" CACHE STRING "Path to the static unwind library (for standalone builds).")
 option(LIBCXXABI_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
 option(LIBCXXABI_ENABLE_THREADS "Build with threads enabled" ON)
 option(LIBCXXABI_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77296.255674.patch
Type: text/x-patch
Size: 1957 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200407/0d64da3d/attachment.bin>


More information about the libcxx-commits mailing list