Skip to content

Commit a4de127

Browse files
[libclc] Give a helpful error when an unknown target is requested (#111528)
I just tried using LLVM backend names here e.g. NVPTX but libclc want's targets more like triples. This change adds a mesasge to tell you that. Before you got: ``` libclc target 'AMDGCN' is enabled CMake Error at CMakeLists.txt:253 (list): list index: 1 out of range (-1, 0) CMake Error at CMakeLists.txt:254 (list): list index: 2 out of range (-1, 0) Configuring incomplete, errors occurred! ``` Now you get: ``` CMake Error at CMakeLists.txt:145 (message): Unknown target in LIBCLC_TARGETS_TO_BUILD: "AMDGCN" Valid targets are: amdgcn--;amdgcn--amdhsa;clspv--;clspv64--;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl;amdgcn-mesa-mesa3d ``` Some of the targets are dynamic based on what is installed, so spirv isn't here for me because I don't have llvm-spirv installed yet. So this is not perfect but it's an improvement on the current behaviour.
1 parent ef739e7 commit a4de127

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

libclc/CMakeLists.txt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,6 @@ if( llvm-spirv_exe )
137137
list( APPEND LIBCLC_TARGETS_ALL spirv-mesa3d- spirv64-mesa3d- )
138138
endif()
139139

140-
if( LIBCLC_TARGETS_TO_BUILD STREQUAL "all" )
141-
set( LIBCLC_TARGETS_TO_BUILD ${LIBCLC_TARGETS_ALL} )
142-
endif()
143-
144-
list( SORT LIBCLC_TARGETS_TO_BUILD )
145-
146140
# Verify that the user hasn't requested mesa3d targets without an available
147141
# llvm-spirv tool.
148142
if( "spirv-mesa3d-" IN_LIST LIBCLC_TARGETS_TO_BUILD OR "spirv64-mesa3d-" IN_LIST LIBCLC_TARGETS_TO_BUILD )
@@ -151,6 +145,19 @@ if( "spirv-mesa3d-" IN_LIST LIBCLC_TARGETS_TO_BUILD OR "spirv64-mesa3d-" IN_LIST
151145
endif()
152146
endif()
153147

148+
if( LIBCLC_TARGETS_TO_BUILD STREQUAL "all" )
149+
set( LIBCLC_TARGETS_TO_BUILD ${LIBCLC_TARGETS_ALL} )
150+
else()
151+
foreach(TARGET_TO_BUILD ${LIBCLC_TARGETS_TO_BUILD})
152+
if (NOT ${TARGET_TO_BUILD} IN_LIST LIBCLC_TARGETS_ALL)
153+
message ( FATAL_ERROR "Unknown target in LIBCLC_TARGETS_TO_BUILD: \"${TARGET_TO_BUILD}\"\n"
154+
"Valid targets are: ${LIBCLC_TARGETS_ALL}\n")
155+
endif()
156+
endforeach()
157+
endif()
158+
159+
list( SORT LIBCLC_TARGETS_TO_BUILD )
160+
154161
# Construct LLVM version define
155162
set( LLVM_VERSION_DEFINE "-DHAVE_LLVM=0x${LLVM_VERSION_MAJOR}0${LLVM_VERSION_MINOR}" )
156163

0 commit comments

Comments
 (0)