Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HIP_CLANG_LAUNCHER for launching Clang through a wrapper executable #14

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions amd/hipcc/bin/hipcc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
# HIP_ROCCLR_HOME : Path to HIP/ROCclr directory. Used on AMD platforms only.
# HIP_CLANG_PATH : Path to HIP-Clang (default to ../../llvm/bin relative to this
# script's abs_path). Used on AMD platforms only.
# HIP_CLANG_LAUNCHER: Path to an executable to launch HIP-Clang with.
# Analogous to CMAKE_C_COMPILER_LAUNCHER, this is commonly
# used for launching HIP-Clang through a compiler cache.

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

$HIP_CLANG_LAUNCHER=$ENV{'HIP_CLANG_LAUNCHER'};

#---
# Temporary directories
my @tmpDirs = ();
Expand Down Expand Up @@ -193,6 +198,7 @@ sub get_normalized_path {
print ("HIP_LIB_PATH=$HIP_LIB_PATH\n");
print ("DEVICE_LIB_PATH=$DEVICE_LIB_PATH\n");
print ("HIP_CLANG_RT_LIB=$HIP_CLANG_RT_LIB\n");
print ("HIP_CLANG_LAUNCHER=$HIP_CLANG_LAUNCHER\n");
}

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

if ($HIP_CLANG_LAUNCHER) {
$CMD = "\"$HIP_CLANG_LAUNCHER\" \"$CMD\"";
}

if ($needCFLAGS) {
$CMD .= " $HIPCFLAGS";
}
Expand Down
5 changes: 5 additions & 0 deletions amd/hipcc/src/hipBin_amd.h
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,11 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
string compiler;
compiler = getHipCC();
string CMD = compiler;

if (!var.hipClangLauncher_.empty()) {
CMD = "\"" + var.hipClangLauncher_ + "\" \"" + compiler + "\"";
}

if (needCFLAGS) {
CMD += " " + HIPCFLAGS;
}
Expand Down
5 changes: 5 additions & 0 deletions amd/hipcc/src/hipBin_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ THE SOFTWARE.
# define HIP_COMPILE_CXX_AS_HIP "HIP_COMPILE_CXX_AS_HIP"
# define HIPCC_VERBOSE "HIPCC_VERBOSE"
# define HCC_AMDGPU_TARGET "HCC_AMDGPU_TARGET"
# define HIP_CLANG_LAUNCHER "HIP_CLANG_LAUNCHER"

# define HIP_BASE_VERSION_MAJOR "6"
# define HIP_BASE_VERSION_MINOR "0"
Expand Down Expand Up @@ -157,6 +158,7 @@ struct EnvVariables {
string hipClangHccCompactModeEnv_ = "";
string hipCompileCxxAsHipEnv_ = "";
string hccAmdGpuTargetEnv_ = "";
string hipClangLauncher_ = "";
friend std::ostream& operator <<(std::ostream& os, const EnvVariables& var) {
os << "Path: " << var.path_ << endl;
os << "Hip Path: " << var.hipPathEnv_ << endl;
Expand All @@ -181,6 +183,7 @@ struct EnvVariables {
os << "Hip Compile Cxx as Hip: " <<
var.hipCompileCxxAsHipEnv_ << endl;
os << "Hcc Amd Gpu Target: " << var.hccAmdGpuTargetEnv_ << endl;
os << "Hip Clang launcher: " << var.hipClangLauncher_ << endl;
return os;
}
};
Expand Down Expand Up @@ -316,6 +319,8 @@ void HipBinBase::readEnvVariables() {
envVariables_.hipClangHccCompactModeEnv_ = hipClangHccCompactMode;
if (const char* hipCompileCxxAsHip = std::getenv(HIP_COMPILE_CXX_AS_HIP))
envVariables_.hipCompileCxxAsHipEnv_ = hipCompileCxxAsHip;
if (const char* hipClangLuancher = std::getenv(HIP_CLANG_LAUNCHER))
envVariables_.hipClangLauncher_ = hipClangLuancher;
}

// constructs the HIP path
Expand Down