xref: /llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp (revision eeee5a44bbf24f2f30a313ecf66e6a76de365658)
1 // Tests the clang-sycl-linker tool.
2 //
3 // Test a simple case without arguments.
4 // RUN: %clangxx -emit-llvm -c %s -o %t_1.bc
5 // RUN: %clangxx -emit-llvm -c %s -o %t_2.bc
6 // RUN: clang-sycl-linker --dry-run -triple spirv64 %t_1.bc %t_2.bc -o a.spv 2>&1 \
7 // RUN:   | FileCheck %s --check-prefix=SIMPLE
8 // SIMPLE: "{{.*}}llvm-link{{.*}}" {{.*}}.bc {{.*}}.bc -o [[FIRSTLLVMLINKOUT:.*]].bc --suppress-warnings
9 // SIMPLE-NEXT: "{{.*}}llvm-spirv{{.*}}" {{.*}}-o a.spv [[FIRSTLLVMLINKOUT]].bc
10 //
11 // Test that llvm-link is not called when only one input is present.
12 // RUN: clang-sycl-linker --dry-run -triple spirv64 %t_1.bc -o a.spv 2>&1 \
13 // RUN:   | FileCheck %s --check-prefix=SIMPLE-NO-LINK
14 // SIMPLE-NO-LINK: "{{.*}}llvm-spirv{{.*}}" {{.*}}-o a.spv {{.*}}.bc
15 //
16 // Test a simple case with device library files specified.
17 // RUN: touch %T/lib1.bc
18 // RUN: touch %T/lib2.bc
19 // RUN: clang-sycl-linker --dry-run -triple spirv64 %t_1.bc %t_2.bc --library-path=%T --device-libs=lib1.bc,lib2.bc -o a.spv 2>&1 \
20 // RUN:   | FileCheck %s --check-prefix=DEVLIBS
21 // DEVLIBS: "{{.*}}llvm-link{{.*}}" {{.*}}.bc {{.*}}.bc -o [[FIRSTLLVMLINKOUT:.*]].bc --suppress-warnings
22 // DEVLIBS-NEXT: "{{.*}}llvm-link{{.*}}" -only-needed [[FIRSTLLVMLINKOUT]].bc {{.*}}lib1.bc {{.*}}lib2.bc -o [[SECONDLLVMLINKOUT:.*]].bc --suppress-warnings
23 // DEVLIBS-NEXT: "{{.*}}llvm-spirv{{.*}}" {{.*}}-o a.spv [[SECONDLLVMLINKOUT]].bc
24 //
25 // Test a simple case with .o (fat object) as input.
26 // TODO: Remove this test once fat object support is added.
27 // RUN: %clangxx -c %s -o %t.o
28 // RUN: not clang-sycl-linker --dry-run -triple spirv64 %t.o -o a.spv 2>&1 \
29 // RUN:   | FileCheck %s --check-prefix=FILETYPEERROR
30 // FILETYPEERROR: Unsupported file type
31 //
32 // Test to see if device library related errors are emitted.
33 // RUN: not clang-sycl-linker --dry-run -triple spirv64 %t_1.bc %t_2.bc --library-path=%T --device-libs= -o a.spv 2>&1 \
34 // RUN:   | FileCheck %s --check-prefix=DEVLIBSERR1
35 // DEVLIBSERR1: Number of device library files cannot be zero
36 // RUN: not clang-sycl-linker --dry-run -triple spirv64 %t_1.bc %t_2.bc --library-path=%T --device-libs=lib1.bc,lib2.bc,lib3.bc -o a.spv 2>&1 \
37 // RUN:   | FileCheck %s --check-prefix=DEVLIBSERR2
38 // DEVLIBSERR2: '{{.*}}lib3.bc' SYCL device library file is not found
39 //
40 // Test if correct set of llvm-spirv options are emitted for windows environment.
41 // RUN: clang-sycl-linker --dry-run -triple spirv64 --is-windows-msvc-env %t_1.bc %t_2.bc -o a.spv 2>&1 \
42 // RUN:   | FileCheck %s --check-prefix=LLVMOPTSWIN
43 // LLVMOPTSWIN: -spirv-debug-info-version=ocl-100 -spirv-allow-extra-diexpressions -spirv-allow-unknown-intrinsics=llvm.genx. -spirv-ext=
44 //
45 // Test if correct set of llvm-spirv options are emitted for linux environment.
46 // RUN: clang-sycl-linker --dry-run -triple spirv64  %t_1.bc %t_2.bc -o a.spv 2>&1 \
47 // RUN:   | FileCheck %s --check-prefix=LLVMOPTSLIN
48 // LLVMOPTSLIN: -spirv-debug-info-version=nonsemantic-shader-200 -spirv-allow-unknown-intrinsics=llvm.genx. -spirv-ext=
49