1 // REQUIRES: x86-registered-target
2 // UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}
5 // Generate all the types of files we can bundle.
7 // RUN: %clang -O0 -target %itanium_abi_triple %s -E -o %t.i
8 // RUN: %clangxx -O0 -target %itanium_abi_triple -x c++ %s -E -o %t.ii
9 // RUN: %clang -O0 -target %itanium_abi_triple %s -S -emit-llvm -o %t.ll
10 // RUN: %clang -O0 -target %itanium_abi_triple %s -c -emit-llvm -o %t.bc
11 // RUN: %clang -O0 -target %itanium_abi_triple %s -S -o %t.s
12 // RUN: %clang -O0 -target %itanium_abi_triple %s -c -o %t.o
13 // RUN: %clang -O0 -target %itanium_abi_triple %s -emit-ast -o %t.ast
16 // Generate an empty file to help with the checks of empty files.
18 // RUN: touch %t.empty
21 // Generate a couple of files to bundle with.
23 // RUN: echo 'Content of device file 1' > %t.tgt1
24 // RUN: echo 'Content of device file 2' > %t.tgt2
27 // Check help message.
29 // RUN: clang-offload-bundler --help | FileCheck %s --check-prefix CK-HELP
30 // CK-HELP: {{.*}}OVERVIEW: A tool to bundle several input files of the specified type <type>
31 // CK-HELP: {{.*}}referring to the same source file but different targets into a single
32 // CK-HELP: {{.*}}one. The resulting file can also be unbundled into different files by
33 // CK-HELP: {{.*}}this tool if -unbundle is provided.
34 // CK-HELP: {{.*}}USAGE: clang-offload-bundler [options]
35 // CK-HELP: {{.*}}-### {{.*}}- Print any external commands that are to be executed instead of actually executing them - for testing purposes.
36 // CK-HELP: {{.*}}-allow-missing-bundles {{.*}}- Create empty files if bundles are missing when unbundling.
37 // CK-HELP: {{.*}}-bundle-align=<uint> {{.*}}- Alignment of bundle for binary files
38 // CK-HELP: {{.*}}-hip-openmp-compatible {{.*}}- Treat hip and hipv4 offload kinds as compatible with openmp kind, and vice versa.
39 // CK-HELP: {{.*}}-input=<string> - Input file. Can be specified multiple times for multiple input files.
40 // CK-HELP: {{.*}}-inputs=<string> - [<input file>,...] (deprecated)
41 // CK-HELP: {{.*}}-list {{.*}}- List bundle IDs in the bundled file.
42 // CK-HELP: {{.*}}-output=<string> - Output file. Can be specified multiple times for multiple output files.
43 // CK-HELP: {{.*}}-outputs=<string> - [<output file>,...] (deprecated)
44 // CK-HELP: {{.*}}-targets=<string> - [<offload kind>-<target triple>,...]
45 // CK-HELP: {{.*}}-type=<string> - Type of the files to be bundled/unbundled.
46 // CK-HELP: {{.*}}Current supported types are:
47 // CK-HELP: {{.*}}i {{.*}}- cpp-output
48 // CK-HELP: {{.*}}ii {{.*}}- c++-cpp-output
49 // CK-HELP: {{.*}}ll {{.*}}- llvm
50 // CK-HELP: {{.*}}bc {{.*}}- llvm-bc
51 // CK-HELP: {{.*}}s {{.*}}- assembler
52 // CK-HELP: {{.*}}o {{.*}}- object
53 // CK-HELP: {{.*}}a {{.*}}- archive of objects
54 // CK-HELP: {{.*}}gch {{.*}}- precompiled-header
55 // CK-HELP: {{.*}}ast {{.*}}- clang AST file
56 // CK-HELP: {{.*}}-unbundle {{.*}}- Unbundle bundled file into several output files.
61 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i -unbundle 2>&1 | FileCheck %s --check-prefix CK-ERR1
62 // CK-ERR1: error: only one input file supported in unbundling mode
64 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.i -output=%t.bundle.i -unbundle 2>&1 | FileCheck %s --check-prefix CK-ERR1A
65 // CK-ERR1A: error: number of output files and targets should match in unbundling mode
67 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR2
68 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.i -input=%t.tgt1 -output=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR2
69 // CK-ERR2: error: number of input files and targets should match in bundling mode
71 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.i -output=%t.tgt1 -output=%t.tgt2 -input=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR3
72 // CK-ERR3: error: only one output file supported in bundling mode
74 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu -output=%t.i -output=%t.tgt1 -output=%t.tgt2 -input=%t.bundle.i -unbundle 2>&1 | FileCheck %s --check-prefix CK-ERR4
75 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.i -output=%t.tgt1 -input=%t.bundle.i -unbundle 2>&1 | FileCheck %s --check-prefix CK-ERR4
76 // CK-ERR4: error: number of output files and targets should match in unbundling mode
78 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2.notexist -output=%t.bundle.i 2>&1 | \
79 // RUN: FileCheck %s -DFILE=%t.tgt2.notexist -DMSG=%errc_ENOENT --check-prefix CK-ERR5
80 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.i -output=%t.tgt1 -output=%t.tgt2 -input=%t.bundle.i.notexist -unbundle 2>&1 | \
81 // RUN: FileCheck %s -DFILE=%t.bundle.i.notexist -DMSG=%errc_ENOENT --check-prefix CK-ERR5
82 // CK-ERR5: error: '[[FILE]]': [[MSG]]
84 // RUN: not clang-offload-bundler -type=invalid -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s -DTYPE=invalid --check-prefix CK-ERR6
85 // CK-ERR6: error: '[[TYPE]]': invalid file type specified
87 // RUN: not clang-offload-bundler 2>&1 | FileCheck %s --check-prefix CK-ERR7
88 // CK-ERR7: clang-offload-bundler: for the --type option: must be specified at least once!
90 // RUN: not clang-offload-bundler -type=i -input=%t.i -input=%t.tgt1 -input=%t.tgt2 2>&1 | FileCheck %s -check-prefix=CK-ERR7A
91 // CK-ERR7A: error: no output file specified!
93 // RUN: not clang-offload-bundler -type=i -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s -check-prefix=CK-ERR7B
94 // CK-ERR7B: error: for the --targets option: must be specified at least once!
96 // RUN: not clang-offload-bundler -type=i -targets=hxst-powerpcxxle-ibm-linux-gnu,openxp-pxxerpc64le-ibm-linux-gnu,xpenmp-x86_xx-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR8
97 // CK-ERR8: error: invalid target 'hxst-powerpcxxle-ibm-linux-gnu', unknown offloading kind 'hxst', unknown target triple 'powerpcxxle-ibm-linux-gnu'
99 // RUN: not clang-offload-bundler -type=i -targets=host-powerpc64le-ibm-linux-gnu,openxp-pxxerpc64le-ibm-linux-gnu,xpenmp-x86_xx-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR8A
100 // CK-ERR8A: error: invalid target 'openxp-pxxerpc64le-ibm-linux-gnu', unknown offloading kind 'openxp', unknown target triple 'pxxerpc64le-ibm-linux-gnu'
102 // RUN: not clang-offload-bundler -type=i -targets=host-powerpc64le-ibm-linux-gnu,openmp-powerpc64le-ibm-linux-gnu,xpenmp-x86_xx-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR8B
103 // CK-ERR8B: error: invalid target 'xpenmp-x86_xx-pc-linux-gnu', unknown offloading kind 'xpenmp', unknown target triple 'x86_xx-pc-linux-gnu'
105 // RUN: not clang-offload-bundler -type=i -targets=openmp-powerpc64le-linux,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR9A
106 // CK-ERR9A: error: expecting exactly one host target but got 0
108 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR9B
109 // CK-ERR9B: error: Duplicate targets are not allowed
111 // RUN: not clang-offload-bundler -type=a -targets=hxst-powerpcxxle-ibm-linux-gnu,openxp-pxxerpc64le-ibm-linux-gnu,xpenmp-x86_xx-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR10A
112 // CK-ERR10A: error: Archive files are only supported for unbundling
114 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.i -inputs=%t.tgt1,%t.tgt2 -output=%t.bundle.i -unbundle 2>&1 | FileCheck %s --check-prefix CK-ERR11A
115 // CK-ERR11A: error: -inputs and -input cannot be used together, use only -input instead
117 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu -output=%t.i -outputs=%t.tgt1,%t.tgt2 -input=%t.bundle.i -unbundle 2>&1 | FileCheck %s --check-prefix CK-ERR11B
118 // CK-ERR11B: error: -outputs and -output cannot be used together, use only -output instead
121 // Check text bundle. This is a readable format, so we check for the format we expect to find.
123 // RUN: clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.i -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.i
124 // RUN: clang-offload-bundler -type=ii -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.ii -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.ii
125 // RUN: clang-offload-bundler -type=ll -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.ll -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.ll
126 // RUN: clang-offload-bundler -type=s -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.s -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.s
127 // RUN: clang-offload-bundler -type=s -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -input=%t.tgt1 -input=%t.s -input=%t.tgt2 -output=%t.bundle3.unordered.s
128 // RUN: FileCheck %s --input-file %t.bundle3.i --check-prefix CK-TEXTI
129 // RUN: FileCheck %s --input-file %t.bundle3.ii --check-prefix CK-TEXTI
130 // RUN: FileCheck %s --input-file %t.bundle3.ll --check-prefix CK-TEXTLL
131 // RUN: FileCheck %s --input-file %t.bundle3.s --check-prefix CK-TEXTS
132 // RUN: FileCheck %s --input-file %t.bundle3.unordered.s --check-prefix CK-TEXTS-UNORDERED
134 // CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____START__ host-[[HOST:.+]]
135 // CK-TEXTI: int A = 0;
136 // CK-TEXTI: test_func(void)
137 // CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____END__ host-[[HOST]]
138 // CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____START__ openmp-powerpc64le-ibm-linux-gnu
139 // CK-TEXTI: Content of device file 1
140 // CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____END__ openmp-powerpc64le-ibm-linux-gnu
141 // CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____START__ openmp-x86_64-pc-linux-gnu
142 // CK-TEXTI: Content of device file 2
143 // CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____END__ openmp-x86_64-pc-linux-gnu
145 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____START__ host-[[HOST:.+]]
146 // CK-TEXTLL: @A = {{.*}}global i32 0
147 // CK-TEXTLL: define {{.*}}@test_func()
148 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____END__ host-[[HOST]]
149 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____START__ openmp-powerpc64le-ibm-linux-gnu
150 // CK-TEXTLL: Content of device file 1
151 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____END__ openmp-powerpc64le-ibm-linux-gnu
152 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____START__ openmp-x86_64-pc-linux-gnu
153 // CK-TEXTLL: Content of device file 2
154 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____END__ openmp-x86_64-pc-linux-gnu
156 // CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____START__ host-[[HOST:.+]]
157 // CK-TEXTS: .globl {{.*}}test_func
158 // CK-TEXTS: .globl {{.*}}A
159 // CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____END__ host-[[HOST]]
160 // CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____START__ openmp-powerpc64le-ibm-linux-gnu
161 // CK-TEXTS: Content of device file 1
162 // CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____END__ openmp-powerpc64le-ibm-linux-gnu
163 // CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____START__ openmp-x86_64-pc-linux-gnu
164 // CK-TEXTS: Content of device file 2
165 // CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____END__ openmp-x86_64-pc-linux-gnu
167 // CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____START__ openmp-powerpc64le-ibm-linux-gnu
168 // CK-TEXTS-UNORDERED: Content of device file 1
169 // CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____END__ openmp-powerpc64le-ibm-linux-gnu
170 // CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____START__ host-[[HOST:.+]]
171 // CK-TEXTS-UNORDERED: .globl {{.*}}test_func
172 // CK-TEXTS-UNORDERED: .globl {{.*}}A
173 // CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____END__ host-[[HOST]]
174 // CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____START__ openmp-x86_64-pc-linux-gnu
175 // CK-TEXTS-UNORDERED: Content of device file 2
176 // CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____END__ openmp-x86_64-pc-linux-gnu
179 // Check text unbundle. Check if we get the exact same content that we bundled before for each file.
181 // RUN: clang-offload-bundler -type=i -input=%t.bundle3.i -list | FileCheck -check-prefix=CKLST %s
182 // RUN: clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.i -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.i -unbundle
183 // RUN: diff %t.i %t.res.i
184 // RUN: diff %t.tgt1 %t.res.tgt1
185 // RUN: diff %t.tgt2 %t.res.tgt2
186 // RUN: clang-offload-bundler -type=i -targets=openmp-powerpc64le-ibm-linux-gnu -output=%t.res.tgt1 -input=%t.bundle3.i -unbundle
187 // RUN: diff %t.tgt1 %t.res.tgt1
188 // RUN: clang-offload-bundler -type=ii -input=%t.bundle3.ii -list | FileCheck -check-prefix=CKLST %s
189 // RUN: clang-offload-bundler -type=ii -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.ii -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.ii -unbundle
190 // RUN: diff %t.ii %t.res.ii
191 // RUN: diff %t.tgt1 %t.res.tgt1
192 // RUN: diff %t.tgt2 %t.res.tgt2
193 // RUN: clang-offload-bundler -type=ii -targets=openmp-x86_64-pc-linux-gnu -output=%t.res.tgt2 -input=%t.bundle3.ii -unbundle
194 // RUN: diff %t.tgt2 %t.res.tgt2
195 // RUN: clang-offload-bundler -type=ll -input=%t.bundle3.ll -list | FileCheck -check-prefix=CKLST %s
196 // RUN: clang-offload-bundler -type=ll -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.ll -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.ll -unbundle
197 // RUN: diff %t.ll %t.res.ll
198 // RUN: diff %t.tgt1 %t.res.tgt1
199 // RUN: diff %t.tgt2 %t.res.tgt2
200 // RUN: clang-offload-bundler -type=ll -targets=openmp-powerpc64le-ibm-linux-gnu -output=%t.res.tgt1 -input=%t.bundle3.ll -unbundle
201 // RUN: diff %t.tgt1 %t.res.tgt1
202 // RUN: clang-offload-bundler -type=s -input=%t.bundle3.s -list | FileCheck -check-prefix=CKLST %s
203 // RUN: clang-offload-bundler -type=s -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.s -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.s -unbundle
204 // RUN: diff %t.s %t.res.s
205 // RUN: diff %t.tgt1 %t.res.tgt1
206 // RUN: diff %t.tgt2 %t.res.tgt2
207 // RUN: clang-offload-bundler -type=s -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.tgt1 -output=%t.res.s -output=%t.res.tgt2 -input=%t.bundle3.s -unbundle
208 // RUN: diff %t.s %t.res.s
209 // RUN: diff %t.tgt1 %t.res.tgt1
210 // RUN: diff %t.tgt2 %t.res.tgt2
211 // RUN: clang-offload-bundler -type=s -targets=openmp-x86_64-pc-linux-gnu -output=%t.res.tgt2 -input=%t.bundle3.s -unbundle
212 // RUN: diff %t.tgt2 %t.res.tgt2
214 // Check if we can unbundle a file with no magic strings.
215 // RUN: clang-offload-bundler -type=s -input=%t.s -list | FileCheck -check-prefix=CKLST2 --allow-empty %s
216 // RUN: clang-offload-bundler -type=s -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.s -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.s -unbundle -allow-missing-bundles
217 // RUN: diff %t.s %t.res.s
218 // RUN: diff %t.empty %t.res.tgt1
219 // RUN: diff %t.empty %t.res.tgt2
220 // RUN: clang-offload-bundler -type=s -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.tgt1 -output=%t.res.s -output=%t.res.tgt2 -input=%t.s -unbundle -allow-missing-bundles
221 // RUN: diff %t.s %t.res.s
222 // RUN: diff %t.empty %t.res.tgt1
223 // RUN: diff %t.empty %t.res.tgt2
225 // Check that bindler prints an error if given host bundle does not exist in the fat binary.
226 // RUN: not clang-offload-bundler -type=s -targets=host-amdgcn-xxx-linux-gnu,openmp-powerpc64le-ibm-linux-gnu -output=%t.res.s -output=%t.res.tgt1 -input=%t.bundle3.s -unbundle 2>&1 | FileCheck %s --check-prefix CK-NO-HOST-BUNDLE
227 // CK-NO-HOST-BUNDLE: error: Can't find bundles for host-amdgcn-xxx-linux-gnu
229 // Check missing host entry is allowed with -allow-missing-bundles
230 // RUN: clang-offload-bundler -type=s -targets=host-amdgcn-xxx-linux-gnu,openmp-powerpc64le-ibm-linux-gnu -output=%t.res.s -output=%t.res.tgt1 -input=%t.bundle3.s -unbundle -allow-missing-bundles
233 // Check binary bundle/unbundle. The content that we have before bundling must be the same we have after unbundling.
235 // RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.bc -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.bc
236 // RUN: clang-offload-bundler -type=gch -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.ast -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.gch
237 // RUN: clang-offload-bundler -type=ast -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.ast -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.ast
238 // RUN: clang-offload-bundler -type=ast -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -input=%t.tgt1 -input=%t.ast -input=%t.tgt2 -output=%t.bundle3.unordered.ast
239 // RUN: clang-offload-bundler -type=bc -input=%t.bundle3.bc -list | FileCheck -check-prefix=CKLST %s
240 // RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.bc -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.bc -unbundle
241 // RUN: diff %t.bc %t.res.bc
242 // RUN: diff %t.tgt1 %t.res.tgt1
243 // RUN: diff %t.tgt2 %t.res.tgt2
244 // RUN: clang-offload-bundler -type=bc -targets=openmp-powerpc64le-ibm-linux-gnu -output=%t.res.tgt1 -input=%t.bundle3.bc -unbundle
245 // RUN: diff %t.tgt1 %t.res.tgt1
246 // RUN: clang-offload-bundler -type=gch -input=%t.bundle3.gch -list | FileCheck -check-prefix=CKLST %s
247 // RUN: clang-offload-bundler -type=gch -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.gch -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.gch -unbundle
248 // RUN: diff %t.ast %t.res.gch
249 // RUN: diff %t.tgt1 %t.res.tgt1
250 // RUN: diff %t.tgt2 %t.res.tgt2
251 // RUN: clang-offload-bundler -type=gch -targets=openmp-x86_64-pc-linux-gnu -output=%t.res.tgt2 -input=%t.bundle3.gch -unbundle
252 // RUN: diff %t.tgt2 %t.res.tgt2
253 // RUN: clang-offload-bundler -type=ast -input=%t.bundle3.ast -list | FileCheck -check-prefix=CKLST %s
254 // RUN: clang-offload-bundler -type=ast -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.ast -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.ast -unbundle
255 // RUN: diff %t.ast %t.res.ast
256 // RUN: diff %t.tgt1 %t.res.tgt1
257 // RUN: diff %t.tgt2 %t.res.tgt2
258 // RUN: clang-offload-bundler -type=ast -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.tgt1 -output=%t.res.ast -output=%t.res.tgt2 -input=%t.bundle3.ast -unbundle
259 // RUN: diff %t.ast %t.res.ast
260 // RUN: diff %t.tgt1 %t.res.tgt1
261 // RUN: diff %t.tgt2 %t.res.tgt2
262 // RUN: clang-offload-bundler -type=ast -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.tgt1 -output=%t.res.ast -output=%t.res.tgt2 -input=%t.bundle3.unordered.ast -unbundle
263 // RUN: diff %t.ast %t.res.ast
264 // RUN: diff %t.tgt1 %t.res.tgt1
265 // RUN: diff %t.tgt2 %t.res.tgt2
266 // RUN: clang-offload-bundler -type=ast -targets=openmp-powerpc64le-ibm-linux-gnu -output=%t.res.tgt1 -input=%t.bundle3.ast -unbundle
267 // RUN: diff %t.tgt1 %t.res.tgt1
269 // Check if we can unbundle a file with no magic strings.
270 // RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.bc -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bc -unbundle -allow-missing-bundles
271 // RUN: diff %t.bc %t.res.bc
272 // RUN: diff %t.empty %t.res.tgt1
273 // RUN: diff %t.empty %t.res.tgt2
274 // RUN: clang-offload-bundler -type=bc -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.tgt1 -output=%t.res.bc -output=%t.res.tgt2 -input=%t.bc -unbundle -allow-missing-bundles
275 // RUN: diff %t.bc %t.res.bc
276 // RUN: diff %t.empty %t.res.tgt1
277 // RUN: diff %t.empty %t.res.tgt2
279 // Check that we do not have to unbundle all available bundles from the fat binary.
280 // RUN: clang-offload-bundler -type=ast -targets=host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.ast -output=%t.res.tgt2 -input=%t.bundle3.unordered.ast -unbundle
281 // RUN: diff %t.ast %t.res.ast
282 // RUN: diff %t.tgt2 %t.res.tgt2
284 // Check that we do not have to unbundle all available bundles from the fat binary.
285 // RUN: clang-offload-bundler -type=ast -targets=host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.ast -output=%t.res.tgt2 -input=%t.bundle3.unordered.ast -unbundle
286 // RUN: diff %t.ast %t.res.ast
287 // RUN: diff %t.tgt2 %t.res.tgt2
290 // Check object bundle/unbundle. The content should be bundled into an ELF
291 // section (we are using a PowerPC little-endian host which uses ELF). We
292 // have an already bundled file to check the unbundle and do a dry run on the
293 // bundling as it cannot be tested in all host platforms that will run these
297 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
298 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD
299 // CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST:.+]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
301 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
302 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD-INPUTS
303 // CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST:.+]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
305 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o
306 // RUN: clang-offload-bundler -type=o -input=%t.bundle3.o -list | FileCheck -check-prefix=CKLST %s
307 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.o -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.o -unbundle
308 // RUN: diff %t.bundle3.o %t.res.o
309 // RUN: diff %t.tgt1 %t.res.tgt1
310 // RUN: diff %t.tgt2 %t.res.tgt2
311 // RUN: clang-offload-bundler -type=o -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.tgt1 -output=%t.res.o -output=%t.res.tgt2 -input=%t.bundle3.o -unbundle
312 // RUN: diff %t.bundle3.o %t.res.o
313 // RUN: diff %t.tgt1 %t.res.tgt1
314 // RUN: diff %t.tgt2 %t.res.tgt2
315 // RUN: clang-offload-bundler -type=o -targets=openmp-powerpc64le-ibm-linux-gnu -output=%t.res.tgt1 -input=%t.bundle3.o -unbundle
316 // RUN: diff %t.tgt1 %t.res.tgt1
318 // Check if we can unbundle a file with no magic strings.
319 // RUN: clang-offload-bundler -type=o -input=%t.o -list | FileCheck -check-prefix=CKLST2 --allow-empty %s
320 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.o -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.o -unbundle -allow-missing-bundles
321 // RUN: diff %t.o %t.res.o
322 // RUN: diff %t.empty %t.res.tgt1
323 // RUN: diff %t.empty %t.res.tgt2
324 // RUN: clang-offload-bundler -type=o -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -output=%t.res.tgt1 -output=%t.res.o -output=%t.res.tgt2 -input=%t.o -unbundle -allow-missing-bundles
325 // RUN: diff %t.o %t.res.o
326 // RUN: diff %t.empty %t.res.tgt1
327 // RUN: diff %t.empty %t.res.tgt2
330 // Check -bundle-align option
333 // RUN: clang-offload-bundler -bundle-align=4096 -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.bc -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.bc
334 // RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.bc -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.bc -unbundle
335 // RUN: diff %t.bc %t.res.bc
336 // RUN: diff %t.tgt1 %t.res.tgt1
337 // RUN: diff %t.tgt2 %t.res.tgt2
340 // Check error due to missing bundles
342 // RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,hip-amdgcn-amd-amdhsa--gfx900 -input=%t.bc -input=%t.tgt1 -output=%t.hip.bundle.bc
343 // RUN: not clang-offload-bundler -type=bc -input=%t.hip.bundle.bc -output=%t.tmp.bc -unbundle \
344 // RUN: -targets=hip-amdgcn-amd-amdhsa--gfx906 \
345 // RUN: 2>&1 | FileCheck -check-prefix=MISS1 %s
346 // RUN: not clang-offload-bundler -type=bc -input=%t.hip.bundle.bc -output=%t.tmp.bc -output=%t.tmp2.bc -unbundle \
347 // RUN: -targets=hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx900 \
348 // RUN: 2>&1 | FileCheck -check-prefix=MISS1 %s
349 // MISS1: error: Can't find bundles for hip-amdgcn-amd-amdhsa--gfx906
350 // RUN: not clang-offload-bundler -type=bc -input=%t.hip.bundle.bc -output=%t.tmp.bc -output=%t.tmp2.bc -unbundle \
351 // RUN: -targets=hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx803 \
352 // RUN: 2>&1 | FileCheck -check-prefix=MISS2 %s
353 // MISS2: error: Can't find bundles for hip-amdgcn-amd-amdhsa--gfx803 and hip-amdgcn-amd-amdhsa--gfx906
354 // RUN: not clang-offload-bundler -type=bc -input=%t.hip.bundle.bc -output=%t.tmp.bc -output=%t.tmp2.bc -output=%t.tmp3.bc -unbundle \
355 // RUN: -targets=hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx1010 \
356 // RUN: 2>&1 | FileCheck -check-prefix=MISS3 %s
357 // MISS3: error: Can't find bundles for hip-amdgcn-amd-amdhsa--gfx1010, hip-amdgcn-amd-amdhsa--gfx803, and hip-amdgcn-amd-amdhsa--gfx906
360 // Check error due to duplicate targets
362 // RUN: not clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx900 \
363 // RUN: -input=%t.bc -input=%t.tgt1 -input=%t.tgt1 -output=%t.hip.bundle.bc 2>&1 | FileCheck -check-prefix=DUP %s
364 // RUN: not clang-offload-bundler -type=bc -input=%t.hip.bundle.bc -output=%t.tmp.bc -output=%t.tmp2.bc -unbundle \
365 // RUN: -targets=hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx906 \
366 // RUN: 2>&1 | FileCheck -check-prefix=DUP %s
367 // DUP: error: Duplicate targets are not allowed
369 // Check -list option
372 // RUN: clang-offload-bundler -bundle-align=4096 -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.bc -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.bc
373 // RUN: not clang-offload-bundler -type=bc -input=%t.bundle3.bc -unbundle -list 2>&1 | FileCheck -check-prefix=CKLST-ERR %s
374 // CKLST-ERR: error: -unbundle and -list cannot be used together
375 // RUN: not clang-offload-bundler -type=bc -input=%t.bundle3.bc -targets=host-%itanium_abi_triple -list 2>&1 | FileCheck -check-prefix=CKLST-ERR2 %s
376 // CKLST-ERR2: error: -targets option is invalid for -list
377 // RUN: not clang-offload-bundler -type=bc -input=%t.bundle3.bc -output=out.txt -list 2>&1 | FileCheck -check-prefix=CKLST-ERR3 %s
378 // CKLST-ERR3: error: -outputs option is invalid for -list
379 // RUN: not clang-offload-bundler -type=bc -input=%t.bundle3.bc -input=%t.bc -list 2>&1 | FileCheck -check-prefix=CKLST-ERR4 %s
380 // CKLST-ERR4: error: only one input file supported for -list
383 // CKLST-DAG: openmp-powerpc64le-ibm-linux-gnu
384 // CKLST-DAG: openmp-x86_64-pc-linux-gnu
387 // CKLST2-NOT: openmp-powerpc64le-ibm-linux-gnu
388 // CKLST2-NOT: openmp-x86_64-pc-linux-gnu
391 // Check unbundling archive for HIP.
393 // When the input to clang-offload-bundler is an archive of bundled bitcodes,
394 // for each target, clang-offload-bundler extracts the bitcode from each
395 // bundle and archives them. Therefore for each target, the output is an
396 // archive of unbundled bitcodes.
398 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
399 // RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%T/hip_bundle1.bc
400 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
401 // RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%T/hip_bundle2.bc
402 // RUN: llvm-ar cr %T/hip_archive.a %T/hip_bundle1.bc %T/hip_bundle2.bc
403 // RUN: clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
404 // RUN: -output=%T/hip_900.a -output=%T/hip_906.a -input=%T/hip_archive.a
405 // RUN: llvm-ar t %T/hip_900.a | FileCheck -check-prefix=HIP-AR-900 %s
406 // RUN: llvm-ar t %T/hip_906.a | FileCheck -check-prefix=HIP-AR-906 %s
407 // HIP-AR-900-DAG: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx900
408 // HIP-AR-900-DAG: hip_bundle2-hip-amdgcn-amd-amdhsa--gfx900
409 // HIP-AR-906-DAG: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx906
410 // HIP-AR-906-DAG: hip_bundle2-hip-amdgcn-amd-amdhsa--gfx906
412 // Check clang-offload-bundler reporting an error when trying to unbundle an archive but
413 // the input file is not an archive.
415 // RUN: echo 'This is not an archive file.' > %t.non-archive
416 // RUN: not clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa--gfx900 \
417 // RUN: -output=%t.res.a -input=%t.non-archive --allow-missing-bundles 2>&1 \
418 // RUN: | FileCheck %s -check-prefix=INVARCHIVE
419 // RUN: not clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa--gfx900 \
420 // RUN: -output=%t.res.a -input=%t.non-archive 2>&1 | FileCheck %s -check-prefix=INVARCHIVE
421 // INVARCHIVE: error: file too small to be an archive
424 // Check bundling without host target is allowed for HIP.
426 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
427 // RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip.bundle.bc
428 // RUN: clang-offload-bundler -type=bc -list -input=%t.hip.bundle.bc | FileCheck -check-prefix=NOHOST %s
429 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \
430 // RUN: -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.hip.bundle.bc -unbundle
431 // RUN: diff %t.tgt1 %t.res.tgt1
432 // RUN: diff %t.tgt2 %t.res.tgt2
435 // NOHOST-DAG: hip-amdgcn-amd-amdhsa--gfx900
436 // NOHOST-DAG: hip-amdgcn-amd-amdhsa--gfx906
439 // Check bundling ID compatibility for HIP.
441 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx906:xnack- \
442 // RUN: -targets=hip-amdgcn-amd-amdhsa--gfx906:xnack+ \
443 // RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip.bundle.bc
444 // RUN: not clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx906 \
445 // RUN: -targets=hip-amdgcn-amd-amdhsa--gfx906:xnack+ \
446 // RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip.bundle.bc 2>&1 \
447 // RUN: | FileCheck %s -check-prefix=CONFLICT-TID
448 // CONFLICT-TID: error: Cannot bundle inputs with conflicting targets: 'hip-amdgcn-amd-amdhsa--gfx906' and 'hip-amdgcn-amd-amdhsa--gfx906:xnack+'
451 // Check extracting bundle entry with compatible target ID for HIP.
453 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx906 \
454 // RUN: -input=%t.tgt1 -output=%t.hip.bundle.bc
455 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx906:xnack- \
456 // RUN: -output=%t.res.tgt1 -input=%t.hip.bundle.bc -unbundle
457 // RUN: diff %t.tgt1 %t.res.tgt1
458 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx906:xnack+ \
459 // RUN: -output=%t.res.tgt1 -input=%t.hip.bundle.bc -unbundle
460 // RUN: diff %t.tgt1 %t.res.tgt1
462 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx906:xnack+ \
463 // RUN: -input=%t.tgt1 -output=%t.hip.bundle.bc
464 // RUN: not clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx906:xnack- \
465 // RUN: -output=%t.res.tgt1 -input=%t.hip.bundle.bc -unbundle 2>&1 | FileCheck %s -check-prefix=NOXNACK
466 // NOXNACK: error: Can't find bundles for hip-amdgcn-amd-amdhsa--gfx906:xnack-
467 // RUN: not clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx906 \
468 // RUN: -output=%t.res.tgt1 -input=%t.hip.bundle.bc -unbundle 2>&1 | FileCheck %s -check-prefix=NOGFX906
469 // NOGFX906: error: Can't find bundles for hip-amdgcn-amd-amdhsa--gfx906
472 // Check archive unbundling
474 // Create few code object bundles and archive them to create an input archive
475 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-amdgcn-amd-amdhsa-gfx906,openmp-amdgcn-amd-amdhsa--gfx908 -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.simple.bundle
476 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-amdgcn-amd-amdhsa--gfx903 -input=%t.o -input=%t.tgt1 -output=%t.simple1.bundle
477 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,hip-amdgcn-amd-amdhsa--gfx906 -input=%t.o -input=%t.tgt1 -output=%t.simple2.bundle
478 // RUN: llvm-ar cr %t.input-archive.a %t.simple.bundle %t.simple1.bundle %t.simple2.bundle
480 // RUN: clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa-gfx906,openmp-amdgcn-amd-amdhsa-gfx908 -input=%t.input-archive.a -output=%t-archive-gfx906-simple.a -output=%t-archive-gfx908-simple.a
481 // RUN: llvm-ar t %t-archive-gfx906-simple.a | FileCheck %s -check-prefix=GFX906
482 // RUN: clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa-gfx906:xnack+ -input=%t.input-archive.a -output=%t-archive-gfx906-simple.a
483 // RUN: llvm-ar t %t-archive-gfx906-simple.a | FileCheck %s -check-prefix=GFX906
484 // GFX906: simple-openmp-amdgcn-amd-amdhsa--gfx906
485 // RUN: llvm-ar t %t-archive-gfx908-simple.a | FileCheck %s -check-prefix=GFX908
486 // GFX908-NOT: {{gfx906}}
487 // RUN: not clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-amdgcn-amd-amdhsa-gfx906,openmp-amdgcn-amd-amdhsa-gfx906:sramecc+ -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bad.bundle 2>&1 | FileCheck %s -check-prefix=BADTARGETS
488 // BADTARGETS: error: Cannot bundle inputs with conflicting targets: 'openmp-amdgcn-amd-amdhsa--gfx906' and 'openmp-amdgcn-amd-amdhsa--gfx906:sramecc+'
490 // Check for error if no compatible code object is found in the heterogeneous archive library
491 // RUN: not clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa-gfx803 -input=%t.input-archive.a -output=%t-archive-gfx803-incompatible.a 2>&1 | FileCheck %s -check-prefix=INCOMPATIBLEARCHIVE
492 // INCOMPATIBLEARCHIVE: error: no compatible code object found for the target 'openmp-amdgcn-amd-amdhsa--gfx803' in heterogeneous archive library
494 // Check creation of empty archive if allow-missing-bundles is present and no compatible code object is found in the heterogeneous archive library
495 // RUN: clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa-gfx803 -input=%t.input-archive.a -output=%t-archive-gfx803-empty.a -allow-missing-bundles
496 // RUN: cat %t-archive-gfx803-empty.a | FileCheck %s -check-prefix=EMPTYARCHIVE
497 // EMPTYARCHIVE: !<arch>
499 // Check compatibility of OpenMP code objects found in the heterogeneous archive library with HIP code objects of the target
500 // RUN: clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa-gfx906,hipv4-amdgcn-amd-amdhsa-gfx908 -input=%t.input-archive.a -output=%t-hip-archive-gfx906-simple.a -output=%t-hipv4-archive-gfx908-simple.a -hip-openmp-compatible
501 // RUN: llvm-ar t %t-hip-archive-gfx906-simple.a | FileCheck %s -check-prefix=HIPOPENMPCOMPAT
502 // HIPOPENMPCOMPAT: simple-openmp-amdgcn-amd-amdhsa--gfx906
503 // RUN: llvm-ar t %t-hipv4-archive-gfx908-simple.a | FileCheck %s -check-prefix=HIPv4OPENMPCOMPAT
504 // HIPv4OPENMPCOMPAT: simple-openmp-amdgcn-amd-amdhsa--gfx908
506 // Check compatibility of HIP code objects found in the heterogeneous archive library with OpenMP code objects of the target
507 // RUN: clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa--gfx906 \
508 // RUN: -output=%T/hip-openmp_906.a -input=%T/hip_archive.a -hip-openmp-compatible
509 // RUN: llvm-ar t %T/hip-openmp_906.a | FileCheck -check-prefix=OPENMPHIPCOMPAT %s
510 // OPENMPHIPCOMPAT: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx906
512 // Some code so that we can create a binary out of this file.
514 void test_func(void) {