Skip to content

Commit

Permalink
[libclc] Give a helpful error when an unknown target is requested (ll…
Browse files Browse the repository at this point in the history
…vm#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.
  • Loading branch information
DavidSpickett authored Oct 9, 2024
1 parent ef739e7 commit a4de127
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions libclc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@ if( llvm-spirv_exe )
list( APPEND LIBCLC_TARGETS_ALL spirv-mesa3d- spirv64-mesa3d- )
endif()

if( LIBCLC_TARGETS_TO_BUILD STREQUAL "all" )
set( LIBCLC_TARGETS_TO_BUILD ${LIBCLC_TARGETS_ALL} )
endif()

list( SORT LIBCLC_TARGETS_TO_BUILD )

# Verify that the user hasn't requested mesa3d targets without an available
# llvm-spirv tool.
if( "spirv-mesa3d-" IN_LIST LIBCLC_TARGETS_TO_BUILD OR "spirv64-mesa3d-" IN_LIST LIBCLC_TARGETS_TO_BUILD )
Expand All @@ -151,6 +145,19 @@ if( "spirv-mesa3d-" IN_LIST LIBCLC_TARGETS_TO_BUILD OR "spirv64-mesa3d-" IN_LIST
endif()
endif()

if( LIBCLC_TARGETS_TO_BUILD STREQUAL "all" )
set( LIBCLC_TARGETS_TO_BUILD ${LIBCLC_TARGETS_ALL} )
else()
foreach(TARGET_TO_BUILD ${LIBCLC_TARGETS_TO_BUILD})
if (NOT ${TARGET_TO_BUILD} IN_LIST LIBCLC_TARGETS_ALL)
message ( FATAL_ERROR "Unknown target in LIBCLC_TARGETS_TO_BUILD: \"${TARGET_TO_BUILD}\"\n"
"Valid targets are: ${LIBCLC_TARGETS_ALL}\n")
endif()
endforeach()
endif()

list( SORT LIBCLC_TARGETS_TO_BUILD )

# Construct LLVM version define
set( LLVM_VERSION_DEFINE "-DHAVE_LLVM=0x${LLVM_VERSION_MAJOR}0${LLVM_VERSION_MINOR}" )

Expand Down

0 comments on commit a4de127

Please sign in to comment.