Files
clang-p2996/clang/test/Tooling/clang-linker-wrapper-spirv-elf.cpp
Nick Sarnie c2fea0d837 [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](https://github.com/llvm/llvm-project/pull/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 <nick.sarnie@intel.com>
2025-02-11 20:04:53 +00:00

20 lines
843 B
C++

// Verify the ELF packaging of OpenMP SPIR-V device images.
// REQUIRES: system-linux
// REQUIRES: spirv-tools
// REQUIRES: llvm-spirv
// RUN: mkdir -p %t_tmp
// RUN: cd %t_tmp
// RUN: %clangxx -fopenmp -fopenmp-targets=spirv64-intel -nogpulib -c -o %t_clang-linker-wrapper-spirv-elf.o %s
// RUN: not clang-linker-wrapper -o a.out %t_clang-linker-wrapper-spirv-elf.o --save-temps --linker-path=ld
// RUN: clang-offload-packager --image=triple=spirv64-intel,kind=openmp,file=%t.elf %t_tmp/a.out.openmp.image.wrapper.o
// RUN: llvm-readelf -t %t.elf | FileCheck -check-prefix=CHECK-SECTION %s
// RUN: llvm-readelf -n %t.elf | FileCheck -check-prefix=CHECK-NOTES %s
// CHECK-SECTION: .note.inteloneompoffload
// CHECK-SECTION: __openmp_offload_spirv_0
// CHECK-NOTES-COUNT-3: INTELONEOMPOFFLOAD
int main(int argc, char** argv) {
return 0;
}