https://github.com/yxsamliu created 
https://github.com/llvm/llvm-project/pull/80190

Skip checking HIP version file under parent directory for /usr/local since /usr 
will be checked after /usr/local.

Fixes: https://github.com/llvm/llvm-project/issues/78344

>From 4da60eac1a940d922703381a9a07c9329e733e11 Mon Sep 17 00:00:00 2001
From: "Yaxun (Sam) Liu" <yaxun....@amd.com>
Date: Wed, 31 Jan 2024 15:14:10 -0500
Subject: [PATCH] [HIP] fix HIP detection for /usr

Skip checking HIP version file under parent directory
for /usr/local since /usr will be checked after /usr/local.

Fixes: https://github.com/llvm/llvm-project/issues/78344
---
 clang/lib/Driver/ToolChains/AMDGPU.cpp | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index b3c9d5908654f..e207a9d784d5a 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -486,10 +486,15 @@ void RocmInstallationDetector::detectHIPRuntime() {
       return newpath;
     };
     // If HIP version file can be found and parsed, use HIP version from there.
-    for (const auto &VersionFilePath :
-         {Append(SharePath, "hip", "version"),
-          Append(ParentSharePath, "hip", "version"),
-          Append(BinPath, ".hipVersion")}) {
+    std::vector<SmallString<0>> VersionFilePaths = {
+        Append(SharePath, "hip", "version"),
+        InstallPath != "/usr/local" ? Append(ParentSharePath, "hip", "version")
+                                    : SmallString<0>(),
+        Append(BinPath, ".hipVersion")};
+
+    for (const auto &VersionFilePath : VersionFilePaths) {
+      if (VersionFilePath.empty())
+        continue;
       llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> VersionFile =
           FS.getBufferForFile(VersionFilePath);
       if (!VersionFile)

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to