[clang] e7175b0 - [HIP] do not link runtime for -r (#85675)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 19 20:04:01 PDT 2024
Author: Yaxun (Sam) Liu
Date: 2024-03-19T23:03:57-04:00
New Revision: e7175b07047d1ba7b012f811064091f12ebf8a40
URL: https://github.com/llvm/llvm-project/commit/e7175b07047d1ba7b012f811064091f12ebf8a40
DIFF: https://github.com/llvm/llvm-project/commit/e7175b07047d1ba7b012f811064091f12ebf8a40.diff
LOG: [HIP] do not link runtime for -r (#85675)
since it will cause duplicate symbols when the partially linked object
is linked again.
Added:
Modified:
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/hip-partial-link.hip
clang/test/Driver/hip-runtime-libs-linux.hip
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 83015b0cb81a6e..4478865313636d 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2830,7 +2830,7 @@ void tools::addHIPRuntimeLibArgs(const ToolChain &TC, Compilation &C,
llvm::opt::ArgStringList &CmdArgs) {
if ((C.getActiveOffloadKinds() & Action::OFK_HIP) &&
!Args.hasArg(options::OPT_nostdlib) &&
- !Args.hasArg(options::OPT_no_hip_rt)) {
+ !Args.hasArg(options::OPT_no_hip_rt) && !Args.hasArg(options::OPT_r)) {
TC.AddHIPRuntimeLibArgs(Args, CmdArgs);
} else {
// Claim "no HIP libraries" arguments if any
diff --git a/clang/test/Driver/hip-partial-link.hip b/clang/test/Driver/hip-partial-link.hip
index faa185972abc33..c8451ec81ed37e 100644
--- a/clang/test/Driver/hip-partial-link.hip
+++ b/clang/test/Driver/hip-partial-link.hip
@@ -47,7 +47,7 @@
// OBJ: D __hip_gpubin_handle_[[ID2]]
// RUN: %clang -v --target=x86_64-unknown-linux-gnu --no-offload-new-driver \
-// RUN: --hip-link -no-hip-rt -fgpu-rdc --offload-arch=gfx906 \
+// RUN: --hip-link -fgpu-rdc --offload-arch=gfx906 \
// RUN: -fuse-ld=lld -nostdlib -r %t.main.o %t.lib.o -o %t.final.o \
// RUN: 2>&1 | FileCheck -check-prefix=LINK-O %s
// LINK-O-NOT: Found undefined HIP {{.*}}symbol
diff --git a/clang/test/Driver/hip-runtime-libs-linux.hip b/clang/test/Driver/hip-runtime-libs-linux.hip
index 142582963c958f..a4cd2733114b69 100644
--- a/clang/test/Driver/hip-runtime-libs-linux.hip
+++ b/clang/test/Driver/hip-runtime-libs-linux.hip
@@ -43,6 +43,11 @@
// RUN: --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
// RUN: | FileCheck -check-prefixes=NOHIPRT %s
+// Test HIP runtime lib is not linked with -r.
+// RUN: %clang -### --hip-link -r --target=x86_64-linux-gnu \
+// RUN: --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
+// RUN: | FileCheck -check-prefixes=NOHIPRT %s
+
// Test HIP runtime lib is linked without hip-link if there is HIP input file.
// RUN: %clang -### --target=x86_64-linux-gnu -nogpuinc -nogpulib \
// RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \
More information about the cfe-commits
mailing list