• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // REQUIRES: x86-registered-target
2 // REQUIRES: powerpc-registered-target
3 // UNSUPPORTED: darwin
4 
5 //
6 // Generate all the types of files we can bundle.
7 //
8 // RUN: %clang -O0 -target %itanium_abi_triple %s -E -o %t.i
9 // RUN: %clangxx -O0 -target %itanium_abi_triple -x c++ %s -E -o %t.ii
10 // RUN: %clang -O0 -target %itanium_abi_triple %s -S -emit-llvm -o %t.ll
11 // RUN: %clang -O0 -target %itanium_abi_triple %s -c -emit-llvm -o %t.bc
12 // RUN: %clang -O0 -target %itanium_abi_triple %s -S -o %t.s
13 // RUN: %clang -O0 -target %itanium_abi_triple %s -c -o %t.o
14 // RUN: %clang -O0 -target %itanium_abi_triple %s -emit-ast -o %t.ast
15 
16 //
17 // Generate an empty file to help with the checks of empty files.
18 //
19 // RUN: touch %t.empty
20 
21 //
22 // Generate a couple of files to bundle with.
23 //
24 // RUN: echo 'Content of device file 1' > %t.tgt1
25 // RUN: echo 'Content of device file 2' > %t.tgt2
26 
27 //
28 // Check help message.
29 //
30 // RUN: clang-offload-bundler --help | FileCheck %s --check-prefix CK-HELP
31 // CK-HELP: {{.*}}OVERVIEW: A tool to bundle several input files of the specified type <type>
32 // CK-HELP: {{.*}}referring to the same source file but different targets into a single
33 // CK-HELP: {{.*}}one. The resulting file can also be unbundled into different files by
34 // CK-HELP: {{.*}}this tool if -unbundle is provided.
35 // CK-HELP: {{.*}}USAGE: clang-offload-bundler [options]
36 // CK-HELP: {{.*}}-inputs=<string>  - [<input file>,...]
37 // CK-HELP: {{.*}}-outputs=<string> - [<output file>,...]
38 // CK-HELP: {{.*}}-targets=<string> - [<offload kind>-<target triple>,...]
39 // CK-HELP: {{.*}}-type=<string>    - Type of the files to be bundled/unbundled.
40 // CK-HELP: {{.*}}Current supported types are:
41 // CK-HELP: {{.*}}i {{.*}}- cpp-output
42 // CK-HELP: {{.*}}ii {{.*}}- c++-cpp-output
43 // CK-HELP: {{.*}}ll {{.*}}- llvm
44 // CK-HELP: {{.*}}bc {{.*}}- llvm-bc
45 // CK-HELP: {{.*}}s {{.*}}- assembler
46 // CK-HELP: {{.*}}o {{.*}}- object
47 // CK-HELP: {{.*}}gch {{.*}}- precompiled-header
48 // CK-HELP: {{.*}}ast {{.*}}- clang AST file
49 // CK-HELP: {{.*}}-unbundle {{.*}}- Unbundle bundled file into several output files.
50 
51 //
52 // Check errors.
53 //
54 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle.i -unbundle 2>&1 | FileCheck %s --check-prefix CK-ERR1
55 // CK-ERR1: error: only one input file supported in unbundling mode
56 // CK-ERR1: error: number of output files and targets should match in unbundling mode
57 
58 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu -inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR2
59 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.i,%t.tgt1 -outputs=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR2
60 // CK-ERR2: error: number of input files and targets should match in bundling mode
61 
62 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.i,%t.tgt1,%t.tgt2 -inputs=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR3
63 // CK-ERR3: error: only one output file supported in bundling mode
64 // CK-ERR3: error: number of input files and targets should match in bundling mode
65 
66 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu -outputs=%t.i,%t.tgt1,%t.tgt2 -inputs=%t.bundle.i -unbundle 2>&1 | FileCheck %s --check-prefix CK-ERR4
67 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.i,%t.tgt1 -inputs=%t.bundle.i -unbundle 2>&1 | FileCheck %s --check-prefix CK-ERR4
68 // CK-ERR4: error: number of output files and targets should match in unbundling mode
69 
70 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.i,%t.tgt1,%t.tgt2.notexist -outputs=%t.bundle.i 2>&1 | FileCheck %s -DFILE=%t.tgt2.notexist --check-prefix CK-ERR5
71 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.i,%t.tgt1,%t.tgt2 -inputs=%t.bundle.i.notexist -unbundle 2>&1 | FileCheck %s -DFILE=%t.bundle.i.notexist --check-prefix CK-ERR5
72 // CK-ERR5: error: '[[FILE]]': {{N|n}}o such file or directory
73 
74 // RUN: not clang-offload-bundler -type=invalid -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle.i 2>&1 | FileCheck %s -DTYPE=invalid --check-prefix CK-ERR6
75 // CK-ERR6: error: '[[TYPE]]': invalid file type specified
76 
77 // RUN: not clang-offload-bundler 2>&1 | FileCheck %s --check-prefix CK-ERR7
78 // CK-ERR7-DAG: clang-offload-bundler: for the --type option: must be specified at least once!
79 // CK-ERR7-DAG: clang-offload-bundler: for the --inputs option: must be specified at least once!
80 // CK-ERR7-DAG: clang-offload-bundler: for the --outputs option: must be specified at least once!
81 // CK-ERR7-DAG: clang-offload-bundler: for the --targets option: must be specified at least once!
82 
83 // RUN: not clang-offload-bundler -type=i -targets=hxst-powerpcxxle-ibm-linux-gnu,openxp-pxxerpc64le-ibm-linux-gnu,xpenmp-x86_xx-pc-linux-gnu -inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR8
84 // CK-ERR8: error: invalid target 'hxst-powerpcxxle-ibm-linux-gnu', unknown offloading kind 'hxst', unknown target triple 'powerpcxxle-ibm-linux-gnu'
85 // CK-ERR8: error: invalid target 'openxp-pxxerpc64le-ibm-linux-gnu', unknown offloading kind 'openxp', unknown target triple 'pxxerpc64le-ibm-linux-gnu'
86 // CK-ERR8: error: invalid target 'xpenmp-x86_xx-pc-linux-gnu', unknown offloading kind 'xpenmp', unknown target triple 'x86_xx-pc-linux-gnu'
87 
88 // RUN: not clang-offload-bundler -type=i -targets=openmp-powerpc64le-linux,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR9A
89 // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR9B
90 // CK-ERR9A: error: expecting exactly one host target but got 0
91 // CK-ERR9B: error: expecting exactly one host target but got 2
92 
93 //
94 // Check text bundle. This is a readable format, so we check for the format we expect to find.
95 //
96 // RUN: clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.i
97 // RUN: clang-offload-bundler -type=ii -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.ii,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.ii
98 // RUN: clang-offload-bundler -type=ll -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.ll,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.ll
99 // RUN: clang-offload-bundler -type=s -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.s,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.s
100 // RUN: clang-offload-bundler -type=s -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -inputs=%t.tgt1,%t.s,%t.tgt2 -outputs=%t.bundle3.unordered.s
101 // RUN: FileCheck %s --input-file %t.bundle3.i --check-prefix CK-TEXTI
102 // RUN: FileCheck %s --input-file %t.bundle3.ii --check-prefix CK-TEXTI
103 // RUN: FileCheck %s --input-file %t.bundle3.ll --check-prefix CK-TEXTLL
104 // RUN: FileCheck %s --input-file %t.bundle3.s --check-prefix CK-TEXTS
105 // RUN: FileCheck %s --input-file %t.bundle3.unordered.s --check-prefix CK-TEXTS-UNORDERED
106 
107 // CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____START__ host-[[HOST:.+]]
108 // CK-TEXTI: int A = 0;
109 // CK-TEXTI: test_func(void)
110 // CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____END__ host-[[HOST]]
111 // CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____START__ openmp-powerpc64le-ibm-linux-gnu
112 // CK-TEXTI: Content of device file 1
113 // CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____END__ openmp-powerpc64le-ibm-linux-gnu
114 // CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____START__ openmp-x86_64-pc-linux-gnu
115 // CK-TEXTI: Content of device file 2
116 // CK-TEXTI: // __CLANG_OFFLOAD_BUNDLE____END__ openmp-x86_64-pc-linux-gnu
117 
118 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____START__ host-[[HOST:.+]]
119 // CK-TEXTLL: @A = {{.*}}global i32 0
120 // CK-TEXTLL: define {{.*}}@test_func()
121 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____END__ host-[[HOST]]
122 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____START__ openmp-powerpc64le-ibm-linux-gnu
123 // CK-TEXTLL: Content of device file 1
124 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____END__ openmp-powerpc64le-ibm-linux-gnu
125 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____START__ openmp-x86_64-pc-linux-gnu
126 // CK-TEXTLL: Content of device file 2
127 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLE____END__ openmp-x86_64-pc-linux-gnu
128 
129 // CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____START__ host-[[HOST:.+]]
130 // CK-TEXTS: .globl {{.*}}test_func
131 // CK-TEXTS: .globl {{.*}}A
132 // CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____END__ host-[[HOST]]
133 // CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____START__ openmp-powerpc64le-ibm-linux-gnu
134 // CK-TEXTS: Content of device file 1
135 // CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____END__ openmp-powerpc64le-ibm-linux-gnu
136 // CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____START__ openmp-x86_64-pc-linux-gnu
137 // CK-TEXTS: Content of device file 2
138 // CK-TEXTS: # __CLANG_OFFLOAD_BUNDLE____END__ openmp-x86_64-pc-linux-gnu
139 
140 // CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____START__ openmp-powerpc64le-ibm-linux-gnu
141 // CK-TEXTS-UNORDERED: Content of device file 1
142 // CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____END__ openmp-powerpc64le-ibm-linux-gnu
143 // CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____START__ host-[[HOST:.+]]
144 // CK-TEXTS-UNORDERED: .globl {{.*}}test_func
145 // CK-TEXTS-UNORDERED: .globl {{.*}}A
146 // CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____END__ host-[[HOST]]
147 // CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____START__ openmp-x86_64-pc-linux-gnu
148 // CK-TEXTS-UNORDERED: Content of device file 2
149 // CK-TEXTS-UNORDERED: # __CLANG_OFFLOAD_BUNDLE____END__ openmp-x86_64-pc-linux-gnu
150 
151 //
152 // Check text unbundle. Check if we get the exact same content that we bundled before for each file.
153 //
154 // RUN: clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.i,%t.res.tgt1,%t.res.tgt2 -inputs=%t.bundle3.i -unbundle
155 // RUN: diff %t.i %t.res.i
156 // RUN: diff %t.tgt1 %t.res.tgt1
157 // RUN: diff %t.tgt2 %t.res.tgt2
158 // RUN: clang-offload-bundler -type=i -targets=openmp-powerpc64le-ibm-linux-gnu -outputs=%t.res.tgt1 -inputs=%t.bundle3.i -unbundle
159 // RUN: diff %t.tgt1 %t.res.tgt1
160 // RUN: clang-offload-bundler -type=ii -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.ii,%t.res.tgt1,%t.res.tgt2 -inputs=%t.bundle3.ii -unbundle
161 // RUN: diff %t.ii %t.res.ii
162 // RUN: diff %t.tgt1 %t.res.tgt1
163 // RUN: diff %t.tgt2 %t.res.tgt2
164 // RUN: clang-offload-bundler -type=ii -targets=openmp-x86_64-pc-linux-gnu -outputs=%t.res.tgt2 -inputs=%t.bundle3.ii -unbundle
165 // RUN: diff %t.tgt2 %t.res.tgt2
166 // RUN: clang-offload-bundler -type=ll -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.ll,%t.res.tgt1,%t.res.tgt2 -inputs=%t.bundle3.ll -unbundle
167 // RUN: diff %t.ll %t.res.ll
168 // RUN: diff %t.tgt1 %t.res.tgt1
169 // RUN: diff %t.tgt2 %t.res.tgt2
170 // RUN: clang-offload-bundler -type=ll -targets=openmp-powerpc64le-ibm-linux-gnu -outputs=%t.res.tgt1 -inputs=%t.bundle3.ll -unbundle
171 // RUN: diff %t.tgt1 %t.res.tgt1
172 // RUN: clang-offload-bundler -type=s -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.s,%t.res.tgt1,%t.res.tgt2 -inputs=%t.bundle3.s -unbundle
173 // RUN: diff %t.s %t.res.s
174 // RUN: diff %t.tgt1 %t.res.tgt1
175 // RUN: diff %t.tgt2 %t.res.tgt2
176 // RUN: clang-offload-bundler -type=s -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.tgt1,%t.res.s,%t.res.tgt2 -inputs=%t.bundle3.s -unbundle
177 // RUN: diff %t.s %t.res.s
178 // RUN: diff %t.tgt1 %t.res.tgt1
179 // RUN: diff %t.tgt2 %t.res.tgt2
180 // RUN: clang-offload-bundler -type=s -targets=openmp-x86_64-pc-linux-gnu -outputs=%t.res.tgt2 -inputs=%t.bundle3.s -unbundle
181 // RUN: diff %t.tgt2 %t.res.tgt2
182 
183 // Check if we can unbundle a file with no magic strings.
184 // RUN: clang-offload-bundler -type=s -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.s,%t.res.tgt1,%t.res.tgt2 -inputs=%t.s -unbundle
185 // RUN: diff %t.s %t.res.s
186 // RUN: diff %t.empty %t.res.tgt1
187 // RUN: diff %t.empty %t.res.tgt2
188 // RUN: clang-offload-bundler -type=s -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.tgt1,%t.res.s,%t.res.tgt2 -inputs=%t.s -unbundle
189 // RUN: diff %t.s %t.res.s
190 // RUN: diff %t.empty %t.res.tgt1
191 // RUN: diff %t.empty %t.res.tgt2
192 
193 // Check that bindler prints an error if given host bundle does not exist in the fat binary.
194 // RUN: not clang-offload-bundler -type=s -targets=host-x86_64-xxx-linux-gnu,openmp-powerpc64le-ibm-linux-gnu -outputs=%t.res.s,%t.res.tgt1 -inputs=%t.bundle3.s -unbundle 2>&1 | FileCheck %s --check-prefix CK-NO-HOST-BUNDLE
195 // CK-NO-HOST-BUNDLE: error: Can't find bundle for the host target
196 
197 //
198 // Check binary bundle/unbundle. The content that we have before bundling must be the same we have after unbundling.
199 //
200 // RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.bc,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.bc
201 // RUN: clang-offload-bundler -type=gch -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.ast,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.gch
202 // RUN: clang-offload-bundler -type=ast -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.ast,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.ast
203 // RUN: clang-offload-bundler -type=ast -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -inputs=%t.tgt1,%t.ast,%t.tgt2 -outputs=%t.bundle3.unordered.ast
204 // RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.bc,%t.res.tgt1,%t.res.tgt2 -inputs=%t.bundle3.bc -unbundle
205 // RUN: diff %t.bc %t.res.bc
206 // RUN: diff %t.tgt1 %t.res.tgt1
207 // RUN: diff %t.tgt2 %t.res.tgt2
208 // RUN: clang-offload-bundler -type=bc -targets=openmp-powerpc64le-ibm-linux-gnu -outputs=%t.res.tgt1 -inputs=%t.bundle3.bc -unbundle
209 // RUN: diff %t.tgt1 %t.res.tgt1
210 // RUN: clang-offload-bundler -type=gch -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.gch,%t.res.tgt1,%t.res.tgt2 -inputs=%t.bundle3.gch -unbundle
211 // RUN: diff %t.ast %t.res.gch
212 // RUN: diff %t.tgt1 %t.res.tgt1
213 // RUN: diff %t.tgt2 %t.res.tgt2
214 // RUN: clang-offload-bundler -type=gch -targets=openmp-x86_64-pc-linux-gnu -outputs=%t.res.tgt2 -inputs=%t.bundle3.gch -unbundle
215 // RUN: diff %t.tgt2 %t.res.tgt2
216 // RUN: clang-offload-bundler -type=ast -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.ast,%t.res.tgt1,%t.res.tgt2 -inputs=%t.bundle3.ast -unbundle
217 // RUN: diff %t.ast %t.res.ast
218 // RUN: diff %t.tgt1 %t.res.tgt1
219 // RUN: diff %t.tgt2 %t.res.tgt2
220 // RUN: clang-offload-bundler -type=ast -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.tgt1,%t.res.ast,%t.res.tgt2 -inputs=%t.bundle3.ast -unbundle
221 // RUN: diff %t.ast %t.res.ast
222 // RUN: diff %t.tgt1 %t.res.tgt1
223 // RUN: diff %t.tgt2 %t.res.tgt2
224 // RUN: clang-offload-bundler -type=ast -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.tgt1,%t.res.ast,%t.res.tgt2 -inputs=%t.bundle3.unordered.ast -unbundle
225 // RUN: diff %t.ast %t.res.ast
226 // RUN: diff %t.tgt1 %t.res.tgt1
227 // RUN: diff %t.tgt2 %t.res.tgt2
228 // RUN: clang-offload-bundler -type=ast -targets=openmp-powerpc64le-ibm-linux-gnu -outputs=%t.res.tgt1 -inputs=%t.bundle3.ast -unbundle
229 // RUN: diff %t.tgt1 %t.res.tgt1
230 
231 // Check if we can unbundle a file with no magic strings.
232 // RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.bc,%t.res.tgt1,%t.res.tgt2 -inputs=%t.bc -unbundle
233 // RUN: diff %t.bc %t.res.bc
234 // RUN: diff %t.empty %t.res.tgt1
235 // RUN: diff %t.empty %t.res.tgt2
236 // RUN: clang-offload-bundler -type=bc -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.tgt1,%t.res.bc,%t.res.tgt2 -inputs=%t.bc -unbundle
237 // RUN: diff %t.bc %t.res.bc
238 // RUN: diff %t.empty %t.res.tgt1
239 // RUN: diff %t.empty %t.res.tgt2
240 
241 // Check that we do not have to unbundle all available bundles from the fat binary.
242 // RUN: clang-offload-bundler -type=ast -targets=host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.ast,%t.res.tgt2 -inputs=%t.bundle3.unordered.ast -unbundle
243 // RUN: diff %t.ast %t.res.ast
244 // RUN: diff %t.tgt2 %t.res.tgt2
245 
246 //
247 // Check object bundle/unbundle. The content should be bundled into an ELF
248 // section (we are using a PowerPC little-endian host which uses ELF). We
249 // have an already bundled file to check the unbundle and do a dry run on the
250 // bundling as it cannot be tested in all host platforms that will run these
251 // tests.
252 //
253 
254 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.o -### 2>&1 \
255 // 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
256 // CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "[[INOBJ1]]" "[[TEMPOBJ:.*]]"
257 // CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "[[TEMPOBJ]]" "[[OUTOBJ]]"
258 
259 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.o
260 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.o,%t.res.tgt1,%t.res.tgt2 -inputs=%t.bundle3.o -unbundle
261 // RUN: diff %t.bundle3.o %t.res.o
262 // RUN: diff %t.tgt1 %t.res.tgt1
263 // RUN: diff %t.tgt2 %t.res.tgt2
264 // RUN: clang-offload-bundler -type=o -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.tgt1,%t.res.o,%t.res.tgt2 -inputs=%t.bundle3.o -unbundle
265 // RUN: diff %t.bundle3.o %t.res.o
266 // RUN: diff %t.tgt1 %t.res.tgt1
267 // RUN: diff %t.tgt2 %t.res.tgt2
268 // RUN: clang-offload-bundler -type=o -targets=openmp-powerpc64le-ibm-linux-gnu -outputs=%t.res.tgt1 -inputs=%t.bundle3.o -unbundle
269 // RUN: diff %t.tgt1 %t.res.tgt1
270 
271 // Check if we can unbundle a file with no magic strings.
272 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.o,%t.res.tgt1,%t.res.tgt2 -inputs=%t.o -unbundle
273 // RUN: diff %t.o %t.res.o
274 // RUN: diff %t.empty %t.res.tgt1
275 // RUN: diff %t.empty %t.res.tgt2
276 // RUN: clang-offload-bundler -type=o -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.tgt1,%t.res.o,%t.res.tgt2 -inputs=%t.o -unbundle
277 // RUN: diff %t.o %t.res.o
278 // RUN: diff %t.empty %t.res.tgt1
279 // RUN: diff %t.empty %t.res.tgt2
280 
281 //
282 // Check -bundle-align option
283 //
284 
285 // 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 -inputs=%t.bc,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.bc
286 // RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.bc,%t.res.tgt1,%t.res.tgt2 -inputs=%t.bundle3.bc -unbundle
287 // RUN: diff %t.bc %t.res.bc
288 // RUN: diff %t.tgt1 %t.res.tgt1
289 // RUN: diff %t.tgt2 %t.res.tgt2
290 
291 // Some code so that we can create a binary out of this file.
292 int A = 0;
test_func(void)293 void test_func(void) {
294   ++A;
295 }
296