[clang] [clang][Driver] Handle ROCm installation layout of lib/llvm/bin/clang (PR #138928)
Jacob Lambert via cfe-commits
cfe-commits at lists.llvm.org
Wed May 7 11:03:53 PDT 2025
https://github.com/lamb-j updated https://github.com/llvm/llvm-project/pull/138928
>From a488081edf4c975a63414c6a5ea713403f2d77bb Mon Sep 17 00:00:00 2001
From: Jacob Lambert <jacob.lambert at amd.com>
Date: Wed, 7 May 2025 11:01:14 -0700
Subject: [PATCH 1/2] [clang][Driver] Handle ROCm installation layout of
lib/llvm/bin/clang
---
clang/lib/Driver/ToolChains/AMDGPU.cpp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
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);
};
>From cbfb0317b8c82dcea2d28d47e71e028deedf754f Mon Sep 17 00:00:00 2001
From: Jacob Lambert <jacob.lambert at amd.com>
Date: Wed, 7 May 2025 11:03:45 -0700
Subject: [PATCH 2/2] Update clang/lib/Driver/ToolChains/AMDGPU.cpp
---
clang/lib/Driver/ToolChains/AMDGPU.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 7405ffecb577c..116e39ca8518f 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -186,7 +186,7 @@ RocmInstallationDetector::getInstallationPathCandidates() {
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.
+ // /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);
}
More information about the cfe-commits
mailing list