[clang] [clang][Driver] Handle ROCm installation layout of lib/llvm/bin/clang (PR #138928)

via cfe-commits cfe-commits at lists.llvm.org
Wed May 7 11:03:31 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Jacob Lambert (lamb-j)

<details>
<summary>Changes</summary>

Committing on behalf of @<!-- -->stellaraccident 

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


1 Files Affected:

- (modified) clang/lib/Driver/ToolChains/AMDGPU.cpp (+8-1) 


``````````diff
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 35ca019795ddc..7405ffecb577c 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -181,8 +181,15 @@ RocmInstallationDetector::getInstallationPathCandidates() {
 
     // Some versions of the rocm llvm package install to /opt/rocm/llvm/bin
     // Some versions of the aomp package install to /opt/rocm/aomp/bin
-    if (ParentName == "llvm" || ParentName.starts_with("aomp"))
+    if (ParentName == "llvm" || ParentName.starts_with("aomp")) {
       ParentDir = llvm::sys::path::parent_path(ParentDir);
+      ParentName = llvm::sys::path::filename(ParentDir);
+
+      // Some versions of the rocm llvm package install to
+      // /opt/rocm/lib/llvm/bin, so also back up if within the lib dir still.
+      if (ParentName == "lib")
+        ParentDir = llvm::sys::path::parent_path(ParentDir);
+    }
 
     return Candidate(ParentDir.str(), /*StrictChecking=*/true);
   };

``````````

</details>


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


More information about the cfe-commits mailing list