Skip to content

Commit

Permalink
SWDEV-385406 - [hipcc] Pass HIP_PATH to clang
Browse files Browse the repository at this point in the history
The HIP_PATH env var has been broken by an earlier patch to change the
linking to the HIP runtime with --hip-link in hipcc.  We need to detect
when the HIP_PATH env var is defined, we have to pass that to the clang.

Change-Id: Iea939893844cce426d4bc4ace3539fc241363ff3
  • Loading branch information
scchan authored and zhang2amd committed Mar 6, 2023
1 parent 1dabde9 commit e63f21b
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions bin/hipcc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,21 @@

# retrieve --rocm-path hipcc option from command line.
# We need to respect this over the env var ROCM_PATH for this compilation.
sub get_rocm_path_option {
sub get_path_options {
my $rocm_path="";
my $hip_path="";
my @CLArgs = @ARGV;
foreach $arg (@CLArgs) {
if (index($arg,"--rocm-path=") != -1) {
($rocm_path) = $arg=~ /=\s*(.*)\s*$/;
next;
}
if (index($arg,"--hip-path=") != -1) {
($hip_path) = $arg=~ /=\s*(.*)\s*$/;
next;
}
}
return $rocm_path;
return ($rocm_path, $hip_path);
}

$verbose = $ENV{'HIPCC_VERBOSE'} // 0;
Expand Down Expand Up @@ -99,13 +105,16 @@ sub delete_temp_dirs {
}

my $base_dir;
my $rocmPath;
BEGIN {
$base_dir = dirname(Cwd::realpath(__FILE__) );
$rocmPath = get_rocm_path_option();
if ($rocmPath ne '') {
my ($rocm_path, $hip_path) = get_path_options();
if ($rocm_path ne '') {
# --rocm-path takes precedence over ENV{ROCM_PATH}
$ENV{ROCM_PATH}=$rocm_path;
}
if ($hip_path ne '') {
# --rocm-path takes precedence over ENV{ROCM_PATH}
$ENV{ROCM_PATH}=$rocmPath;
$ENV{HIP_PATH}=$hip_path;
}
}
use lib "$base_dir/";
Expand Down Expand Up @@ -566,6 +575,13 @@ BEGIN
}
}

# If the HIP_PATH env var is defined, pass that path to Clang
if ($ENV{'HIP_PATH'}) {
my $hip_path_flag = " --hip-path=\"$HIP_PATH\"";
$HIPCXXFLAGS .= $hip_path_flag;
$HIPLDFLAGS .= $hip_path_flag;
}

if ($hasHIP) {
if ($DEVICE_LIB_PATH ne "$ROCM_PATH/amdgcn/bitcode") {
$HIPCXXFLAGS .= " --hip-device-lib-path=\"$DEVICE_LIB_PATH\"";
Expand Down

0 comments on commit e63f21b

Please sign in to comment.