Skip to content

Commit d08c5de

Browse files
committed
[libclc] Fix building top-level 'libclc' target
With libclc being a 'runtime', the top-level build assumes that there is a corresopnding 'libclc' target. We previously weren't providing this, leading to a build failure if the user tried to build it. This commit remedies this by adding support for building the 'libclc' target. It does so by adding dependencies from the OpenCL builtins to this target. It uses a configurable in-between target - libclc-opencl-builtins - to ease the possibility of adding non-OpenCL builtin libraries in the future.
1 parent a22d010 commit d08c5de

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

libclc/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
55
endif()
66
set(LLVM_SUBPROJECT_TITLE "libclc")
77

8+
# Top level target used to build all Libclc libraries.
9+
add_custom_target( libclc ALL )
10+
811
set(CMAKE_CXX_STANDARD 17)
912

1013
# Add path for custom modules
@@ -42,6 +45,9 @@ set( LIBCLC_TARGETS_TO_BUILD "all"
4245

4346
option( ENABLE_RUNTIME_SUBNORMAL "Enable runtime linking of subnormal support." OFF )
4447

48+
add_custom_target( libclc-opencl-builtins COMMENT "Build libclc OpenCL builtins" )
49+
add_dependencies( libclc libclc-opencl-builtins )
50+
4551
if( LIBCLC_STANDALONE_BUILD OR CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
4652
# Out-of-tree configuration
4753
set( LIBCLC_STANDALONE_BUILD TRUE )
@@ -463,6 +469,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
463469
LIB_FILES ${opencl_lib_files}
464470
GEN_FILES ${opencl_gen_files}
465471
ALIASES ${${d}_aliases}
472+
PARENT_TARGET libclc-opencl-builtins
466473
# Link in the CLC builtins and internalize their symbols
467474
INTERNAL_LINK_DEPENDENCIES builtins.link.clc-${arch_suffix}
468475
)

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ endfunction()
207207
# libclc architecture/triple suffix
208208
# * TRIPLE <string>
209209
# Triple used to compile
210+
# * PARENT_TARGET <string>
211+
# Target into which to group the target builtins
210212
#
211213
# Optional Arguments:
212214
# * CLC_INTERNAL
@@ -229,7 +231,7 @@ endfunction()
229231
function(add_libclc_builtin_set)
230232
cmake_parse_arguments(ARG
231233
"CLC_INTERNAL"
232-
"ARCH;TRIPLE;ARCH_SUFFIX"
234+
"ARCH;TRIPLE;ARCH_SUFFIX;PARENT_TARGET"
233235
"LIB_FILES;GEN_FILES;COMPILE_FLAGS;OPT_FLAGS;ALIASES;INTERNAL_LINK_DEPENDENCIES"
234236
${ARGN}
235237
)
@@ -403,6 +405,9 @@ function(add_libclc_builtin_set)
403405
add_custom_target( prepare-${ARG_TRIPLE} ALL )
404406
endif()
405407
add_dependencies( prepare-${ARG_TRIPLE} prepare-${obj_suffix} )
408+
# Add dependency to top-level pseudo target to ease making other
409+
# targets dependent on libclc.
410+
add_dependencies( ${ARG_PARENT_TARGET} prepare-${ARG_TRIPLE} )
406411

407412
install(
408413
FILES ${libclc_builtins_lib}
@@ -445,6 +450,7 @@ function(add_libclc_builtin_set)
445450
add_custom_target( alias-${alias_suffix} ALL
446451
DEPENDS ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix}
447452
)
453+
add_dependencies( ${ARG_PARENT_TARGET} alias-${alias_suffix} )
448454
set_target_properties( alias-${alias_suffix}
449455
PROPERTIES FOLDER "libclc/Device IR/Aliases"
450456
)

0 commit comments

Comments
 (0)