From eeb34e2b2f86d385a0ac58e2a67cf79f539e6ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Ke=C3=9Fler?= Date: Sun, 13 Oct 2024 16:42:31 +0200 Subject: [PATCH] [hipcc] Populate compiler and linker flags on AMD platform Fixes https://github.com/ROCm/llvm-project/issues/172 --- amd/hipcc/src/hipBin_amd.h | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/amd/hipcc/src/hipBin_amd.h b/amd/hipcc/src/hipBin_amd.h index 0a782d1beab9f6..721ca9443657af 100644 --- a/amd/hipcc/src/hipBin_amd.h +++ b/amd/hipcc/src/hipBin_amd.h @@ -158,10 +158,17 @@ void HipBinAmd::initializeHipLdFlags() { if (!fs::exists(hipCC)) { hipLdFlags = "--driver-mode=g++"; } + string hipLib = getHipLibPath(); + hipLdFlags += " -L \"" + hipLib + "\"" + " -lamdhip64"; hipLdFlags_ = hipLdFlags; } void HipBinAmd::initializeHipCFlags() { + string hipCFlags; + string hipIncludePath = getHipInclude(); + hipCFlags += " -isystem \"" + hipIncludePath + "\""; + + hipCFlags_ = hipCFlags; } const string& HipBinAmd::getHipCXXFlags() const { @@ -192,6 +199,8 @@ void HipBinAmd::initializeHipCXXFlags() { hipCXXFlags += " -Xclang -fallow-half-arguments-and-returns -D__HIP_HCC_COMPAT_MODE__=1"; } + string hipIncludePath = getHipInclude(); + hipCXXFlags += " -isystem \"" + hipIncludePath + "\""; hipCXXFlags_ = hipCXXFlags; } @@ -367,16 +376,15 @@ bool HipBinAmd::detectPlatform() { } string HipBinAmd::getHipLibPath() const { - string hipLibPath; - const EnvVariables& env = getEnvVariables(); - if (!env.hipLibPathEnv_.empty()) { - hipLibPath = env.hipLibPathEnv_; - } - else if (!env.hipPathEnv_.empty()) { - fs::path p = env.hipLibPathEnv_; - p /= "lib"; - hipLibPath = p.string(); + const string& rocclrHomePath = getRocclrHomePath(); + fs::path hipLibfs = rocclrHomePath; + hipLibfs /= "lib"; + if (hipLibfs.string().empty()) { + const string& hipPath = getHipPath(); + hipLibfs = hipPath; + hipLibfs /= "include"; } + string hipLibPath = hipLibfs.string(); return hipLibPath; }