|
22 | 22 | ; |
23 | 23 | ; Test non-existent input file |
24 | 24 | ; RUN: not clang-sycl-linker %t-missing.bc -o %t.out 2>&1 | FileCheck %s --check-prefix=MISSING |
25 | | -; MISSING: Input file '{{.*}}-missing.bc' does not exist |
| 25 | +; MISSING: input file not found: '{{.*}}-missing.bc' |
26 | 26 | ; |
27 | 27 | ; Test the dry run of a simple case to link two input files. |
28 | 28 | ; Test that IMG_SPIRV image kind is set for non-AOT compilation. |
29 | 29 | ; RUN: clang-sycl-linker --dry-run -v --module-split-mode=none %t/input1.bc %t/input2.bc -o %t/spirv.out 2>&1 \ |
30 | 30 | ; RUN: | FileCheck %s --check-prefix=SIMPLE-FO |
31 | | -; SIMPLE-FO: link: inputs: {{.*}}.bc, {{.*}}.bc libfiles: output: [[LLVMLINKOUT:.*]].bc |
| 31 | +; SIMPLE-FO: link: inputs: {{.*}}.bc, {{.*}}.bc output: [[LLVMLINKOUT:.*]].bc |
32 | 32 | ; SIMPLE-FO-NEXT: LLVM backend: input: [[LLVMLINKOUT]].bc, output: {{.*}}_0.spv |
33 | 33 | ; SIMPLE-FO-NEXT: sycl-bundle: image kind: spv, triple: spirv64, arch: {{$}} |
34 | 34 | ; SIMPLE-FO-NOT: {{.+}} |
35 | 35 | ; |
36 | | -; Test the dry run of a simple case with device library files specified. |
| 36 | +; Test the dry run of a simple case with device library archive specified using --whole-archive. |
37 | 37 | ; RUN: mkdir -p %t/libs |
38 | | -; RUN: touch %t/libs/lib1.bc |
39 | | -; RUN: touch %t/libs/lib2.bc |
40 | | -; RUN: clang-sycl-linker --dry-run -v --module-split-mode=none %t/input1.bc %t/input2.bc --library-path=%t/libs --bc-library lib1.bc --bc-library lib2.bc -o a.spv 2>&1 \ |
| 38 | +; RUN: llvm-as %t/lib1.ll -o %t/libs/lib1.bc |
| 39 | +; RUN: llvm-as %t/lib2.ll -o %t/libs/lib2.bc |
| 40 | +; RUN: rm -f %t/libs/libdevice.a |
| 41 | +; RUN: llvm-ar rc %t/libs/libdevice.a %t/libs/lib1.bc %t/libs/lib2.bc |
| 42 | +; RUN: clang-sycl-linker --dry-run -v --module-split-mode=none %t/input1.bc %t/input2.bc --library-path=%t/libs --whole-archive -l device -o a.spv 2>&1 \ |
41 | 43 | ; RUN: | FileCheck %s --check-prefix=DEVLIBS |
42 | | -; DEVLIBS: link: inputs: {{.*}}.bc libfiles: {{.*}}lib1.bc, {{.*}}lib2.bc output: [[LLVMLINKOUT:.*]].bc |
| 44 | +; DEVLIBS: link: inputs: {{.*}}.bc, {{.*}}.bc, {{.*}}libdevice.a(lib1.bc), {{.*}}libdevice.a(lib2.bc) output: [[LLVMLINKOUT:.*]].bc |
43 | 45 | ; DEVLIBS-NEXT: LLVM backend: input: [[LLVMLINKOUT]].bc, output: a_0.spv |
44 | 46 | ; DEVLIBS-NEXT: sycl-bundle: image kind: spv, triple: spirv64, arch: {{$}} |
45 | 47 | ; DEVLIBS-NOT: {{.+}} |
46 | 48 | ; |
47 | | -; Test -L short form (joined) and --bc-library= joined form. |
48 | | -; RUN: clang-sycl-linker --dry-run -v --module-split-mode=none %t/input1.bc -L%t/libs --bc-library=lib1.bc -o a.spv 2>&1 \ |
| 49 | +; Test -L short form (joined) and -l with archive using --whole-archive. |
| 50 | +; RUN: clang-sycl-linker --dry-run -v --module-split-mode=none %t/input1.bc -L%t/libs --whole-archive -l device -o a.spv 2>&1 \ |
49 | 51 | ; RUN: | FileCheck %s --check-prefix=DEVLIBS-SHORT |
50 | | -; DEVLIBS-SHORT: link: inputs: {{.*}}.bc libfiles: {{.*}}libs{{[/\\]}}lib1.bc output: {{.*}}.bc |
| 52 | +; DEVLIBS-SHORT: link: inputs: {{.*}}.bc, {{.*}}libdevice.a(lib1.bc), {{.*}}libdevice.a(lib2.bc) output: {{.*}}.bc |
51 | 53 | ; |
52 | | -; Test that search continues past the first -L when the library is not found there. lib1.bc exists only in %t/libs (the second -L). |
| 54 | +; Test that search continues past the first -L when the library is not found there. libdevice.a exists only in %t/libs (the second -L). |
53 | 55 | ; RUN: mkdir -p %t/empty |
54 | | -; RUN: clang-sycl-linker --dry-run -v --module-split-mode=none %t/input1.bc -L %t/empty -L %t/libs --bc-library lib1.bc -o a.spv 2>&1 \ |
| 56 | +; RUN: clang-sycl-linker --dry-run -v --module-split-mode=none %t/input1.bc -L %t/empty -L %t/libs --whole-archive -l device -o a.spv 2>&1 \ |
55 | 57 | ; RUN: | FileCheck %s --check-prefix=DEVLIBS-FALLTHROUGH |
56 | | -; DEVLIBS-FALLTHROUGH: link: inputs: {{.*}}.bc libfiles: {{.*}}libs{{[/\\]}}lib1.bc output: {{.*}}.bc |
57 | | -; |
58 | | -; Test that -L paths are searched in order: when the same name exists in multiple -L dirs, the first one wins. |
59 | | -; RUN: mkdir -p %t/libs2 |
60 | | -; RUN: touch %t/libs/shadow.bc %t/libs2/shadow.bc |
61 | | -; RUN: clang-sycl-linker --dry-run -v --module-split-mode=none %t/input1.bc -L %t/libs2 -L %t/libs --bc-library shadow.bc -o a.spv 2>&1 \ |
62 | | -; RUN: | FileCheck %s --check-prefix=DEVLIBS-ORDER |
63 | | -; DEVLIBS-ORDER: link: inputs: {{.*}}.bc libfiles: {{.*}}libs2{{[/\\]}}shadow.bc output: {{.*}}.bc |
| 58 | +; DEVLIBS-FALLTHROUGH: link: inputs: {{.*}}.bc, {{.*}}libdevice.a(lib1.bc), {{.*}}libdevice.a(lib2.bc) output: {{.*}}.bc |
64 | 59 | ; |
65 | 60 | ; Test a simple case with a random file (not bitcode) as input. |
66 | 61 | ; RUN: touch %t/dummy.o |
67 | 62 | ; RUN: not clang-sycl-linker %t/dummy.o -o a.spv 2>&1 \ |
68 | 63 | ; RUN: | FileCheck %s --check-prefix=FILETYPEERROR |
69 | | -; FILETYPEERROR: Unsupported file type |
| 64 | +; FILETYPEERROR: Unsupported file type: '{{.*}}dummy.o' |
| 65 | +; |
| 66 | +; Test that unsupported file type error includes buffer identifier when found inside an archive. |
| 67 | +; Create an archive containing an unsupported file (text file instead of bitcode). |
| 68 | +; RUN: echo "not bitcode" > %t/invalid.txt |
| 69 | +; RUN: rm -f %t/libinvalid.a |
| 70 | +; RUN: llvm-ar rc %t/libinvalid.a %t/invalid.txt |
| 71 | +; RUN: not clang-sycl-linker --dry-run %t/input1.bc -L %t --whole-archive -l invalid -o a.spv 2>&1 \ |
| 72 | +; RUN: | FileCheck %s --check-prefix=ARCHIVE-INVALID-MEMBER |
| 73 | +; ARCHIVE-INVALID-MEMBER: Unsupported file type: '{{.*}}libinvalid.a(invalid.txt)' |
| 74 | +; |
| 75 | +; Test mixed archive: valid bitcode member + invalid member. |
| 76 | +; The error should clearly identify which member is invalid. |
| 77 | +; RUN: rm -f %t/libmixed.a |
| 78 | +; RUN: llvm-ar rc %t/libmixed.a %t/libs/lib1.bc %t/invalid.txt |
| 79 | +; RUN: not clang-sycl-linker --dry-run %t/input1.bc -L %t --whole-archive -l mixed -o a.spv 2>&1 \ |
| 80 | +; RUN: | FileCheck %s --check-prefix=ARCHIVE-MIXED-INVALID |
| 81 | +; ARCHIVE-MIXED-INVALID: Unsupported file type: '{{.*}}libmixed.a(invalid.txt)' |
70 | 82 | ; |
71 | 83 | ; Test to see if device library related errors are emitted. |
72 | | -; RUN: not clang-sycl-linker --dry-run %t/input1.bc %t/input2.bc --library-path=%t/libs --bc-library lib1.bc --bc-library lib2.bc --bc-library lib3.bc -o a.spv 2>&1 \ |
| 84 | +; RUN: not clang-sycl-linker --dry-run %t/input1.bc %t/input2.bc --library-path=%t/libs -l device -l nonexistent -o a.spv 2>&1 \ |
73 | 85 | ; RUN: | FileCheck %s --check-prefix=DEVLIBSERR |
74 | | -; DEVLIBSERR: '{{.*}}lib3.bc' library file not found |
| 86 | +; DEVLIBSERR: unable to find library -lnonexistent |
75 | 87 | ; |
76 | | -; Test that there is no implicit CWD search: a bare bitcode name without any -L |
| 88 | +; Test that there is no implicit CWD search: a bare library name without any -L |
77 | 89 | ; must fail to resolve, even if a same-named file exists in the CWD. |
78 | | -; RUN: cd %t && not clang-sycl-linker --dry-run input1.bc --bc-library input1.bc -o a.spv 2>&1 \ |
| 90 | +; RUN: cd %t && not clang-sycl-linker --dry-run input1.bc -l mixed -o a.spv 2>&1 \ |
79 | 91 | ; RUN: | FileCheck %s --check-prefix=NO-CWD-SEARCH |
80 | | -; NO-CWD-SEARCH: 'input1.bc' library file not found |
| 92 | +; NO-CWD-SEARCH: unable to find library -lmixed |
81 | 93 | ; |
82 | 94 | ; Test that a directory matching the requested name is not accepted as a library: |
83 | | -; %t/libs is a directory created above; resolving --bc-library libs against -L %t |
84 | | -; would otherwise pick it up and fail later with a confusing bitcode-reader error. |
85 | | -; RUN: not clang-sycl-linker --dry-run %t/input1.bc -L %t --bc-library libs -o a.spv 2>&1 \ |
| 95 | +; %t/libs is a directory created above; resolving -l:libs against -L %t |
| 96 | +; would detect it's a directory and error with the filename in the message. |
| 97 | +; RUN: not clang-sycl-linker --dry-run %t/input1.bc -L %t -l :libs -o a.spv 2>&1 \ |
86 | 98 | ; RUN: | FileCheck %s --check-prefix=NO-DIR-AS-LIB |
87 | | -; NO-DIR-AS-LIB: 'libs' library file not found |
| 99 | +; NO-DIR-AS-LIB: '{{.*}}libs': Is a directory |
| 100 | +; |
| 101 | +; Test that providing only an empty archive results in "No input files could be resolved" error |
| 102 | +; RUN: rm -f %t/empty.a |
| 103 | +; RUN: llvm-ar rc %t/empty.a |
| 104 | +; RUN: not clang-sycl-linker --dry-run --whole-archive %t/empty.a -o a.spv 2>&1 \ |
| 105 | +; RUN: | FileCheck %s --check-prefix=NO-RESOLVED-INPUT |
| 106 | +; NO-RESOLVED-INPUT: No input files could be resolved |
| 107 | +; |
| 108 | +; Test that providing only a lazy archive with no extracted members results in "No input files could be resolved" error |
| 109 | +; RUN: not clang-sycl-linker --dry-run %t/libs/libdevice.a -o a.spv 2>&1 \ |
| 110 | +; RUN: | FileCheck %s --check-prefix=NO-RESOLVED-LAZY |
| 111 | +; NO-RESOLVED-LAZY: No input files could be resolved |
88 | 112 | ; |
89 | 113 | ; Test AOT compilation for an Intel GPU. |
90 | 114 | ; Test that IMG_Object image kind is set for AOT compilation (Intel GPU). |
91 | 115 | ; RUN: clang-sycl-linker --dry-run -v --module-split-mode=none -arch=bmg_g21 %t/input1.bc %t/input2.bc -o %t/aot-gpu.out 2>&1 \ |
92 | 116 | ; RUN: --ocloc-options="-a -b" \ |
93 | 117 | ; RUN: | FileCheck %s --check-prefix=AOT-INTEL-GPU |
94 | | -; AOT-INTEL-GPU: link: inputs: {{.*}}.bc, {{.*}}.bc libfiles: output: [[LLVMLINKOUT:.*]].bc |
| 118 | +; AOT-INTEL-GPU: link: inputs: {{.*}}.bc, {{.*}}.bc output: [[LLVMLINKOUT:.*]].bc |
95 | 119 | ; AOT-INTEL-GPU-NEXT: LLVM backend: input: [[LLVMLINKOUT]].bc, output: [[SPIRVTRANSLATIONOUT:.*]]_0.spv |
96 | 120 | ; AOT-INTEL-GPU-NEXT: "{{.*}}ocloc{{.*}}" {{.*}}-device bmg_g21 -a -b {{.*}}-output [[SPIRVTRANSLATIONOUT]]_0.out -file [[SPIRVTRANSLATIONOUT]]_0.spv |
97 | 121 | ; AOT-INTEL-GPU-NEXT: sycl-bundle: image kind: o, triple: spirv64, arch: bmg_g21 |
|
102 | 126 | ; RUN: clang-sycl-linker --dry-run -v --module-split-mode=none -arch=graniterapids %t/input1.bc %t/input2.bc -o %t/aot-cpu.out 2>&1 \ |
103 | 127 | ; RUN: --opencl-aot-options="-a -b" \ |
104 | 128 | ; RUN: | FileCheck %s --check-prefix=AOT-INTEL-CPU |
105 | | -; AOT-INTEL-CPU: link: inputs: {{.*}}.bc, {{.*}}.bc libfiles: output: [[LLVMLINKOUT:.*]].bc |
| 129 | +; AOT-INTEL-CPU: link: inputs: {{.*}}.bc, {{.*}}.bc output: [[LLVMLINKOUT:.*]].bc |
106 | 130 | ; AOT-INTEL-CPU-NEXT: LLVM backend: input: [[LLVMLINKOUT]].bc, output: [[SPIRVTRANSLATIONOUT:.*]]_0.spv |
107 | 131 | ; AOT-INTEL-CPU-NEXT: "{{.*}}opencl-aot{{.*}}" {{.*}}--device=cpu -a -b {{.*}}-o [[SPIRVTRANSLATIONOUT]]_0.out [[SPIRVTRANSLATIONOUT]]_0.spv |
108 | 132 | ; AOT-INTEL-CPU-NEXT: sycl-bundle: image kind: o, triple: spirv64, arch: graniterapids |
@@ -164,3 +188,19 @@ target triple = "spirv64" |
164 | 188 | define spir_func i32 @helper() { |
165 | 189 | ret i32 0 |
166 | 190 | } |
| 191 | + |
| 192 | +;--- lib1.ll |
| 193 | +target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1" |
| 194 | +target triple = "spirv64" |
| 195 | + |
| 196 | +define spir_func i32 @lib1_func() { |
| 197 | + ret i32 1 |
| 198 | +} |
| 199 | + |
| 200 | +;--- lib2.ll |
| 201 | +target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1" |
| 202 | +target triple = "spirv64" |
| 203 | + |
| 204 | +define spir_func i32 @lib2_func() { |
| 205 | + ret i32 2 |
| 206 | +} |
0 commit comments