Skip to content

Commit c2fea0d

Browse files
authored
[clang-linker-wrapper][lit] Fix SPIR-V ELF test when spirv-tools feature is available (#126756)
My last change made the test not run when the `spirv-tools` feature is not available, which is always the case in CI for clang tests, but it fails if `spirv-tools` is available for the following reasons: 1) We didn't build `spirv-link` as part of the internal `SPIRV-Tools` build, which is required by the `clang` call in `clang-linker-wrapper`, I already fixed that [here](#126319). 2) We didn't depend on the `SPIRV-Tools` CMake targets in clang tests, so depending on what CMake targets were built before running `check-clang`, `SPIRV-Tools` might not have been built. 3) We didn't check for `llvm-spirv` being available, which is not part of `SPIRV-Tools` but is currently required for SPIR-V compilation. Manually confirmed this works. This test is the bane of my existence. --------- Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 401f4b8 commit c2fea0d

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

clang/test/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ if(CLANG_BUILD_EXAMPLES AND CLANG_PLUGIN_SUPPORT)
103103
)
104104
endif ()
105105

106+
if(LLVM_INCLUDE_SPIRV_TOOLS_TESTS)
107+
list(APPEND CLANG_TEST_DEPS
108+
spirv-dis
109+
spirv-val
110+
spirv-as
111+
spirv-link
112+
)
113+
endif()
114+
106115
set(CLANG_TEST_PARAMS
107116
USE_Z3_SOLVER=0
108117
)

clang/test/Tooling/clang-linker-wrapper-spirv-elf.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Verify the ELF packaging of OpenMP SPIR-V device images.
22
// REQUIRES: system-linux
33
// REQUIRES: spirv-tools
4+
// REQUIRES: llvm-spirv
45
// RUN: mkdir -p %t_tmp
56
// RUN: cd %t_tmp
67
// RUN: %clangxx -fopenmp -fopenmp-targets=spirv64-intel -nogpulib -c -o %t_clang-linker-wrapper-spirv-elf.o %s

clang/test/Tooling/lit.local.cfg

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import lit.util
2+
13
if not config.root.clang_staticanalyzer:
24
config.unsupported = True
35

@@ -6,3 +8,7 @@ if config.spirv_tools_tests:
68
config.substitutions.append(("spirv-dis", os.path.join(config.llvm_tools_dir, "spirv-dis")))
79
config.substitutions.append(("spirv-val", os.path.join(config.llvm_tools_dir, "spirv-val")))
810
config.substitutions.append(("spirv-as", os.path.join(config.llvm_tools_dir, "spirv-as")))
11+
config.substitutions.append(("spirv-link", os.path.join(config.llvm_tools_dir, "spirv-link")))
12+
13+
if lit.util.which("llvm-spirv"):
14+
config.available_features.add("llvm-spirv")

0 commit comments

Comments
 (0)