[clang] Fix amdgpu-arch for dll name on Windows (PR #101350)
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 25 14:22:39 PDT 2024
================
@@ -31,16 +44,118 @@ typedef hipError_t (*hipGetDeviceCount_t)(int *);
typedef hipError_t (*hipDeviceGet_t)(int *, int);
typedef hipError_t (*hipGetDeviceProperties_t)(hipDeviceProp_t *, int);
-int printGPUsByHIP() {
+extern cl::opt<bool> Verbose;
+
#ifdef _WIN32
- constexpr const char *DynamicHIPPath = "amdhip64.dll";
+static std::vector<std::string> getSearchPaths() {
+ std::vector<std::string> Paths;
+
+ // Get the directory of the current executable
+ if (auto MainExe = sys::fs::getMainExecutable(nullptr, nullptr);
+ !MainExe.empty())
+ Paths.push_back(sys::path::parent_path(MainExe).str());
+
+ // Get the system directory
+ wchar_t SystemDirectory[MAX_PATH];
+ if (GetSystemDirectoryW(SystemDirectory, MAX_PATH) > 0) {
+ std::string Utf8SystemDir;
+ if (convertUTF16ToUTF8String(
+ ArrayRef<UTF16>(reinterpret_cast<const UTF16 *>(SystemDirectory),
+ wcslen(SystemDirectory)),
+ Utf8SystemDir))
+ Paths.push_back(Utf8SystemDir);
+ }
+
+ // Get the Windows directory
+ wchar_t WindowsDirectory[MAX_PATH];
+ if (GetWindowsDirectoryW(WindowsDirectory, MAX_PATH) > 0) {
+ std::string Utf8WindowsDir;
+ if (convertUTF16ToUTF8String(
+ ArrayRef<UTF16>(reinterpret_cast<const UTF16 *>(WindowsDirectory),
+ wcslen(WindowsDirectory)),
+ Utf8WindowsDir))
+ Paths.push_back(Utf8WindowsDir);
+ }
+
+ // Get the current working directory
+ SmallVector<char, 256> CWD;
+ if (sys::fs::current_path(CWD))
+ Paths.push_back(std::string(CWD.begin(), CWD.end()));
+
+ // Get the PATH environment variable
+ if (auto PathEnv = sys::Process::GetEnv("PATH")) {
----------------
arsenm wrote:
No auto
https://github.com/llvm/llvm-project/pull/101350
More information about the cfe-commits
mailing list