Skip to content

Commit 6359049

Browse files
committed
[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
1 parent eb37d35 commit 6359049

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

libcxx/src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ if (LIBCXX_ENABLE_STATIC)
299299
else()
300300
set(MERGE_ARCHIVES_ABI_TARGET
301301
"${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_STATIC_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}")
302+
if (LIBCXX_CXX_ABI_LIBRARY_PATH)
303+
set(MERGE_ARCHIVES_ABI_TARGET "${LIBCXX_CXX_ABI_LIBRARY_PATH}/${MERGE_ARCHIVES_ABI_TARGET}")
304+
endif ()
302305
endif()
303306
if (APPLE)
304307
set(MERGE_ARCHIVES_LIBTOOL "--use-libtool" "--libtool" "${CMAKE_LIBTOOL}")
@@ -314,6 +317,7 @@ if (LIBCXX_ENABLE_STATIC)
314317
"${MERGE_ARCHIVES_ABI_TARGET}"
315318
"${MERGE_ARCHIVES_SEARCH_PATHS}"
316319
WORKING_DIRECTORY ${LIBCXX_BUILD_DIR}
320+
DEPENDS ${MERGE_ARCHIVES_ABI_TARGET}
317321
)
318322
endif()
319323
endif()

libcxxabi/src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ if (LIBCXXABI_ENABLE_STATIC)
302302
"$<TARGET_LINKER_FILE:cxxabi_static>"
303303
"$<TARGET_LINKER_FILE:unwind_static>"
304304
WORKING_DIRECTORY ${LIBCXXABI_BUILD_DIR}
305+
DEPENDS unwind_static
305306
)
306307
endif()
307308
endif()

0 commit comments

Comments
 (0)