Skip to content

Commit 651bf3e

Browse files
committed
[clang-linker-wrapper] Forward offload options to device linker
1 parent 17481aa commit 651bf3e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

clang/test/Driver/linker-wrapper.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ __attribute__((visibility("protected"), used)) int x;
5050
// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --wrapper-verbose --dry-run --save-temps -O2 \
5151
// RUN: --lto-in-process --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=AMDGPU-LTO-IN-PROC
5252
// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --wrapper-verbose --dry-run --save-temps -O2 \
53-
// RUN: --lto-debug-pass-manager --lto-print-pipeline-passes --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=AMDGPU-LTO-OPTS
53+
// RUN: --lto-debug-pass-manager --lto-print-pipeline-passes \
54+
// RUN: -offload-opt=--print-before=openmp-opt -offload-opt=--print-after=openmp-opt \
55+
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=AMDGPU-LTO-OPTS
5456

5557
// AMDGPU-LTO-TEMPS-NOT: Linking bitcode files
5658
// AMDGPU-LTO-TEMPS: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -O2 -Wl,--no-undefined {{.*}}.o -save-temps
@@ -61,6 +63,8 @@ __attribute__((visibility("protected"), used)) int x;
6163
// AMDGPU-LTO-OPTS: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -O2 -Wl,--no-undefined {{.*}}.o -save-temps -Wl,--save-temps
6264
// AMDGPU-LTO-OPTS-SAME: -Wl,--lto-debug-pass-manager
6365
// AMDGPU-LTO-OPTS-SAME: -Wl,--lto-print-pipeline-passes
66+
// AMDGPU-LTO-OPTS-SAME: -Wl,--mllvm=-print-before=openmp-opt
67+
// AMDGPU-LTO-OPTS-SAME: -Wl,--mllvm=-print-after=openmp-opt
6468

6569
// RUN: clang-offload-packager -o %t.out \
6670
// RUN: --image=file=%t.elf.o,kind=openmp,triple=x86_64-unknown-linux-gnu \

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,10 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, const ArgList &Args) {
580580
CmdArgs.push_back("-Wl,--lto-debug-pass-manager");
581581
if (Args.hasArg(OPT_lto_print_pipeline_passes))
582582
CmdArgs.push_back("-Wl,--lto-print-pipeline-passes");
583+
for (const opt::Arg *Arg : Args.filtered(OPT_offload_opt_eq_minus)) {
584+
CmdArgs.push_back(
585+
Args.MakeArgString("-Wl,--mllvm=" + StringRef(Arg->getValue())));
586+
}
583587
}
584588

585589
if (Args.hasArg(OPT_embed_bitcode))

0 commit comments

Comments
 (0)