[clang] [clang-repl] Load the HIP runtime from the detected ROCm installation (PR #246462)
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 29 14:53:03 PST 2026
================
@@ -165,6 +168,28 @@ static llvm::Expected<unsigned> getSlabAllocSize(llvm::StringRef SizeString) {
return SlabSize * Units;
}
+static std::string getHIPRuntimePath(llvm::ArrayRef<const char *> UserArgs) {
+ const char *RuntimeLib = "libamdhip64.so";
+
+ clang::DiagnosticOptions DiagOpts;
+ clang::DiagnosticsEngine Diags(clang::DiagnosticIDs::create(), DiagOpts,
+ new clang::IgnoringDiagConsumer());
+ std::string TT = llvm::sys::getProcessTriple();
+ std::string Exe = llvm::sys::fs::getMainExecutable(nullptr, nullptr);
+ clang::driver::Driver D(Exe, TT, Diags);
+ bool ContainsError = false;
+ llvm::opt::InputArgList Args =
+ D.ParseArgStrings(UserArgs, /*UseDriverMode=*/true, ContainsError);
+
+ clang::driver::RocmInstallationDetector Rocm(D, llvm::Triple(TT), Args);
+ if (!Rocm.hasHIPRuntime())
+ return RuntimeLib;
+
+ llvm::SmallString<256> Path(Rocm.getLibPath());
+ llvm::sys::path::append(Path, RuntimeLib);
----------------
yxsamliu wrote:
Can we load `libamdhip64.so` by name if this path is missing? On Debian, the library is in `/usr/lib/x86_64-linux-gnu`, so opening `/usr/lib/libamdhip64.so` fails even though the library is installed.
https://github.com/llvm/llvm-project/pull/246462
More information about the cfe-commits
mailing list