search path logic updated for extractkernel SWDEV-230929

Change-Id: I48d6332502774485d7ced3fee065a74f15774500
This commit is contained in:
Dittakavi Satyanvesh
2020-05-08 07:09:20 -04:00
parent 507f6bb0c3
commit 83f0c4402e
2 changed files with 53 additions and 12 deletions
+20 -11
View File
@@ -34,26 +34,35 @@ defined $options{i} || die("input not specified");
$input_file = $options{i};
(-f $input_file) || die("can't find $input_file");
# derive HIP_PATH via env var or use parent directory of extractkernel
my $HIP_PATH=$ENV{'HIP_PATH'} // dirname(Cwd::abs_path("$0/../"));
my $HIP_COMPILER = `$HIP_PATH/bin/hipconfig --compiler`;
my $ROCM_PATH = `$HIP_PATH/bin/hipconfig --rocmpath`;
my $HIP_CLANG_PATH = `$HIP_PATH/bin/hipconfig --hipclangpath`;
# look for llvm-objdump and clang-offload-bundler
my $tools_path_prefix;
my $llvm_objdump;
my $clang_offload_bundler;
if (defined $ENV{'HCC_HOME'}) {
$tools_path_prefix = File::Spec->catfile($ENV{'HCC_HOME'}, "bin");
$llvm_objdump = File::Spec->catfile($tools_path_prefix, "llvm-objdump");
$clang_offload_bundler = File::Spec->catfile($tools_path_prefix, "clang-offload-bundler");
if (defined $HIP_COMPILER and $HIP_COMPILER eq "clang"){
# Search the path with respect to HIP_CLANG_PATH
$tools_path_prefix = $HIP_CLANG_PATH;
}
else {
$tools_path_prefix = dirname(realpath($0));
$llvm_objdump = File::Spec->catfile($tools_path_prefix, "llvm-objdump");
$clang_offload_bundler = File::Spec->catfile($tools_path_prefix, "clang-offload-bundler");
if (!(-f $llvm_objdump)) {
$tools_path_prefix = realpath($tools_path_prefix."/../../hcc/bin");
$llvm_objdump = File::Spec->catfile($tools_path_prefix, "llvm-objdump");
$clang_offload_bundler = File::Spec->catfile($tools_path_prefix, "clang-offload-bundler");
if (defined $HIP_COMPILER and $HIP_COMPILER eq "hcc") {
# Search the path with respect to HCC_HOME if it is set, else search in ROCM_PATH
if (defined $ENV{'HCC_HOME'}) {
$tools_path_prefix = File::Spec->catfile($ENV{'HCC_HOME'}, "bin");
}
else {
$tools_path_prefix = realpath($ROCM_PATH."/hcc/bin");
}
}
}
# Find llvm-objdump and clang-offload-bundler in the path set above
$llvm_objdump = File::Spec->catfile($tools_path_prefix, "llvm-objdump");
$clang_offload_bundler = File::Spec->catfile($tools_path_prefix, "clang-offload-bundler");
if (!(-f $llvm_objdump)) {
$llvm_objdump = which("llvm-objdump");