File tree Expand file tree Collapse file tree 2 files changed +26
-5
lines changed Expand file tree Collapse file tree 2 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -486,10 +486,16 @@ 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 != D.SysRoot + " /usr/local"
492+ ? Append (ParentSharePath, " hip" , " version" )
493+ : SmallString<0 >(),
494+ Append (BinPath, " .hipVersion" )};
495+
496+ for (const auto &VersionFilePath : VersionFilePaths) {
497+ if (VersionFilePath.empty ())
498+ continue ;
493499 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> VersionFile =
494500 FS.getBufferForFile (VersionFilePath);
495501 if (!VersionFile)
Original file line number Diff line number Diff line change 7777// RUN: --hip-path=%t/myhip --print-rocm-search-dirs %s 2>&1 \
7878// RUN: | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
7979
80+ // Test detecting /usr directory.
81+ // RUN: rm -rf %t/*
82+ // RUN: cp -r %S/Inputs/rocm %t/usr
83+ // RUN: mkdir -p %t/usr/share/hip
84+ // RUN: mv %t/usr/bin/.hipVersion %t/usr/share/hip/version
85+ // RUN: mkdir -p %t/usr/local
86+ // RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx1010 --sysroot=%t \
87+ // RUN: --print-rocm-search-dirs --hip-link %s 2>&1 \
88+ // RUN: | FileCheck -check-prefixes=USR %s
89+
8090// Test detecting latest /opt/rocm-{release} directory.
81- // RUN: rm -rf %t/opt
91+ // RUN: rm -rf %t/*
8292// RUN: mkdir -p %t/opt
8393// RUN: cp -r %S/Inputs/rocm %t/opt/rocm-3.9.0-1234
8494// RUN: cp -r %S/Inputs/rocm %t/opt/rocm-3.10.0
130140// ROCM-PATH: "-idirafter" "[[ROCM_PATH]]/include"
131141// ROCM-PATH: "-L[[ROCM_PATH]]/lib" {{.*}}"-lamdhip64"
132142
143+ // USR: ROCm installation search path: [[ROCM_PATH:.*/usr$]]
144+ // USR: "-mlink-builtin-bitcode" "[[ROCM_PATH]]/amdgcn/bitcode/oclc_isa_version_1010.bc"
145+ // USR: "-idirafter" "[[ROCM_PATH]]/include"
146+ // USR: "-L[[ROCM_PATH]]/lib" {{.*}}"-lamdhip64"
147+
133148// ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm
134149// ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm-3.10.0
135150
You can’t perform that action at this time.
0 commit comments