[libclc] [libclc] Give a helpful error when an unknown target is requested (PR #111528)
David Spickett via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 8 08:56:36 PDT 2024
https://github.com/DavidSpickett updated https://github.com/llvm/llvm-project/pull/111528
>From 686a0404c968d3bcec56bca232599465a9549312 Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at linaro.org>
Date: Tue, 8 Oct 2024 12:40:40 +0000
Subject: [PATCH 1/3] [libclc] Give a helpful error when an unknown target is
requested
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.
---
libclc/CMakeLists.txt | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 260e4d433a1d49..0135b2c64e3ea6 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -139,6 +139,13 @@ 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}")
+ endif()
+ endforeach()
endif()
list( SORT LIBCLC_TARGETS_TO_BUILD )
>From 417ff0bfbfe179c8a0abb7c666fd00da934e4ed1 Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at linaro.org>
Date: Tue, 8 Oct 2024 12:48:19 +0000
Subject: [PATCH 2/3] Move the unknown target error after the spir-v tool check
---
libclc/CMakeLists.txt | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 0135b2c64e3ea6..152c4c41b2b39f 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -137,17 +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} )
-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}")
- endif()
- endforeach()
-endif()
-
list( SORT LIBCLC_TARGETS_TO_BUILD )
# Verify that the user hasn't requested mesa3d targets without an available
@@ -158,6 +147,17 @@ 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()
+
# Construct LLVM version define
set( LLVM_VERSION_DEFINE "-DHAVE_LLVM=0x${LLVM_VERSION_MAJOR}0${LLVM_VERSION_MINOR}" )
>From 4c7116931b3b97e83b32bd5809a1d5c4b27b668b Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at linaro.org>
Date: Tue, 8 Oct 2024 15:55:53 +0000
Subject: [PATCH 3/3] Also move the final sort
---
libclc/CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 152c4c41b2b39f..5f882bac8c465c 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -137,8 +137,6 @@ if( llvm-spirv_exe )
list( APPEND LIBCLC_TARGETS_ALL spirv-mesa3d- spirv64-mesa3d- )
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 )
@@ -158,6 +156,8 @@ else()
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}" )
More information about the cfe-commits
mailing list