Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions clang/lib/Driver/ToolChains/Linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,11 @@ void Linux::AddHIPRuntimeLibArgs(const ArgList &Args,
Args.MakeArgString(StringRef("-L") + RocmInstallation->getLibPath()));

if (Args.hasFlag(options::OPT_frtlib_add_rpath,
options::OPT_fno_rtlib_add_rpath, false))
CmdArgs.append(
{"-rpath", Args.MakeArgString(RocmInstallation->getLibPath())});
options::OPT_fno_rtlib_add_rpath, false)) {
SmallString<0> p = RocmInstallation->getLibPath();
llvm::sys::path::remove_dots(p, true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so far the preferred style is like remove_dots(p, /*remove_dot_dot=*/ true);

CmdArgs.append({"-rpath", Args.MakeArgString(p)});
}

CmdArgs.push_back("-lamdhip64");
}
Expand Down
6 changes: 6 additions & 0 deletions clang/test/Driver/hip-runtime-libs-linux.hip
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
// RUN: --rocm-path=%S/Inputs/rocm %t.o -frtlib-add-rpath 2>&1 \
// RUN: | FileCheck -check-prefixes=ROCM-RPATH %s

// Test that a canonical HIP runtime path is passed to the -rpath flag
// RUN: %clang -### --hip-link --target=x86_64-linux-gnu \
// RUN: --rocm-path=%S/Inputs/rocm/./bin/../include/../ %t.o -frtlib-add-rpath 2>&1 \
// RUN: | FileCheck -check-prefixes=ROCM-RPATH-CANONICAL %s

// Test detecting latest /opt/rocm-{release} directory.
// RUN: rm -rf %t && mkdir -p %t/opt
// RUN: cp -r %S/Inputs/rocm %t/opt/rocm-3.9.0-1234
Expand Down Expand Up @@ -55,6 +60,7 @@

// ROCM-PATH: "-L[[HIPRT:.*/Inputs/rocm/lib]]" "-lamdhip64"
// ROCM-RPATH: "-L[[HIPRT:.*/Inputs/rocm/lib]]" "-rpath" "[[HIPRT]]" "-lamdhip64"
// ROCM-RPATH-CANONICAL: "-rpath" "{{.*/rocm/lib}}" "-lamdhip64"
// ROCM-REL: "-L[[HIPRT:.*/opt/rocm-3.10.0/lib]]" "-lamdhip64"
// NOHIPRT-NOT: "-L{{.*/Inputs/rocm/lib}}"
// NOHIPRT-NOT: "-rpath" "{{.*/Inputs/rocm/lib}}"
Expand Down
Loading