Skip to content

Commit 735d7c1

Browse files
authored
[libclc] link_bc target should depends on target builtins.link.clc-arch_suffix (#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 being generated while it is being used in link_bc. This PR adds target-level dependency to ensure builtins.link.clc-${ARCH}--.bc is generated first.
1 parent cc5f829 commit 735d7c1

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

libclc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
413413
GEN_FILES ${opencl_gen_files}
414414
ALIASES ${${d}_aliases}
415415
# Link in the CLC builtins and internalize their symbols
416-
INTERNAL_LINK_DEPENDENCIES $<TARGET_PROPERTY:builtins.link.clc-${arch_suffix},TARGET_FILE>
416+
INTERNAL_LINK_DEPENDENCIES builtins.link.clc-${arch_suffix}
417417
)
418418
endforeach( d )
419419
endforeach( t )

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,10 @@ endfunction()
214214
# Optimization options (for opt)
215215
# * ALIASES <string> ...
216216
# List of aliases
217-
# * INTERNAL_LINK_DEPENDENCIES <string> ...
218-
# A list of extra bytecode files to link into the builtin library. Symbols
219-
# from these link dependencies will be internalized during linking.
217+
# * INTERNAL_LINK_DEPENDENCIES <target> ...
218+
# A list of extra bytecode file's targets. The bitcode files will be linked
219+
# into the builtin library. Symbols from these link dependencies will be
220+
# internalized during linking.
220221
function(add_libclc_builtin_set)
221222
cmake_parse_arguments(ARG
222223
"CLC_INTERNAL"
@@ -313,12 +314,16 @@ function(add_libclc_builtin_set)
313314
INPUTS ${bytecode_files}
314315
DEPENDENCIES ${builtins_comp_lib_tgt}
315316
)
317+
set( internal_link_depend_files )
318+
foreach( tgt ${ARG_INTERNAL_LINK_DEPENDENCIES} )
319+
list( APPEND internal_link_depend_files $<TARGET_PROPERTY:${tgt},TARGET_FILE> )
320+
endforeach()
316321
link_bc(
317322
INTERNALIZE
318323
TARGET ${builtins_link_lib_tgt}
319324
INPUTS $<TARGET_PROPERTY:${builtins_link_lib_tmp_tgt},TARGET_FILE>
320-
${ARG_INTERNAL_LINK_DEPENDENCIES}
321-
DEPENDENCIES ${builtins_link_lib_tmp_tgt}
325+
${internal_link_depend_files}
326+
DEPENDENCIES ${builtins_link_lib_tmp_tgt} ${ARG_INTERNAL_LINK_DEPENDENCIES}
322327
)
323328
endif()
324329

0 commit comments

Comments
 (0)