Clang Project

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