summaryrefslogtreecommitdiff
blob: 225adc7096660560be27c2f1a00c09c22f9f77b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
replace hardcoded hip finder with Gentoo paths.

It is not necessary to check HIP runtime each time.

Author: Benda Xu <heroxbd@gentoo.org>

Index: llvm-project-rocm-4.0.0/clang/lib/Driver/ToolChains/AMDGPU.cpp
===================================================================
--- llvm-project-rocm-4.0.0.orig/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ llvm-project-rocm-4.0.0/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -116,37 +116,8 @@ RocmInstallationDetector::getInstallatio
     return Candidates;
   }
 
-  // Try to find relative to the compiler binary.
-  const char *InstallDir = D.getInstalledDir();
+  Candidates.emplace_back(D.SysRoot + "/usr", /*StrictChecking=*/true);
 
-  // Check both a normal Unix prefix position of the clang binary, as well as
-  // the Windows-esque layout the ROCm packages use with the host architecture
-  // subdirectory of bin.
-
-  // Strip off directory (usually bin)
-  StringRef ParentDir = llvm::sys::path::parent_path(InstallDir);
-  StringRef ParentName = llvm::sys::path::filename(ParentDir);
-
-  // Some builds use bin/{host arch}, so go up again.
-  if (ParentName == "bin") {
-    ParentDir = llvm::sys::path::parent_path(ParentDir);
-    ParentName = llvm::sys::path::filename(ParentDir);
-  }
-
-  // Some versions of the rocm llvm package install to /opt/rocm/llvm/bin
-  if (ParentName == "llvm")
-    ParentDir = llvm::sys::path::parent_path(ParentDir);
-
-  Candidates.emplace_back(ParentDir.str(), /*StrictChecking=*/true);
-
-  // Device library may be installed in clang resource directory.
-  Candidates.emplace_back(D.ResourceDir, /*StrictChecking=*/true);
-
-  Candidates.emplace_back(D.SysRoot + "/opt/rocm", /*StrictChecking=*/true);
-  if (ParentName.startswith("aomp")) {
-    // Some versions of the aomp package install to /opt/rocm/aomp/bin
-    Candidates.emplace_back(ParentDir.str());
-  }
   return Candidates;
 }
 
@@ -273,33 +244,7 @@ void RocmInstallationDetector::detectDev
 }
 
 void RocmInstallationDetector::detectHIPRuntime() {
-  auto Candidates = getInstallationPathCandidates();
-  auto &FS = D.getVFS();
-
-  for (const auto &Candidate : Candidates) {
-    InstallPath = Candidate.Path;
-    if (InstallPath.empty() || !FS.exists(InstallPath))
-      continue;
-
-    BinPath = InstallPath;
-    llvm::sys::path::append(BinPath, "bin");
-    IncludePath = InstallPath;
-    llvm::sys::path::append(IncludePath, "include");
-    LibPath = InstallPath;
-    llvm::sys::path::append(LibPath, "lib");
-
-    llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> VersionFile =
-        FS.getBufferForFile(BinPath + "/.hipVersion");
-    if (!VersionFile && Candidate.StrictChecking)
-      continue;
-
-    if (HIPVersionArg.empty() && VersionFile)
-      ParseHIPVersionFile((*VersionFile)->getBuffer());
-
-    HasHIPRuntime = true;
-    return;
-  }
-  HasHIPRuntime = false;
+  HasHIPRuntime = true;
 }
 
 void RocmInstallationDetector::print(raw_ostream &OS) const {