[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);
----------------
yxsamliu wrote:

Can we use the SDK Clang already selected? With `clang.cfg` pointing to TheRock and `ROCM_PATH` pointing to system ROCm, Clang compiles with TheRock and the REPL loads the system ROCm runtime.

https://github.com/llvm/llvm-project/pull/246462


More information about the cfe-commits mailing list