Skip to content

Commit e421ef2

Browse files
wenju-heCopilot
andauthored
[libclc] Make output filename configurable; rename top-level targets (#178119)
This PR relates to c5cb48c. Pass `OUTPUT_FILENAME` to `add_libclc_builtin_set` to allow downstream output naming (e.g. libspirv in https://github.com/intel/llvm/tree/sycl/libclc). Rename top-level target to `libclc-${ARG_TRIPLE}` to avoid collision with `library-${ARG_ARCH_SUFFIX}` in our downstream when libclc TRIPLE matches libspirv ARCH_SUFFIX. --------- Co-authored-by: Copilot <[email protected]>
1 parent bf408aa commit e421ef2

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

libclc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
466466
OPT_FLAGS ${opt_flags}
467467
LIB_FILES ${opencl_lib_files}
468468
ALIASES ${${d}_aliases}
469+
OUTPUT_FILENAME libclc
469470
PARENT_TARGET libclc-opencl-builtins
470471
# Link in the CLC builtins and internalize their symbols
471472
INTERNAL_LINK_DEPENDENCIES builtins.link.clc-${arch_suffix}

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ endfunction()
241241
# libclc architecture/triple suffix
242242
# * TRIPLE <string>
243243
# Triple used to compile
244+
# * OUTPUT_FILENAME <string>
245+
# libclc output library name
244246
# * PARENT_TARGET <string>
245247
# Target into which to group the target builtins
246248
#
@@ -263,7 +265,7 @@ endfunction()
263265
function(add_libclc_builtin_set)
264266
cmake_parse_arguments(ARG
265267
"CLC_INTERNAL"
266-
"ARCH;DEVICE;TRIPLE;ARCH_SUFFIX;PARENT_TARGET"
268+
"ARCH;DEVICE;TRIPLE;ARCH_SUFFIX;OUTPUT_FILENAME;PARENT_TARGET"
267269
"LIB_FILES;COMPILE_FLAGS;OPT_FLAGS;ALIASES;INTERNAL_LINK_DEPENDENCIES"
268270
${ARGN}
269271
)
@@ -374,7 +376,10 @@ function(add_libclc_builtin_set)
374376
return()
375377
endif()
376378

377-
set( LIBCLC_OUTPUT_FILENAME libclc )
379+
if (NOT DEFINED ARG_OUTPUT_FILENAME OR ARG_OUTPUT_FILENAME STREQUAL "")
380+
message(FATAL_ERROR "OUTPUT_FILENAME parameter is required and must be non-empty.")
381+
endif()
382+
set( LIBCLC_OUTPUT_FILENAME ${ARG_OUTPUT_FILENAME} )
378383
set( builtins_link_lib $<TARGET_PROPERTY:${builtins_link_lib_tgt},TARGET_FILE> )
379384

380385
# We store the library according to its triple and cpu if present.
@@ -418,16 +423,16 @@ function(add_libclc_builtin_set)
418423
FOLDER "libclc/Device IR/Library"
419424
)
420425

421-
# Also add a 'library' target for the triple. Since a triple may have
426+
# Also add a 'libclc' target for the triple. Since a triple may have
422427
# multiple devices, ensure we only try to create the triple target once. The
423428
# triple's target will build all of the bytecode for its constituent devices.
424-
if( NOT TARGET library-${ARG_TRIPLE} )
425-
add_custom_target( library-${ARG_TRIPLE} ALL )
429+
if( NOT TARGET libclc-${ARG_TRIPLE} )
430+
add_custom_target( libclc-${ARG_TRIPLE} ALL )
426431
endif()
427-
add_dependencies( library-${ARG_TRIPLE} library-${ARG_ARCH_SUFFIX} )
432+
add_dependencies( libclc-${ARG_TRIPLE} library-${ARG_ARCH_SUFFIX} )
428433
# Add dependency to top-level pseudo target to ease making other
429434
# targets dependent on libclc.
430-
add_dependencies( ${ARG_PARENT_TARGET} library-${ARG_TRIPLE} )
435+
add_dependencies( ${ARG_PARENT_TARGET} libclc-${ARG_TRIPLE} )
431436

432437
# Install the created library.
433438
install(

0 commit comments

Comments
 (0)