From dd539e475dab3513732aa2f0488a76ffe95a8df5 Mon Sep 17 00:00:00 2001 From: ROCm CI Service Account <66695075+rocm-ci@users.noreply.github.com> Date: Wed, 8 Mar 2023 01:08:53 +0530 Subject: [PATCH] SWDEV-385406 - [hipcc] Pass HIP_PATH to clang (#3174) 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 [ROCm/hip commit: 3fb0920a55f780abac15b21f482df97894105148] --- projects/hip/bin/hipcc.pl | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/projects/hip/bin/hipcc.pl b/projects/hip/bin/hipcc.pl index 739e34b1cf..56dcda2d59 100644 --- a/projects/hip/bin/hipcc.pl +++ b/projects/hip/bin/hipcc.pl @@ -52,15 +52,21 @@ if(scalar @ARGV == 0){ # 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; @@ -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}=$rocmPath; + $ENV{ROCM_PATH}=$rocm_path; + } + if ($hip_path ne '') { + # --rocm-path takes precedence over ENV{ROCM_PATH} + $ENV{HIP_PATH}=$hip_path; } } use lib "$base_dir/"; @@ -556,6 +565,13 @@ if ($HIP_PLATFORM eq "amd") { } } + # 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 (defined $DEVICE_LIB_PATH) { $HIPCXXFLAGS .= " --hip-device-lib-path=\"$DEVICE_LIB_PATH\"";