Skip to content

Commit 838ea93

Browse files
David SalinasDavid Salinas
authored andcommitted
Remove Linux path names in ROCm search paths on Windows
When target triple indicates we are on Windows, do not add linux paths to search path in ROCm Installation Detection. Change-Id: I18effb8c20252de3d84ea37ef562124695c5a570
1 parent 845dee3 commit 838ea93

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,16 @@ RocmInstallationDetector::getInstallationPathCandidates() {
306306
LatestVer = Ver;
307307
}
308308
}
309-
if (!LatestROCm.empty())
310-
ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm,
311-
/*StrictChecking=*/true);
309+
if (!isWindows()) {
310+
if (!LatestROCm.empty())
311+
ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm,
312+
/*StrictChecking=*/true);
312313

313-
ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local",
314-
/*StrictChecking=*/true);
315-
ROCmSearchDirs.emplace_back(D.SysRoot + "/usr",
316-
/*StrictChecking=*/true);
314+
ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local",
315+
/*StrictChecking=*/true);
316+
ROCmSearchDirs.emplace_back(D.SysRoot + "/usr",
317+
/*StrictChecking=*/true);
318+
}
317319

318320
DoPrintROCmSearchDirs();
319321
return ROCmSearchDirs;
@@ -322,7 +324,7 @@ RocmInstallationDetector::getInstallationPathCandidates() {
322324
RocmInstallationDetector::RocmInstallationDetector(
323325
const Driver &D, const llvm::Triple &HostTriple,
324326
const llvm::opt::ArgList &Args, bool DetectHIPRuntime, bool DetectDeviceLib)
325-
: D(D) {
327+
: D(D), hostTriple(HostTriple) {
326328
Verbose = Args.hasArg(options::OPT_v);
327329
RocmPathArg = Args.getLastArgValue(clang::driver::options::OPT_rocm_path_EQ);
328330
PrintROCmSearchDirs =

clang/lib/Driver/ToolChains/ROCm.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ class RocmInstallationDetector {
111111
// Wheter -nogpulib is specified.
112112
bool NoBuiltinLibs = false;
113113

114+
llvm::Triple hostTriple;
115+
114116
// Paths
115117
SmallString<0> InstallPath;
116118
SmallString<0> BinPath;
@@ -193,6 +195,9 @@ class RocmInstallationDetector {
193195
/// Check whether we detected a valid HIP STDPAR Acceleration library.
194196
bool hasHIPStdParLibrary() const { return HasHIPStdParLibrary; }
195197

198+
/// Check whether the target triple is for Windows.
199+
bool isWindows() const { return hostTriple.isOSWindows(); }
200+
196201
/// Print information about the detected ROCm installation.
197202
void print(raw_ostream &OS) const;
198203

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// REQUIRES: system-windows
2+
3+
// Test to ensure that on Windows, we do not include linux sesrch paths
4+
// RUN: %clang -### -nogpulib -nogpuinc \
5+
// RUN: --print-rocm-search-dirs %s 2>&1 \
6+
// RUN: | FileCheck %s
7+
8+
// CHECK-NOT: ROCm installation search path: [[ROCM_PATH:.*/usr$]]

0 commit comments

Comments
 (0)