[clang] Compiler messages on HIP SDK for Windows (PR #97668)
David Salinas via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 8 21:15:47 PDT 2024
https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/97668
>From 970b1e696b77216f326fb7d8dcad5b55a82db489 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] Compiler messages on HIP SDK for 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 | 7 +++++++
3 files changed, 22 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..7f7c34efb5fd4
--- /dev/null
+++ b/clang/test/Driver/rocm-detect-windows.hip
@@ -0,0 +1,7 @@
+// UNSUPPORTED: system-linux
+
+// 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