[libcxx-commits] [libcxx] 6359049 - [CMake][runtimes] Add file level dependency to merge_archives commands
Markus Böck via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Mar 18 10:52:52 PDT 2021
Author: Markus Böck
Date: 2021-03-18T18:51:10+01:00
New Revision: 6359049c35042adb34ffe6ba77008613c1436ee1
URL: https://github.com/llvm/llvm-project/commit/6359049c35042adb34ffe6ba77008613c1436ee1
DIFF: https://github.com/llvm/llvm-project/commit/6359049c35042adb34ffe6ba77008613c1436ee1.diff
LOG: [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
Added:
Modified:
libcxx/src/CMakeLists.txt
libcxxabi/src/CMakeLists.txt
Removed:
################################################################################
diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index 5a59b58d4363..2afc69be37b8 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 50afdf6890a3..ea8c54589006 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -302,6 +302,7 @@ if (LIBCXXABI_ENABLE_STATIC)
"$<TARGET_LINKER_FILE:cxxabi_static>"
"$<TARGET_LINKER_FILE:unwind_static>"
WORKING_DIRECTORY ${LIBCXXABI_BUILD_DIR}
+ DEPENDS unwind_static
)
endif()
endif()
More information about the libcxx-commits
mailing list