[clang] Compiler messages on HIP SDK for Windows (PR #97668)

David Salinas via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 3 20:35:42 PDT 2024


https://github.com/david-salinas created https://github.com/llvm/llvm-project/pull/97668

      When target triple indicates we are on Windows, do not add linux
      paths to search path in ROCm Installation Detection.

Change-Id: I18effb8c20252de3d84ea37ef562124695c5a570

>From eb83f777e5e15f2602b34b0ba48d1cf5ac803d16 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 +++++
 2 files changed, 15 insertions(+), 8 deletions(-)

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..e2492b1630238 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;
 



More information about the cfe-commits mailing list