[libclc] [libclc] link_bc target should depends on target builtins.link.clc-arch_suffix (PR #132338)

Wenju He via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 20 22:16:02 PDT 2025


https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/132338

Currently link_bc command depends on the bitcode file that is associated with custom target builtins.link.clc-arch_suffix.
On windows we randomly see following error:
`
  Generating builtins.link.clc-${ARCH}--.bc
  Generating builtins.link.libspirv-${ARCH}.bc
  error : The requested operation cannot be performed on a file with a user-mapped section open.
`
I suspect that builtins.link.clc-${ARCH}--.bc file is been generated while it is been used in link_bc.
This PR adds target-level dependency to ensure builtins.link.clc-${ARCH}--.bc is generated first.

>From a423c4d51b88dc51c5628eb9d4c0b7053a96f461 Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Thu, 20 Mar 2025 22:01:55 -0700
Subject: [PATCH] [libclc] link_bc target should depends on target
 builtins.link.clc-arch_suffix

Currently link_bc command depends on the bitcode file that is associated
with custom target builtins.link.clc-arch_suffix.
On windows we randomly see following error:
`
  Generating builtins.link.clc-${ARCH}--.bc
  Generating builtins.link.libspirv-${ARCH}.bc
  error : The requested operation cannot be performed on a file with a user-mapped section open.
`
I suspect that builtins.link.clc-${ARCH}--.bc file is been generated
while it is been used in link_bc.
This PR adds target-level dependency to ensure builtins.link.clc-${ARCH}--.bc
is generated first.
---
 libclc/CMakeLists.txt                | 2 +-
 libclc/cmake/modules/AddLibclc.cmake | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 426f210a73fcc..3de7ee9b707a8 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -413,7 +413,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
       GEN_FILES ${opencl_gen_files}
       ALIASES ${${d}_aliases}
       # Link in the CLC builtins and internalize their symbols
-      INTERNAL_LINK_DEPENDENCIES $<TARGET_PROPERTY:builtins.link.clc-${arch_suffix},TARGET_FILE>
+      INTERNAL_LINK_DEPENDENCIES builtins.link.clc-${arch_suffix}
     )
   endforeach( d )
 endforeach( t )
diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake
index 911559ff4bfa9..0808b39e06555 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -211,8 +211,9 @@ endfunction()
 #  * ALIASES <string> ...
 #      List of aliases
 #  * INTERNAL_LINK_DEPENDENCIES <string> ...
-#      A list of extra bytecode files to link into the builtin library. Symbols
-#      from these link dependencies will be internalized during linking.
+#      A list of extra bytecode file's targets. The bitcode files will be linked
+#      into the builtin library. Symbols from these link dependencies will be
+#      internalized during linking.
 function(add_libclc_builtin_set)
   cmake_parse_arguments(ARG
     "CLC_INTERNAL"
@@ -313,8 +314,8 @@ function(add_libclc_builtin_set)
       INTERNALIZE
       TARGET ${builtins_link_lib_tgt}
       INPUTS $<TARGET_PROPERTY:${builtins_link_lib_tmp_tgt},TARGET_FILE>
-        ${ARG_INTERNAL_LINK_DEPENDENCIES}
-      DEPENDENCIES ${builtins_link_lib_tmp_tgt}
+        $<TARGET_PROPERTY:${ARG_INTERNAL_LINK_DEPENDENCIES},TARGET_FILE>
+      DEPENDENCIES ${builtins_link_lib_tmp_tgt} ${ARG_INTERNAL_LINK_DEPENDENCIES}
     )
   endif()
 



More information about the cfe-commits mailing list