-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[HIP] fix HIP detection for /usr #80190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-backend-amdgpu Author: Yaxun (Sam) Liu (yxsamliu) ChangesSkip checking HIP version file under parent directory for /usr/local since /usr will be checked after /usr/local. Fixes: #78344 Full diff: https://github.com/llvm/llvm-project/pull/80190.diff 1 Files Affected:
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)
|
@llvm/pr-subscribers-clang Author: Yaxun (Sam) Liu (yxsamliu) ChangesSkip checking HIP version file under parent directory for /usr/local since /usr will be checked after /usr/local. Fixes: #78344 Full diff: https://github.com/llvm/llvm-project/pull/80190.diff 1 Files Affected:
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)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any tests for this kind of stuff? We really should have some mock ROCm installation in one of the Inputs/
directories and then do --rocm-path=
or something.
Skip checking HIP version file under parent directory for /usr/local since /usr will be checked after /usr/local. Fixes: llvm#78344
test added |
Skip checking HIP version file under parent directory for /usr/local since /usr will be checked after /usr/local. Fixes: llvm#78344
Skip checking HIP version file under parent directory for /usr/local since /usr will be checked after /usr/local. Fixes: llvm#78344
Skip checking HIP version file under parent directory for /usr/local since /usr will be checked after /usr/local. Fixes: llvm#78344
Skip checking HIP version file under parent directory for /usr/local since /usr will be checked after /usr/local.
Fixes: #78344