Skip to content

Commit 92a606f

Browse files
committed
[HIP] Pass -Xoffload-linker option to device linker
Reuse -Xoffload-linker option for HIP toolchain. Reviewed by: Artem Belevich Differential Revision: https://reviews.llvm.org/D126704
1 parent 377806a commit 92a606f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

clang/lib/Driver/ToolChains/HIPAMD.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA,
147147

148148
addLinkerCompressDebugSectionsOption(TC, Args, LldArgs);
149149

150+
for (auto *Arg : Args.filtered(options::OPT_Xoffload_linker))
151+
LldArgs.push_back(Arg->getValue(1));
152+
150153
LldArgs.append({"-o", Output.getFilename()});
151154
for (auto Input : Inputs)
152155
LldArgs.push_back(Input.getFilename());

clang/test/Driver/hip-options.hip

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,13 @@
106106
// RUN: --offload-arch=gfx906 -fopenmp -fopenmp-targets=amdgcn %s 2>&1 \
107107
// RUN: | FileCheck -check-prefix=OMPTGT %s
108108
// OMPTGT: unsupported option '-fopenmp-targets=' for language mode 'HIP'
109+
110+
// Check -Xoffload-linker option is passed to lld.
111+
112+
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
113+
// RUN: --cuda-gpu-arch=gfx906 -fgpu-rdc -Xoffload-linker --build-id=md5 %s 2>&1 \
114+
// RUN: | FileCheck -check-prefix=OFL-LINK %s
115+
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
116+
// RUN: --cuda-gpu-arch=gfx906 -Xoffload-linker --build-id=md5 %s 2>&1 \
117+
// RUN: | FileCheck -check-prefix=OFL-LINK %s
118+
// OFL-LINK: lld{{.*}}"--build-id=md5"

0 commit comments

Comments
 (0)