Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -4253,13 +4253,15 @@ def rtlib_EQ : Joined<["-", "--"], "rtlib=">, HelpText<"Compiler runtime library to use">; def frtlib_add_rpath: Flag<["-"], "frtlib-add-rpath">, Flags<[NoArgumentUnused]>, - HelpText<"Add -rpath with architecture-specific resource directory to the linker flags">; + HelpText<"Add -rpath with architecture-specific resource directory to the linker flags. " + "When --hip-link is specified, also add -rpath with HIP runtime library directory to the linker flags">; def fno_rtlib_add_rpath: Flag<["-"], "fno-rtlib-add-rpath">, Flags<[NoArgumentUnused]>, - HelpText<"Do not add -rpath with architecture-specific resource directory to the linker flags">; + HelpText<"Do not add -rpath with architecture-specific resource directory to the linker flags. " + "When --hip-link is specified, do not add -rpath with HIP runtime library directory to the linker flags">; def offload_add_rpath: Flag<["--"], "offload-add-rpath">, Flags<[NoArgumentUnused]>, - HelpText<"Add -rpath with HIP runtime library directory to the linker flags">; + Alias; def no_offload_add_rpath: Flag<["--"], "no-offload-add-rpath">, Flags<[NoArgumentUnused]>, - HelpText<"Do not add -rpath with HIP runtime library directory to the linker flags">; + Alias; defm openmp_implicit_rpath: BoolFOption<"openmp-implicit-rpath", LangOpts<"OpenMP">, DefaultTrue, Index: clang/lib/Driver/ToolChains/Linux.cpp =================================================================== --- clang/lib/Driver/ToolChains/Linux.cpp +++ clang/lib/Driver/ToolChains/Linux.cpp @@ -694,8 +694,8 @@ CmdArgs.push_back( Args.MakeArgString(StringRef("-L") + RocmInstallation->getLibPath())); - if (Args.hasFlag(options::OPT_offload_add_rpath, - options::OPT_no_offload_add_rpath, false)) + if (Args.hasFlag(options::OPT_frtlib_add_rpath, + options::OPT_fno_rtlib_add_rpath, false)) CmdArgs.append( {"-rpath", Args.MakeArgString(RocmInstallation->getLibPath())}); Index: clang/test/Driver/hip-runtime-libs-linux.hip =================================================================== --- clang/test/Driver/hip-runtime-libs-linux.hip +++ clang/test/Driver/hip-runtime-libs-linux.hip @@ -13,7 +13,7 @@ // RUN: | FileCheck -check-prefixes=ROCM-PATH %s // RUN: %clang -### --hip-link --target=x86_64-linux-gnu \ -// RUN: --rocm-path=%S/Inputs/rocm %t.o --offload-add-rpath 2>&1 \ +// RUN: --rocm-path=%S/Inputs/rocm %t.o -frtlib-add-rpath 2>&1 \ // RUN: | FileCheck -check-prefixes=ROCM-RPATH %s // Test detecting latest /opt/rocm-{release} directory.