[clang] Compiler messages on HIP SDK for Windows (PR #97668)
David Salinas via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 9 07:56:14 PDT 2024
https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/97668
>From 838ea93f30e9e421ad9948618cfcb61703d94029 Mon Sep 17 00:00:00 2001
From: David Salinas <david.salinas at amd.com>
Date: Thu, 4 Jul 2024 03:32:13 +0000
Subject: [PATCH] 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
---
clang/lib/Driver/ToolChains/AMDGPU.cpp | 18 ++++++++++--------
clang/lib/Driver/ToolChains/ROCm.h | 5 +++++
clang/test/Driver/rocm-detect-windows.hip | 8 ++++++++
3 files changed, 23 insertions(+), 8 deletions(-)
create mode 100644 clang/test/Driver/rocm-detect-windows.hip
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 453daed7cc7d5..e05b9202599c7 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -306,14 +306,16 @@ RocmInstallationDetector::getInstallationPathCandidates() {
LatestVer = Ver;
}
}
- if (!LatestROCm.empty())
- ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm,
- /*StrictChecking=*/true);
+ if (!isWindows()) {
+ if (!LatestROCm.empty())
+ ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm,
+ /*StrictChecking=*/true);
- ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local",
- /*StrictChecking=*/true);
- ROCmSearchDirs.emplace_back(D.SysRoot + "/usr",
- /*StrictChecking=*/true);
+ ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local",
+ /*StrictChecking=*/true);
+ ROCmSearchDirs.emplace_back(D.SysRoot + "/usr",
+ /*StrictChecking=*/true);
+ }
DoPrintROCmSearchDirs();
return ROCmSearchDirs;
@@ -322,7 +324,7 @@ RocmInstallationDetector::getInstallationPathCandidates() {
RocmInstallationDetector::RocmInstallationDetector(
const Driver &D, const llvm::Triple &HostTriple,
const llvm::opt::ArgList &Args, bool DetectHIPRuntime, bool DetectDeviceLib)
- : D(D) {
+ : D(D), hostTriple(HostTriple) {
Verbose = Args.hasArg(options::OPT_v);
RocmPathArg = Args.getLastArgValue(clang::driver::options::OPT_rocm_path_EQ);
PrintROCmSearchDirs =
diff --git a/clang/lib/Driver/ToolChains/ROCm.h b/clang/lib/Driver/ToolChains/ROCm.h
index dceb0ab036693..242e84a32e8d0 100644
--- a/clang/lib/Driver/ToolChains/ROCm.h
+++ b/clang/lib/Driver/ToolChains/ROCm.h
@@ -111,6 +111,8 @@ class RocmInstallationDetector {
// Wheter -nogpulib is specified.
bool NoBuiltinLibs = false;
+ llvm::Triple hostTriple;
+
// Paths
SmallString<0> InstallPath;
SmallString<0> BinPath;
@@ -193,6 +195,9 @@ class RocmInstallationDetector {
/// Check whether we detected a valid HIP STDPAR Acceleration library.
bool hasHIPStdParLibrary() const { return HasHIPStdParLibrary; }
+ /// Check whether the target triple is for Windows.
+ bool isWindows() const { return hostTriple.isOSWindows(); }
+
/// Print information about the detected ROCm installation.
void print(raw_ostream &OS) const;
diff --git a/clang/test/Driver/rocm-detect-windows.hip b/clang/test/Driver/rocm-detect-windows.hip
new file mode 100644
index 0000000000000..e8a940862c6ec
--- /dev/null
+++ b/clang/test/Driver/rocm-detect-windows.hip
@@ -0,0 +1,8 @@
+// REQUIRES: system-windows
+
+// Test to ensure that on Windows, we do not include linux sesrch paths
+// RUN: %clang -### -nogpulib -nogpuinc \
+// RUN: --print-rocm-search-dirs %s 2>&1 \
+// RUN: | FileCheck %s
+
+// CHECK-NOT: ROCm installation search path: [[ROCM_PATH:.*/usr$]]
More information about the cfe-commits
mailing list