Debian Codegraph @

clang/test/Driver/linker-wrapper.c

raw
1 // UNSUPPORTED: system-windows
2 // REQUIRES: x86-registered-target
3 // REQUIRES: nvptx-registered-target
4 // REQUIRES: amdgpu-registered-target
5 // REQUIRES: spirv-registered-target
6
7 // An externally visible variable so static libraries extract.
8 __attribute__((visibility("protected"), used)) int x;
9
10 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.elf.o
11 // RUN: %clang -cc1 %s -triple nvptx64-nvidia-cuda -emit-llvm-bc -o %t.nvptx.bc
12 // RUN: %clang -cc1 %s -triple amdgcn-amd-amdhsa -emit-llvm-bc -o %t.amdgpu.bc
13 // RUN: %clang -cc1 %s -triple spirv64-unknown-unknown -emit-llvm-bc -o %t.spirv.bc
14
15 // RUN: llvm-offload-binary -o %t.out \
16 // RUN: --image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
17 // RUN: --image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
18 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t.out
19 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
20 // RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=NVPTX-LINK
21 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o %t.o -fembed-offload-object=%t.out
22 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
23 // RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=NVPTX-LINK
24
25 // NVPTX-LINK: clang{{.*}} -o {{.*}}.img -dumpdir a.out.nvptx64.sm_70.img. --target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.o {{.*}}.o
26
27 // RUN: llvm-offload-binary -o %t.out \
28 // RUN: --image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
29 // RUN: --image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
30 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t.out
31 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run --device-compiler=-g \
32 // RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=NVPTX-LINK-DEBUG
33
34 // NVPTX-LINK-DEBUG: clang{{.*}} --target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}-g
35
36 // RUN: llvm-offload-binary -o %t.out \
37 // RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
38 // RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
39 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t.out
40 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
41 // RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=AMDGPU-LINK
42
43 // AMDGPU-LINK: clang{{.*}} -o {{.*}}.img -dumpdir a.out.amdgcn.gfx908.img. --target=amdgcn-amd-amdhsa -mcpu=gfx908 -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
44
45 // RUN: llvm-offload-binary -o %t.out \
46 // RUN: --image=file=%t.amdgpu.bc,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx1030 \
47 // RUN: --image=file=%t.amdgpu.bc,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx1030
48 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t.out
49 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run --device-compiler=--save-temps \
50 // RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=AMDGPU-LTO-TEMPS
51
52 // AMDGPU-LTO-TEMPS: clang{{.*}} --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -flto {{.*}}-save-temps
53
54 // RUN: llvm-offload-binary -o %t.out \
55 // RUN: --image=file=%t.spirv.bc,kind=sycl,triple=spirv64-unknown-unknown,arch=generic
56 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t.out
57 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
58 // RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=SPIRV-LINK
59
60 // SPIRV-LINK: clang{{.*}} -o {{.*}}.img -dumpdir a.out.spirv64..img. --target=spirv64-unknown-unknown {{.*}}.o --sycl-link -Xlinker -triple=spirv64-unknown-unknown -Xlinker -arch=
61
62 // RUN: llvm-offload-binary -o %t.out \
63 // RUN: --image=file=%t.elf.o,kind=openmp,triple=x86_64-unknown-linux-gnu \
64 // RUN: --image=file=%t.elf.o,kind=openmp,triple=x86_64-unknown-linux-gnu
65 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t.out
66 // RUN: llvm-ar rcs %t.a %t.o
67 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
68 // RUN: --linker-path=/usr/bin/ld.lld --whole-archive %t.a --no-whole-archive \
69 // RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CPU-LINK
70
71 // CPU-LINK: clang{{.*}} -o {{.*}}.img -dumpdir a.out.x86_64..img. --target=x86_64-unknown-linux-gnu -Wl,--no-undefined {{.*}}.o {{.*}}.o -Wl,-Bsymbolic -shared -Wl,--whole-archive {{.*}}.a -Wl,--no-whole-archive
72
73 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o
74 // RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu -mllvm -openmp-opt-disable \
75 // RUN: --linker-path=/usr/bin/ld.lld -a -b -c %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=HOST-LINK
76
77 // HOST-LINK: ld.lld{{.*}}-a -b -c {{.*}}.o -o a.out
78 // HOST-LINK-NOT: ld.lld{{.*}}-abc
79
80 // RUN: llvm-offload-binary -o %t-lib.out \
81 // RUN: --image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
82 // RUN: --image=file=%t.elf.o,kind=cuda,triple=nvptx64-nvidia-cuda,arch=sm_52
83 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t-lib.out
84 // RUN: llvm-ar rcs %t.a %t.o
85 // RUN: llvm-offload-binary -o %t.out \
86 // RUN: --image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
87 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t-obj.o -fembed-offload-object=%t.out
88 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
89 // RUN: --linker-path=/usr/bin/ld %t.a %t-obj.o -o a.out 2>&1 | FileCheck %s --check-prefix=STATIC-LIBRARY
90
91 // STATIC-LIBRARY: clang{{.*}} -march=sm_70
92 // STATIC-LIBRARY-NOT: clang{{.*}} -march=sm_50
93
94 // RUN: llvm-offload-binary -o %t.out \
95 // RUN: --image=file=%t.elf.o,kind=cuda,triple=nvptx64-nvidia-cuda,arch=sm_70 \
96 // RUN: --image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
97 // RUN: --image=file=%t.elf.o,kind=cuda,triple=nvptx64-nvidia-cuda,arch=sm_52
98 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
99 // RUN: -fembed-offload-object=%t.out
100 // RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu \
101 // RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CUDA
102
103 // CUDA: clang{{.*}} -o [[IMG_SM70:.+]] -dumpdir a.out.nvptx64.sm_70.img. --target=nvptx64-nvidia-cuda -march=sm_70
104 // CUDA: clang{{.*}} -o [[IMG_SM52:.+]] -dumpdir a.out.nvptx64.sm_52.img. --target=nvptx64-nvidia-cuda -march=sm_52
105 // CUDA: fatbinary{{.*}}-64 --create {{.*}}.fatbin --image3=kind=elf,sm=70,file=[[IMG_SM70]] --image3=kind=elf,sm=52,file=[[IMG_SM52]]
106 // CUDA: usr/bin/ld{{.*}} {{.*}}.openmp.image.{{.*}}.o {{.*}}.cuda.image.{{.*}}.o
107
108 // RUN: llvm-offload-binary -o %t.out \
109 // RUN: --image=file=%t.elf.o,kind=cuda,triple=nvptx64-nvidia-cuda,arch=sm_80 \
110 // RUN: --image=file=%t.elf.o,kind=cuda,triple=nvptx64-nvidia-cuda,arch=sm_75 \
111 // RUN: --image=file=%t.elf.o,kind=cuda,triple=nvptx64-nvidia-cuda,arch=sm_70 \
112 // RUN: --image=file=%t.elf.o,kind=cuda,triple=nvptx64-nvidia-cuda,arch=sm_52
113 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
114 // RUN: -fembed-offload-object=%t.out
115 // RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu --wrapper-jobs=4 \
116 // RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CUDA-PAR
117 // RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu --wrapper-jobs=jobserver \
118 // RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CUDA-PAR
119
120 // CUDA-PAR: fatbinary{{.*}}-64 --create {{.*}}.fatbin
121
122 // RUN: llvm-offload-binary -o %t.out \
123 // RUN: --image=file=%t.elf.o,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx90a \
124 // RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a \
125 // RUN: --image=file=%t.elf.o,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx908
126 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
127 // RUN: -fembed-offload-object=%t.out
128 // RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu \
129 // RUN: --compress --compression-level=6 \
130 // RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=HIP
131
132 // HIP: clang{{.*}} -o [[IMG_GFX90A:.+]] -dumpdir a.out.amdgcn.gfx90a.img. --target=amdgcn-amd-amdhsa -mcpu=gfx90a
133 // HIP: clang{{.*}} -o [[IMG_GFX908:.+]] -dumpdir a.out.amdgcn.gfx908.img. --target=amdgcn-amd-amdhsa -mcpu=gfx908
134 // HIP: clang-offload-bundler{{.*}}-type=o -bundle-align=4096 -compress -compression-level=6 -targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa--gfx90a,hip-amdgcn-amd-amdhsa--gfx908 -input={{/dev/null|NUL}} -input=[[IMG_GFX90A]] -input=[[IMG_GFX908]] -output={{.*}}.hipfb
135
136 // RUN: llvm-offload-binary -o %t.out \
137 // RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
138 // RUN: --image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
139 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
140 // RUN: -fembed-offload-object=%t.out
141 // RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu \
142 // RUN: --linker-path=/usr/bin/ld --device-linker=foo=bar --device-linker=a \
143 // RUN: --device-linker=nvptx64-nvidia-cuda=b --device-compiler=foo\
144 // RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=LINKER-ARGS
145
146 // LINKER-ARGS: clang{{.*}}--target=amdgcn-amd-amdhsa{{.*}}-Xlinker foo=bar{{.*}}-Xlinker a{{.*}}foo
147 // LINKER-ARGS: clang{{.*}}--target=nvptx64-nvidia-cuda{{.*}}-Xlinker foo=bar{{.*}}-Xlinker a -Xlinker b{{.*}}foo
148
149 // RUN: not clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu \
150 // RUN: -ldummy --linker-path=/usr/bin/ld \
151 // RUN: -o a.out 2>&1 | FileCheck %s --check-prefix=MISSING-LIBRARY
152
153 // MISSING-LIBRARY: error: unable to find library -ldummy
154
155 // RUN: llvm-offload-binary -o %t.out \
156 // RUN: --image=file=%t.amdgpu.bc,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
157 // RUN: --image=file=%t.amdgpu.bc,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
158 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t.out
159 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run --clang-backend \
160 // RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CLANG-BACKEND
161
162 // CLANG-BACKEND: clang{{.*}} -o {{.*}}.img -dumpdir a.out.amdgcn.gfx908.img. --target=amdgcn-amd-amdhsa -mcpu=gfx908 -flto -Wl,--no-undefined {{.*}}.o
163
164 // RUN: llvm-offload-binary -o %t.out \
165 // RUN: --image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
166 // RUN: %clang -cc1 %s -triple x86_64-unknown-windows-msvc -emit-obj -o %t.o -fembed-offload-object=%t.out
167 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-windows-msvc --dry-run \
168 // RUN: --linker-path=/usr/bin/lld-link %t.o -libpath:./ -out:a.exe 2>&1 | FileCheck %s --check-prefix=COFF
169
170 // COFF: "/usr/bin/lld-link" {{.*}}.o -libpath:./ -out:a.exe {{.*}}openmp.image.wrapper{{.*}}
171
172 // RUN: llvm-offload-binary -o %t-lib.out \
173 // RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a
174 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t-lib.out
175 // RUN: llvm-ar rcs %t.a %t.o
176 // RUN: llvm-offload-binary -o %t-on.out \
177 // RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a:xnack+
178 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t-on.o -fembed-offload-object=%t-on.out
179 // RUN: llvm-offload-binary -o %t-off.out \
180 // RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a:xnack-
181 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t-off.o -fembed-offload-object=%t-off.out
182 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
183 // RUN: --linker-path=/usr/bin/ld %t-on.o %t-off.o %t.a -o a.out 2>&1 | FileCheck %s --check-prefix=AMD-TARGET-ID
184
185 // AMD-TARGET-ID: clang{{.*}} -o {{.*}}.img -dumpdir a.out.amdgcn.gfx90a:xnack+.img. --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack+ -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
186 // AMD-TARGET-ID: clang{{.*}} -o {{.*}}.img -dumpdir a.out.amdgcn.gfx90a:xnack-.img. --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack- -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
187
188 // RUN: llvm-offload-binary -o %t-lib.out \
189 // RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=generic
190 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t-lib.out
191 // RUN: llvm-ar rcs %t.a %t.o
192 // RUN: llvm-offload-binary -o %t1.out \
193 // RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a
194 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t1.o -fembed-offload-object=%t1.out
195 // RUN: llvm-offload-binary -o %t2.out \
196 // RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
197 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t2.o -fembed-offload-object=%t2.out
198 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
199 // RUN: --linker-path=/usr/bin/ld %t1.o %t2.o %t.a -o a.out 2>&1 | FileCheck %s --check-prefix=ARCH-ALL
200
201 // ARCH-ALL: clang{{.*}} -o {{.*}}.img -dumpdir a.out.amdgcn.gfx90a.img. --target=amdgcn-amd-amdhsa -mcpu=gfx90a -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
202 // ARCH-ALL: clang{{.*}} -o {{.*}}.img -dumpdir a.out.amdgcn.gfx908.img. --target=amdgcn-amd-amdhsa -mcpu=gfx908 -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
203
204 // RUN: llvm-offload-binary -o %t.out \
205 // RUN: --image=file=%t.elf.o,kind=openmp,triple=x86_64-unknown-linux-gnu \
206 // RUN: --image=file=%t.elf.o,kind=openmp,triple=x86_64-unknown-linux-gnu
207 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t.out
208 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
209 // RUN: --linker-path=/usr/bin/ld.lld -r %t.o \
210 // RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=RELOCATABLE-LINK
211
212 // RELOCATABLE-LINK: clang{{.*}} -o {{.*}}.img -dumpdir a.out.x86_64..img. --target=x86_64-unknown-linux-gnu
213 // RELOCATABLE-LINK: /usr/bin/ld.lld{{.*}}-r
214 // RELOCATABLE-LINK: llvm-objcopy{{.*}}a.out --remove-section .llvm.offloading
215
216 // RUN: llvm-offload-binary -o %t.out \
217 // RUN: --image=file=%t.elf.o,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx90a \
218 // RUN: --image=file=%t.elf.o,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx90a
219 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t.out
220 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
221 // RUN: --linker-path=/usr/bin/ld.lld -r %t.o \
222 // RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=RELOCATABLE-LINK-HIP
223
224 // RELOCATABLE-LINK-HIP: clang{{.*}} -o {{.*}}.img -dumpdir a.out.amdgcn.gfx90a.img. --target=amdgcn-amd-amdhsa
225 // RELOCATABLE-LINK-HIP: clang-offload-bundler{{.*}} -type=o -bundle-align=4096 -targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa--gfx90a -input={{/dev/null|NUL}} -input={{.*}} -output={{.*}}
226 // RELOCATABLE-LINK-HIP: /usr/bin/ld.lld{{.*}}-r
227 // RELOCATABLE-LINK-HIP: llvm-objcopy{{.*}}a.out --remove-section .llvm.offloading
228 // RELOCATABLE-LINK-HIP: --rename-section llvm_offload_entries
229
230 // RUN: llvm-offload-binary -o %t.out \
231 // RUN: --image=file=%t.elf.o,kind=cuda,triple=nvptx64-nvidia-cuda,arch=sm_89 \
232 // RUN: --image=file=%t.elf.o,kind=cuda,triple=nvptx64-nvidia-cuda,arch=sm_89
233 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t.out
234 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
235 // RUN: --linker-path=/usr/bin/ld.lld -r %t.o \
236 // RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=RELOCATABLE-LINK-CUDA
237
238 // RELOCATABLE-LINK-CUDA: clang{{.*}} -o {{.*}}.img -dumpdir a.out.nvptx64.sm_89.img. --target=nvptx64-nvidia-cuda
239 // RELOCATABLE-LINK-CUDA: fatbinary{{.*}} -64 --create {{.*}}.fatbin --image3=kind=elf,sm=89,file={{.*}}.img
240 // RELOCATABLE-LINK-CUDA: /usr/bin/ld.lld{{.*}}-r
241 // RELOCATABLE-LINK-CUDA: llvm-objcopy{{.*}}a.out --remove-section .llvm.offloading
242
243 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o
244 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
245 // RUN: --linker-path=/usr/bin/ld --override=image=openmp=%t.o %t.o -o a.out 2>&1 \
246 // RUN: | FileCheck %s --check-prefix=OVERRIDE
247 // OVERRIDE-NOT: clang
248 // OVERRIDE: /usr/bin/ld
249
250 // RUN: llvm-offload-binary -o %t.out \
251 // RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
252 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t.out
253 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
254 // RUN: --offload-opt=-pass-remarks=foo,bar --linker-path=/usr/bin/ld \
255 // RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=OFFLOAD-OPT
256 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
257 // RUN: -mllvm -pass-remarks=foo,bar --linker-path=/usr/bin/ld \
258 // RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=MLLVM
259
260 // MLLVM: clang{{.*}}-Xlinker --plugin-opt=-pass-remarks=foo,bar
261 // OFFLOAD-OPT: clang{{.*}}-Xlinker --plugin-opt=-pass-remarks=foo,bar
262 // MLLVM-SAME: -Xlinker -mllvm=-pass-remarks=foo,bar
263 // OFFLOAD-OPT-NOT: -Xlinker -mllvm=-pass-remarks=foo,bar
264 // OFFLOAD-OPT-SAME: {{$}}
265
266 // Error handling when --linker-path is not provided for clang-linker-wrapper
267 // RUN: not clang-linker-wrapper 2>&1 | FileCheck --check-prefix=LINKER-PATH-NOT-PROVIDED %s
268 // LINKER-PATH-NOT-PROVIDED: linker path missing, must pass 'linker-path'