[llvm] [SPIR-V] Add SPIRV-Tools for testing (PR #73044)
Nathan Gauër via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 30 02:33:58 PST 2023
================
@@ -0,0 +1,66 @@
+option(LLVM_INCLUDE_SPIRV_TOOLS_TESTS "Include tests that use SPIRV-Tools" Off)
+mark_as_advanced(LLVM_INCLUDE_SPIRV_TOOLS_TESTS)
+
+if (NOT LLVM_INCLUDE_SPIRV_TOOLS_TESTS)
+ return()
+endif ()
+
+if (NOT "SPIRV" IN_LIST LLVM_TARGETS_TO_BUILD)
+ message(FATAL_ERROR "Building SPIRV-Tools tests is unsupported without the SPIR-V target")
+endif ()
+
+# SPIRV_DIS and SPIRV_VAL variables can be used to provide paths to existing
+# spirv-dis and spirv-val binaries, respectively. Otherwise, build them from
+# SPIRV-Tools source.
+if (NOT SPIRV_DIS OR NOT SPIRV_VAL)
+ include(ExternalProject)
+
+ set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/SPIRVTools-bin)
+
+ ExternalProject_Add(SPIRVTools
+ GIT_REPOSITORY https://github.com/KhronosGroup/SPIRV-Tools.git
+ GIT_TAG main
+ BINARY_DIR ${BINARY_DIR}
+ BUILD_COMMAND ${CMAKE_COMMAND} --build ${BINARY_DIR} --target spirv-dis spirv-val
+ BUILD_BYPRODUCTS ${BINARY_DIR}/tools/spirv-dis ${BINARY_DIR}/tools/spirv-val
+ # Don't auto-update on every build.
+ UPDATE_DISCONNECTED 1
+ # Allow manual updating with an explicit SPIRVTools-update target.
+ STEP_TARGETS update
+ INSTALL_COMMAND ""
+ )
+
+ ExternalProject_Add_Step(SPIRVTools get-deps
----------------
Keenuts wrote:
On a clean build, I get a failure because the dependencies are not fetched.
I solved it by changing this rule into this:
```cmake
ExternalProject_Add_Step(SPIRVTools get-deps-configure
COMMENT "Getting SPIRV-Tools dependencies"
COMMAND ${Python3_EXECUTABLE} utils/git-sync-deps
DEPENDEES download
DEPENDERS configure
WORKING_DIRECTORY <SOURCE_DIR>
)
```
and removing the `STEP_TARGETS update` bit.
But this means the download is not done when running cmake for configuration, but at build time. Unsure of what's the policy on that.
https://github.com/llvm/llvm-project/pull/73044
More information about the llvm-commits
mailing list