Skip to content

Commit 17a4c78

Browse files
committed
[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.
1 parent 7b03a55 commit 17a4c78

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

compiler-rt/lib/builtins/CMakeLists.txt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,13 @@ foreach(pat cas swp ldadd ldclr ldeor ldset)
567567
foreach(size 1 2 4 8 16)
568568
foreach(model 1 2 3 4 5)
569569
if(pat STREQUAL "cas" OR NOT size STREQUAL "16")
570+
set(source_asm "${CMAKE_CURRENT_SOURCE_DIR}/aarch64/lse.S")
570571
set(helper_asm "${OA_HELPERS_DIR}/outline_atomic_${pat}${size}_${model}.S")
571-
list(APPEND lse_builtins "${helper_asm}")
572-
list(APPEND arm64_lse_commands COMMAND ${CMAKE_COMMAND} -E ${COMPILER_RT_LINK_OR_COPY} "${CMAKE_CURRENT_SOURCE_DIR}/aarch64/lse.S" "${helper_asm}")
572+
add_custom_command(
573+
OUTPUT "${helper_asm}"
574+
COMMAND ${CMAKE_COMMAND} -E ${COMPILER_RT_LINK_OR_COPY} "${source_asm}" "${helper_asm}"
575+
DEPENDS "${source_asm}"
576+
)
573577
set_source_files_properties("${helper_asm}"
574578
PROPERTIES
575579
COMPILE_DEFINITIONS "L_${pat};SIZE=${size};MODEL=${model}"
@@ -827,16 +831,6 @@ else ()
827831
list(APPEND BUILTIN_CFLAGS_${arch} -fforce-enable-int128)
828832
endif()
829833

830-
if(arch STREQUAL "aarch64")
831-
add_custom_target(
832-
lse_builtin_symlinks
833-
BYPRODUCTS ${lse_builtins}
834-
${arm64_lse_commands}
835-
)
836-
837-
set(deps_aarch64 lse_builtin_symlinks)
838-
endif()
839-
840834
add_compiler_rt_runtime(clang_rt.builtins
841835
STATIC
842836
ARCHS ${arch}

0 commit comments

Comments
 (0)