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 "$") + 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 "$" + COMMAND + ${CMAKE_AR} + ARGS + qcs "$" *.o* + WORKING_DIRECTORY ${cxxabi_merge_dir} + ) + endif() endif() # Add a meta-target for both libraries.