[clang] [clang][Driver][HIP] Support Debian multiarch libamdhip64.so layout (PR #208525)
David Salinas via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 24 21:05:04 PST 2026
================
@@ -887,9 +887,27 @@ void Linux::addOffloadRTLibs(unsigned ActiveKinds, const ArgList &Args,
Args.hasArg(options::OPT_no_hip_rt) || Args.hasArg(options::OPT_r))
return;
+ // On Debian and derivatives, the ROCm runtime ships under
+ // <rocm>/lib/<multiarch-triple>/ (e.g. /usr/lib/x86_64-linux-gnu/) rather
+ // than <rocm>/lib/. Prefer the multiarch subdir when libamdhip64.so lives
+ // there, so the absolute path emitted below, the -L search path, and any
+ // -rpath all resolve to a real file. Non-multiarch layouts (Fedora, Arch,
+ // /opt/rocm, etc.) are unaffected: the probe short-circuits when the
+ // multiarch subdir does not contain libamdhip64.so.
+ SmallString<0> HIPLibPath;
+ if (ActiveKinds & Action::OFK_HIP) {
+ HIPLibPath = RocmInstallation->getLibPath();
+ std::string MultiarchTriple =
+ getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot);
+ SmallString<0> MultiarchProbe = HIPLibPath;
+ llvm::sys::path::append(MultiarchProbe, MultiarchTriple, "libamdhip64.so");
+ if (getVFS().exists(MultiarchProbe))
+ llvm::sys::path::append(HIPLibPath, MultiarchTriple);
+ }
+
llvm::SmallVector<std::pair<StringRef, StringRef>> Libraries;
if (ActiveKinds & Action::OFK_HIP)
- Libraries.emplace_back(RocmInstallation->getLibPath(), "libamdhip64.so");
+ Libraries.emplace_back(HIPLibPath, "libamdhip64.so");
----------------
david-salinas wrote:
Small nit. Should we combine these two " if (ActiveKinds & Action::OFK_HIP)" statements? Line #898 and #909?
https://github.com/llvm/llvm-project/pull/208525
More information about the cfe-commits
mailing list