From 17a4c78665ddc63e0eb02c414f0c73c5e72beaae Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Wed, 20 Sep 2023 18:16:40 +0000 Subject: [PATCH] [builtins][CMake] Replace custom target for lse_builtin symlinks Using custom target with BYPRODUCTS results in symlinks being recreated on every build (the build is always dirty). We could instead use custom commands to generate the symlinks and by adding the output to the list of sources, build system will ensure those are created as needed. --- compiler-rt/lib/builtins/CMakeLists.txt | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index 43ef62ffb115d..1afceddc62d84 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -567,9 +567,13 @@ foreach(pat cas swp ldadd ldclr ldeor ldset) foreach(size 1 2 4 8 16) foreach(model 1 2 3 4 5) if(pat STREQUAL "cas" OR NOT size STREQUAL "16") + set(source_asm "${CMAKE_CURRENT_SOURCE_DIR}/aarch64/lse.S") set(helper_asm "${OA_HELPERS_DIR}/outline_atomic_${pat}${size}_${model}.S") - list(APPEND lse_builtins "${helper_asm}") - list(APPEND arm64_lse_commands COMMAND ${CMAKE_COMMAND} -E ${COMPILER_RT_LINK_OR_COPY} "${CMAKE_CURRENT_SOURCE_DIR}/aarch64/lse.S" "${helper_asm}") + add_custom_command( + OUTPUT "${helper_asm}" + COMMAND ${CMAKE_COMMAND} -E ${COMPILER_RT_LINK_OR_COPY} "${source_asm}" "${helper_asm}" + DEPENDS "${source_asm}" + ) set_source_files_properties("${helper_asm}" PROPERTIES COMPILE_DEFINITIONS "L_${pat};SIZE=${size};MODEL=${model}" @@ -827,16 +831,6 @@ else () list(APPEND BUILTIN_CFLAGS_${arch} -fforce-enable-int128) endif() - if(arch STREQUAL "aarch64") - add_custom_target( - lse_builtin_symlinks - BYPRODUCTS ${lse_builtins} - ${arm64_lse_commands} - ) - - set(deps_aarch64 lse_builtin_symlinks) - endif() - add_compiler_rt_runtime(clang_rt.builtins STATIC ARCHS ${arch}