Skip to content

Commit 43c90f9

Browse files
committed
[HIP] Make --offload-add-rpath alias of -frtlib-add-rpath
HIP runtime is the language runtime of HIP. When users need to specify rpath, they usually need to specify rpath for both compiler-rt and HIP runtime. It seems redundant to have separate options. Therefore make --offload-add-rpath an alias to -frtlib-add-rpath. Reviewed by: Fangrui Song, Artem Belevich Differential Revision: https://reviews.llvm.org/D145393
1 parent 9883558 commit 43c90f9

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4253,13 +4253,15 @@ def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>, Group<Link_Group>;
42534253
def rtlib_EQ : Joined<["-", "--"], "rtlib=">,
42544254
HelpText<"Compiler runtime library to use">;
42554255
def frtlib_add_rpath: Flag<["-"], "frtlib-add-rpath">, Flags<[NoArgumentUnused]>,
4256-
HelpText<"Add -rpath with architecture-specific resource directory to the linker flags">;
4256+
HelpText<"Add -rpath with architecture-specific resource directory to the linker flags. "
4257+
"When --hip-link is specified, also add -rpath with HIP runtime library directory to the linker flags">;
42574258
def fno_rtlib_add_rpath: Flag<["-"], "fno-rtlib-add-rpath">, Flags<[NoArgumentUnused]>,
4258-
HelpText<"Do not add -rpath with architecture-specific resource directory to the linker flags">;
4259+
HelpText<"Do not add -rpath with architecture-specific resource directory to the linker flags. "
4260+
"When --hip-link is specified, do not add -rpath with HIP runtime library directory to the linker flags">;
42594261
def offload_add_rpath: Flag<["--"], "offload-add-rpath">, Flags<[NoArgumentUnused]>,
4260-
HelpText<"Add -rpath with HIP runtime library directory to the linker flags">;
4262+
Alias<frtlib_add_rpath>;
42614263
def no_offload_add_rpath: Flag<["--"], "no-offload-add-rpath">, Flags<[NoArgumentUnused]>,
4262-
HelpText<"Do not add -rpath with HIP runtime library directory to the linker flags">;
4264+
Alias<frtlib_add_rpath>;
42634265
def r : Flag<["-"], "r">, Flags<[LinkerInput,NoArgumentUnused]>,
42644266
Group<Link_Group>;
42654267
def save_temps_EQ : Joined<["-", "--"], "save-temps=">, Flags<[CC1Option, FlangOption, NoXarchOption]>,

clang/lib/Driver/ToolChains/Linux.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,8 @@ void Linux::AddHIPRuntimeLibArgs(const ArgList &Args,
694694
CmdArgs.push_back(
695695
Args.MakeArgString(StringRef("-L") + RocmInstallation->getLibPath()));
696696

697-
if (Args.hasFlag(options::OPT_offload_add_rpath,
698-
options::OPT_no_offload_add_rpath, false))
697+
if (Args.hasFlag(options::OPT_frtlib_add_rpath,
698+
options::OPT_fno_rtlib_add_rpath, false))
699699
CmdArgs.append(
700700
{"-rpath", Args.MakeArgString(RocmInstallation->getLibPath())});
701701

clang/test/Driver/hip-runtime-libs-linux.hip

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
// RUN: --rocm-path=%S/Inputs/rocm %t.o --offload-add-rpath 2>&1 \
1717
// RUN: | FileCheck -check-prefixes=ROCM-RPATH %s
1818

19+
// RUN: %clang -### --hip-link --target=x86_64-linux-gnu \
20+
// RUN: --rocm-path=%S/Inputs/rocm %t.o -frtlib-add-rpath 2>&1 \
21+
// RUN: | FileCheck -check-prefixes=ROCM-RPATH %s
22+
1923
// Test detecting latest /opt/rocm-{release} directory.
2024
// RUN: rm -rf %t && mkdir -p %t/opt
2125
// RUN: cp -r %S/Inputs/rocm %t/opt/rocm-3.9.0-1234

0 commit comments

Comments
 (0)