Skip to content

Commit 4da60ea

Browse files
committed
[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: #78344
1 parent 209fe1f commit 4da60ea

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,15 @@ void RocmInstallationDetector::detectHIPRuntime() {
486486
return newpath;
487487
};
488488
// If HIP version file can be found and parsed, use HIP version from there.
489-
for (const auto &VersionFilePath :
490-
{Append(SharePath, "hip", "version"),
491-
Append(ParentSharePath, "hip", "version"),
492-
Append(BinPath, ".hipVersion")}) {
489+
std::vector<SmallString<0>> VersionFilePaths = {
490+
Append(SharePath, "hip", "version"),
491+
InstallPath != "/usr/local" ? Append(ParentSharePath, "hip", "version")
492+
: SmallString<0>(),
493+
Append(BinPath, ".hipVersion")};
494+
495+
for (const auto &VersionFilePath : VersionFilePaths) {
496+
if (VersionFilePath.empty())
497+
continue;
493498
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> VersionFile =
494499
FS.getBufferForFile(VersionFilePath);
495500
if (!VersionFile)

0 commit comments

Comments
 (0)