[clang] [clang][Driver] Add CLANG_DEFAULT_FRTLIB_ADD_RPATH for HIP/SYCL offload runtime rpath (PR #190213)

2026-05-09 Thread Afzal Patel via cfe-commits

https://github.com/afzpatel closed 
https://github.com/llvm/llvm-project/pull/190213
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Driver] Add CLANG_DEFAULT_FRTLIB_ADD_RPATH for HIP/SYCL offload runtime rpath (PR #190213)

2026-05-09 Thread Afzal Patel via cfe-commits

afzpatel wrote:

Closing this pr. The issue on spack is resolved by adding a missing rocm.cfg 
file which contains `-frtlib-add-rpath` 
https://github.com/spack/spack-packages/pull/4769

https://github.com/llvm/llvm-project/pull/190213
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Driver] Add CLANG_DEFAULT_FRTLIB_ADD_RPATH for HIP/SYCL offload runtime rpath (PR #190213)

2026-04-30 Thread Afzal Patel via cfe-commits

afzpatel wrote:

Ping

https://github.com/llvm/llvm-project/pull/190213
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Driver] Add CLANG_DEFAULT_FRTLIB_ADD_RPATH for HIP/SYCL offload runtime rpath (PR #190213)

2026-04-22 Thread Afzal Patel via cfe-commits

afzpatel wrote:

Ping

https://github.com/llvm/llvm-project/pull/190213
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Driver] Add CLANG_DEFAULT_FRTLIB_ADD_RPATH for HIP/SYCL offload runtime rpath (PR #190213)

2026-04-15 Thread Afzal Patel via cfe-commits

afzpatel wrote:

Ping

https://github.com/llvm/llvm-project/pull/190213
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Driver] Add CLANG_DEFAULT_FRTLIB_ADD_RPATH for HIP/SYCL offload runtime rpath (PR #190213)

2026-04-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Afzal Patel (afzpatel)


Changes

Clang only adds -rpath for the HIP/SYCL offload runtimes (libamdhip64, libsycl) 
when `-frtlib-add-rpath` is passed. The default is off, so binaries built 
against a non-unified ROCm layout (e.g. Spack, separate install prefixes) often 
link fine but fail at run time with `libamdhip64.so.7 => not found`.

This adds a CMake option `CLANG_DEFAULT_FRTLIB_ADD_RPATH` (default OFF) that 
makes that behavior the default for `Linux::addOffloadRTLibs` only. Users can 
still disable with `-fno-rtlib-add-rpath`.

---
Full diff: https://github.com/llvm/llvm-project/pull/190213.diff


3 Files Affected:

- (modified) clang/CMakeLists.txt (+4) 
- (modified) clang/include/clang/Config/config.h.cmake (+3) 
- (modified) clang/lib/Driver/ToolChains/Linux.cpp (+2-1) 


``diff
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index b3bc56209fc9e..38f6218571542 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -280,6 +280,10 @@ set(CLANG_SPAWN_CC1 OFF CACHE BOOL
 
 option(CLANG_DEFAULT_PIE_ON_LINUX "Default to -fPIE and -pie on linux-gnu" ON)
 
+option(CLANG_DEFAULT_FRTLIB_ADD_RPATH
+  "Default -frtlib-add-rpath for HIP/SYCL offload runtimes (e.g. split-prefix 
ROCm). Use -fno-rtlib-add-rpath to disable."
+  OFF)
+
 set(CLANG_DEFAULT_LINKER "" CACHE STRING
   "Default linker to use (linker name or absolute path, empty for platform 
default)")
 
diff --git a/clang/include/clang/Config/config.h.cmake 
b/clang/include/clang/Config/config.h.cmake
index 05e4deb671a7e..628c83f9f885a 100644
--- a/clang/include/clang/Config/config.h.cmake
+++ b/clang/include/clang/Config/config.h.cmake
@@ -11,6 +11,9 @@
 /* Default to -fPIE and -pie on Linux. */
 #cmakedefine01 CLANG_DEFAULT_PIE_ON_LINUX
 
+/* Default -frtlib-add-rpath for HIP/SYCL offload libs in 
Linux::addOffloadRTLibs only. */
+#cmakedefine01 CLANG_DEFAULT_FRTLIB_ADD_RPATH
+
 /* Default linker to use. */
 #define CLANG_DEFAULT_LINKER "${CLANG_DEFAULT_LINKER}"
 
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index cf67f984ccdd2..6e01c36655b07 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -870,7 +870,8 @@ void Linux::addOffloadRTLibs(unsigned ActiveKinds, const 
ArgList &Args,
 
   for (auto [Path, Library] : Libraries) {
 if (Args.hasFlag(options::OPT_frtlib_add_rpath,
- options::OPT_fno_rtlib_add_rpath, false)) {
+ options::OPT_fno_rtlib_add_rpath,
+ (bool)CLANG_DEFAULT_FRTLIB_ADD_RPATH)) {
   SmallString<0> p = Path;
   llvm::sys::path::remove_dots(p, true);
   CmdArgs.append({"-rpath", Args.MakeArgString(p)});

``




https://github.com/llvm/llvm-project/pull/190213
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Driver] Add CLANG_DEFAULT_FRTLIB_ADD_RPATH for HIP/SYCL offload runtime rpath (PR #190213)

2026-04-02 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

https://github.com/llvm/llvm-project/pull/190213
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Driver] Add CLANG_DEFAULT_FRTLIB_ADD_RPATH for HIP/SYCL offload runtime rpath (PR #190213)

2026-04-02 Thread Afzal Patel via cfe-commits

https://github.com/afzpatel created 
https://github.com/llvm/llvm-project/pull/190213

Clang only adds -rpath for the HIP/SYCL offload runtimes (libamdhip64, libsycl) 
when `-frtlib-add-rpath` is passed. The default is off, so binaries built 
against a non-unified ROCm layout (e.g. Spack, separate install prefixes) often 
link fine but fail at run time with `libamdhip64.so.7 => not found`.

This adds a CMake option `CLANG_DEFAULT_FRTLIB_ADD_RPATH` (default OFF) that 
makes that behavior the default for `Linux::addOffloadRTLibs` only. Users can 
still disable with `-fno-rtlib-add-rpath`.

>From 53614e47da05a66b09c47249f1cd483208e9503d Mon Sep 17 00:00:00 2001
From: Afzal Patel 
Date: Thu, 2 Apr 2026 09:42:52 -0700
Subject: [PATCH] Add CLANG_DEFAULT_FRTLIB_ADD_RPATH for HIP/SYCL offload
 runtime rpath

---
 clang/CMakeLists.txt  | 4 
 clang/include/clang/Config/config.h.cmake | 3 +++
 clang/lib/Driver/ToolChains/Linux.cpp | 3 ++-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index b3bc56209fc9e..38f6218571542 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -280,6 +280,10 @@ set(CLANG_SPAWN_CC1 OFF CACHE BOOL
 
 option(CLANG_DEFAULT_PIE_ON_LINUX "Default to -fPIE and -pie on linux-gnu" ON)
 
+option(CLANG_DEFAULT_FRTLIB_ADD_RPATH
+  "Default -frtlib-add-rpath for HIP/SYCL offload runtimes (e.g. split-prefix 
ROCm). Use -fno-rtlib-add-rpath to disable."
+  OFF)
+
 set(CLANG_DEFAULT_LINKER "" CACHE STRING
   "Default linker to use (linker name or absolute path, empty for platform 
default)")
 
diff --git a/clang/include/clang/Config/config.h.cmake 
b/clang/include/clang/Config/config.h.cmake
index 05e4deb671a7e..628c83f9f885a 100644
--- a/clang/include/clang/Config/config.h.cmake
+++ b/clang/include/clang/Config/config.h.cmake
@@ -11,6 +11,9 @@
 /* Default to -fPIE and -pie on Linux. */
 #cmakedefine01 CLANG_DEFAULT_PIE_ON_LINUX
 
+/* Default -frtlib-add-rpath for HIP/SYCL offload libs in 
Linux::addOffloadRTLibs only. */
+#cmakedefine01 CLANG_DEFAULT_FRTLIB_ADD_RPATH
+
 /* Default linker to use. */
 #define CLANG_DEFAULT_LINKER "${CLANG_DEFAULT_LINKER}"
 
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index cf67f984ccdd2..6e01c36655b07 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -870,7 +870,8 @@ void Linux::addOffloadRTLibs(unsigned ActiveKinds, const 
ArgList &Args,
 
   for (auto [Path, Library] : Libraries) {
 if (Args.hasFlag(options::OPT_frtlib_add_rpath,
- options::OPT_fno_rtlib_add_rpath, false)) {
+ options::OPT_fno_rtlib_add_rpath,
+ (bool)CLANG_DEFAULT_FRTLIB_ADD_RPATH)) {
   SmallString<0> p = Path;
   llvm::sys::path::remove_dots(p, true);
   CmdArgs.append({"-rpath", Args.MakeArgString(p)});

___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits