From 840a793375fec763c2b2781b82b764325635cc7a Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 28 Oct 2022 16:10:41 -0700 Subject: [PATCH] clang/AMDGPU: Use Support's wrapper around getenv This does some extra stuff for Windows, so might as well use it just in case. --- clang/lib/Driver/ToolChains/AMDGPU.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 2615941..153537c 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -20,6 +20,7 @@ #include "llvm/Support/Host.h" #include "llvm/Support/LineIterator.h" #include "llvm/Support/Path.h" +#include "llvm/Support/Process.h" #include "llvm/Support/VirtualFileSystem.h" #include @@ -199,9 +200,10 @@ RocmInstallationDetector::getInstallationPathCandidates() { ROCmSearchDirs.emplace_back(RocmPathArg.str()); DoPrintROCmSearchDirs(); return ROCmSearchDirs; - } else if (const char *RocmPathEnv = ::getenv("ROCM_PATH")) { - if (!StringRef(RocmPathEnv).empty()) { - ROCmSearchDirs.emplace_back(RocmPathEnv); + } else if (Optional RocmPathEnv = + llvm::sys::Process::GetEnv("ROCM_PATH")) { + if (!RocmPathEnv->empty()) { + ROCmSearchDirs.emplace_back(std::move(*RocmPathEnv)); DoPrintROCmSearchDirs(); return ROCmSearchDirs; } @@ -374,8 +376,9 @@ void RocmInstallationDetector::detectDeviceLibrary() { if (!RocmDeviceLibPathArg.empty()) LibDevicePath = RocmDeviceLibPathArg[RocmDeviceLibPathArg.size() - 1]; - else if (const char *LibPathEnv = ::getenv("HIP_DEVICE_LIB_PATH")) - LibDevicePath = LibPathEnv; + else if (Optional LibPathEnv = + llvm::sys::Process::GetEnv("HIP_DEVICE_LIB_PATH")) + LibDevicePath = std::move(*LibPathEnv); auto &FS = D.getVFS(); if (!LibDevicePath.empty()) { -- 2.7.4