From 6359049c35042adb34ffe6ba77008613c1436ee1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Markus=20B=C3=B6ck?= Date: Thu, 18 Mar 2021 18:51:10 +0100 Subject: [PATCH] [CMake][runtimes] Add file level dependency to merge_archives commands Both libc++ and libc++abi have options of merging with another archive. In the case of libc++abi, libunwind can be merged into it and in the case of libc++, libc++abi can be merged into it. This is realized using add_custom_command with POST_BUILD and the usage of the CMake generator expression TARGET_LINKER_FILE in the arguments. For such generator expressions CMake doc states: "This target-level dependency does NOT add a file-level dependency that would cause the custom command to re-run whenever the executable is recompiled" [1] This patch adds a DEPENDS argument to both add_custom_command invocations so that the archives also have a file-level dependency on the target they are merging with. That way, changes in say, libunwind source code, will be updated in the libc++abi and/or libc++ static libraries as well. [1] https://cmake.org/cmake/help/v3.20/command/add_custom_command.html Differential Revision: https://reviews.llvm.org/D98129 --- libcxx/src/CMakeLists.txt | 4 ++++ libcxxabi/src/CMakeLists.txt | 1 + 2 files changed, 5 insertions(+) diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt index 5a59b58..2afc69b 100644 --- a/libcxx/src/CMakeLists.txt +++ b/libcxx/src/CMakeLists.txt @@ -299,6 +299,9 @@ if (LIBCXX_ENABLE_STATIC) else() set(MERGE_ARCHIVES_ABI_TARGET "${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_STATIC_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}") + if (LIBCXX_CXX_ABI_LIBRARY_PATH) + set(MERGE_ARCHIVES_ABI_TARGET "${LIBCXX_CXX_ABI_LIBRARY_PATH}/${MERGE_ARCHIVES_ABI_TARGET}") + endif () endif() if (APPLE) set(MERGE_ARCHIVES_LIBTOOL "--use-libtool" "--libtool" "${CMAKE_LIBTOOL}") @@ -314,6 +317,7 @@ if (LIBCXX_ENABLE_STATIC) "${MERGE_ARCHIVES_ABI_TARGET}" "${MERGE_ARCHIVES_SEARCH_PATHS}" WORKING_DIRECTORY ${LIBCXX_BUILD_DIR} + DEPENDS ${MERGE_ARCHIVES_ABI_TARGET} ) endif() endif() diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt index 50afdf6..ea8c545 100644 --- a/libcxxabi/src/CMakeLists.txt +++ b/libcxxabi/src/CMakeLists.txt @@ -302,6 +302,7 @@ if (LIBCXXABI_ENABLE_STATIC) "$" "$" WORKING_DIRECTORY ${LIBCXXABI_BUILD_DIR} + DEPENDS unwind_static ) endif() endif() -- 2.7.4