[clang] 92a606f - [HIP] Pass -Xoffload-linker option to device linker

Yaxun Liu via cfe-commits cfe-commits at lists.llvm.org
Tue May 31 19:38:50 PDT 2022


Author: Yaxun (Sam) Liu
Date: 2022-05-31T22:17:40-04:00
New Revision: 92a606f6de77f69f9eb86498deaeeeb8f821f4e1

URL: https://github.com/llvm/llvm-project/commit/92a606f6de77f69f9eb86498deaeeeb8f821f4e1
DIFF: https://github.com/llvm/llvm-project/commit/92a606f6de77f69f9eb86498deaeeeb8f821f4e1.diff

LOG: [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

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/HIPAMD.cpp
    clang/test/Driver/hip-options.hip

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp b/clang/lib/Driver/ToolChains/HIPAMD.cpp
index f672d2a108cc..bce3e729f7ee 100644
--- a/clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -147,6 +147,9 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA,
 
   addLinkerCompressDebugSectionsOption(TC, Args, LldArgs);
 
+  for (auto *Arg : Args.filtered(options::OPT_Xoffload_linker))
+    LldArgs.push_back(Arg->getValue(1));
+
   LldArgs.append({"-o", Output.getFilename()});
   for (auto Input : Inputs)
     LldArgs.push_back(Input.getFilename());

diff  --git a/clang/test/Driver/hip-options.hip b/clang/test/Driver/hip-options.hip
index c995fa68dacc..c4f436669b0b 100644
--- a/clang/test/Driver/hip-options.hip
+++ b/clang/test/Driver/hip-options.hip
@@ -106,3 +106,13 @@
 // RUN:   --offload-arch=gfx906 -fopenmp -fopenmp-targets=amdgcn %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=OMPTGT %s
 // OMPTGT: unsupported option '-fopenmp-targets=' for language mode 'HIP'
+
+// Check -Xoffload-linker option is passed to lld.
+
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --cuda-gpu-arch=gfx906 -fgpu-rdc -Xoffload-linker --build-id=md5 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=OFL-LINK %s
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --cuda-gpu-arch=gfx906 -Xoffload-linker --build-id=md5 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=OFL-LINK %s
+// OFL-LINK: lld{{.*}}"--build-id=md5"


        


More information about the cfe-commits mailing list