[compiler-rt] [builtins][CMake] Replace custom target for lse_builtin symlinks (PR #66936)

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 11:22:17 PDT 2023


https://github.com/petrhosek created https://github.com/llvm/llvm-project/pull/66936

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.

>From 7d7503a771dfa841b671099e300a28f36dc5ba8d Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
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 | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index 43ef62ffb115d9d..8082f3c068590cb 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -568,8 +568,10 @@ foreach(pat cas swp ldadd ldclr ldeor ldset)
     foreach(model 1 2 3 4 5)
       if(pat STREQUAL "cas" OR NOT size STREQUAL "16")
         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} "${CMAKE_CURRENT_SOURCE_DIR}/aarch64/lse.S" "${helper_asm}"
+        )
         set_source_files_properties("${helper_asm}"
           PROPERTIES
           COMPILE_DEFINITIONS "L_${pat};SIZE=${size};MODEL=${model}"
@@ -827,16 +829,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}



More information about the llvm-commits mailing list