Skip to content

Commit c40c4ea

Browse files
committed
Add HIP_CLANG_LAUNCHER for launching Clang through a wrapper executable
Signed-off-by: Gavin Zhao <[email protected]>
1 parent 3fa9d9a commit c40c4ea

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

amd/hipcc/bin/hipcc.pl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
# HIP_ROCCLR_HOME : Path to HIP/ROCclr directory. Used on AMD platforms only.
4545
# HIP_CLANG_PATH : Path to HIP-Clang (default to ../../llvm/bin relative to this
4646
# script's abs_path). Used on AMD platforms only.
47+
# HIP_CLANG_LAUNCHER: Path to an executable to launch HIP-Clang with.
48+
# Analogous to CMAKE_C_COMPILER_LAUNCHER, this is commonly
49+
# used for launching HIP-Clang through a compiler cache.
4750

4851
if(scalar @ARGV == 0){
4952
print "No Arguments passed, exiting ...\n";
@@ -83,6 +86,8 @@ sub get_path_options {
8386
$HIP_CLANG_HCC_COMPAT_MODE=$ENV{'HIP_CLANG_HCC_COMPAT_MODE'}; # HCC compatibility mode
8487
$HIP_COMPILE_CXX_AS_HIP=$ENV{'HIP_COMPILE_CXX_AS_HIP'} // "1";
8588

89+
$HIP_CLANG_LAUNCHER=$ENV{'HIP_CLANG_LAUNCHER'};
90+
8691
#---
8792
# Temporary directories
8893
my @tmpDirs = ();
@@ -193,6 +198,7 @@ sub get_normalized_path {
193198
print ("HIP_LIB_PATH=$HIP_LIB_PATH\n");
194199
print ("DEVICE_LIB_PATH=$DEVICE_LIB_PATH\n");
195200
print ("HIP_CLANG_RT_LIB=$HIP_CLANG_RT_LIB\n");
201+
print ("HIP_CLANG_LAUNCHER=$HIP_CLANG_LAUNCHER\n");
196202
}
197203

198204
if ($HIP_CLANG_HCC_COMPAT_MODE) {
@@ -594,6 +600,10 @@ sub get_normalized_path {
594600
# TODO: convert CMD to an array rather than a string
595601
my $CMD="$HIPCC";
596602

603+
if ($HIP_CLANG_LAUNCHER) {
604+
$CMD = "\"$HIP_CLANG_LAUNCHER\" \"$CMD\"";
605+
}
606+
597607
if ($needCFLAGS) {
598608
$CMD .= " $HIPCFLAGS";
599609
}

amd/hipcc/src/hipBin_amd.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,11 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
878878
string compiler;
879879
compiler = getHipCC();
880880
string CMD = compiler;
881+
882+
if (!var.hipClangLauncher_.empty()) {
883+
CMD = "\"" + var.hipClangLauncher_ + "\" \"" + compiler + "\"";
884+
}
885+
881886
if (needCFLAGS) {
882887
CMD += " " + HIPCFLAGS;
883888
}

amd/hipcc/src/hipBin_base.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ THE SOFTWARE.
5050
# define HIP_COMPILE_CXX_AS_HIP "HIP_COMPILE_CXX_AS_HIP"
5151
# define HIPCC_VERBOSE "HIPCC_VERBOSE"
5252
# define HCC_AMDGPU_TARGET "HCC_AMDGPU_TARGET"
53+
# define HIP_CLANG_LAUNCHER "HIP_CLANG_LAUNCHER"
5354

5455
# define HIP_BASE_VERSION_MAJOR "6"
5556
# define HIP_BASE_VERSION_MINOR "0"
@@ -157,6 +158,7 @@ struct EnvVariables {
157158
string hipClangHccCompactModeEnv_ = "";
158159
string hipCompileCxxAsHipEnv_ = "";
159160
string hccAmdGpuTargetEnv_ = "";
161+
string hipClangLauncher_ = "";
160162
friend std::ostream& operator <<(std::ostream& os, const EnvVariables& var) {
161163
os << "Path: " << var.path_ << endl;
162164
os << "Hip Path: " << var.hipPathEnv_ << endl;
@@ -181,6 +183,7 @@ struct EnvVariables {
181183
os << "Hip Compile Cxx as Hip: " <<
182184
var.hipCompileCxxAsHipEnv_ << endl;
183185
os << "Hcc Amd Gpu Target: " << var.hccAmdGpuTargetEnv_ << endl;
186+
os << "Hip Clang launcher: " << var.hipClangLauncher_ << endl;
184187
return os;
185188
}
186189
};
@@ -316,6 +319,8 @@ void HipBinBase::readEnvVariables() {
316319
envVariables_.hipClangHccCompactModeEnv_ = hipClangHccCompactMode;
317320
if (const char* hipCompileCxxAsHip = std::getenv(HIP_COMPILE_CXX_AS_HIP))
318321
envVariables_.hipCompileCxxAsHipEnv_ = hipCompileCxxAsHip;
322+
if (const char* hipClangLuancher = std::getenv(HIP_CLANG_LAUNCHER))
323+
envVariables_.hipClangLauncher_ = hipClangLuancher;
319324
}
320325

321326
// constructs the HIP path

0 commit comments

Comments
 (0)