diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt --- a/libcxxabi/CMakeLists.txt +++ b/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) diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt --- a/libcxxabi/src/CMakeLists.txt +++ b/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 "$") + 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} "$" - "$" + "${MERGE_ARCHIVES_UNWIND}" + "${MERGE_ARCHIVES_SEARCH_PATHS}" WORKING_DIRECTORY ${LIBCXXABI_BUILD_DIR} ) endif()