From 9af24c0aed00387ec584f2b885050aa4f46f9330 Mon Sep 17 00:00:00 2001 From: ROCm CI Service Account <66695075+rocm-ci@users.noreply.github.com> Date: Wed, 22 Jun 2022 09:42:16 +0530 Subject: [PATCH] SWDEV-335967 - hipcc fixes for return value and blocking call (#2752) Change-Id: I8caade13dac2c3cfd540bd683bd46eafb91111c2 --- bin/hipcc | 28 ++++++++++++++++++++++++---- bin/hipcc.bat | 2 +- bin/hipconfig | 31 +++++++++++++++++++++++++------ bin/hipconfig.bat | 2 +- 4 files changed, 51 insertions(+), 12 deletions(-) diff --git a/bin/hipcc b/bin/hipcc index 86622c7a36..62191ffa4e 100755 --- a/bin/hipcc +++ b/bin/hipcc @@ -38,16 +38,36 @@ foreach $arg (@ARGV) { } my $SCRIPT_DIR=dirname(__FILE__); + if ($HIPCC_USE_PERL_SCRIPT) { #Invoke hipcc.pl my $HIPCC_PERL=catfile($SCRIPT_DIR, '/hipcc.pl'); - exec($^X, $HIPCC_PERL, @ARGV); + system($^X, $HIPCC_PERL, @ARGV); } else { - #Invoke hipcc.bin - my $HIPCC_BIN=catfile($SCRIPT_DIR, '/hipcc.bin'); + $BIN_NAME="/hipcc.bin"; + if ($isWindows) { + $BIN_NAME="/hipcc.bin.exe"; + } + my $HIPCC_BIN=catfile($SCRIPT_DIR, $BIN_NAME); if ( -e $HIPCC_BIN ) { - exec($HIPCC_BIN, @ARGV); + #Invoke hipcc.bin + system($HIPCC_BIN, @ARGV); } else { print "hipcc.bin not present; Install HIPCC binaries before proceeding"; + exit(-1); } } + +# Because of this wrapper we need to check +# the output of the system command for perl and bin +# else the failures are ignored and build fails silently +if ($? == -1) { + exit($?); +} +elsif ($? & 127) { + exit($?); +} +else { + $CMD_EXIT_CODE = $? >> 8; +} +exit($CMD_EXIT_CODE); diff --git a/bin/hipcc.bat b/bin/hipcc.bat index 9aa0e9628f..beb67966cd 100644 --- a/bin/hipcc.bat +++ b/bin/hipcc.bat @@ -1,2 +1,2 @@ -@set HIPCC="%~dp0/hipcc" +@set HIPCC="%~dp0hipcc" @perl %HIPCC% %* diff --git a/bin/hipconfig b/bin/hipconfig index 8ed1ba6f10..6bb4f892f8 100755 --- a/bin/hipconfig +++ b/bin/hipconfig @@ -22,7 +22,6 @@ # Need perl > 5.10 to use logic-defined or use 5.006; use v5.10.1; -use strict; use warnings; use File::Basename; @@ -30,18 +29,38 @@ use File::Spec::Functions 'catfile'; #TODO: By default select perl script until change incorporated in HIP build script my $HIPCONFIG_USE_PERL_SCRIPT = 1; - +my $isWindows = ($^O eq 'MSWin32' or $^O eq 'msys'); my $SCRIPT_DIR=dirname(__FILE__); + if ($HIPCONFIG_USE_PERL_SCRIPT) { #Invoke hipconfig.pl my $HIPCONFIG_PERL=catfile($SCRIPT_DIR, '/hipconfig.pl'); - exec($^X, $HIPCONFIG_PERL, @ARGV); + system($^X, $HIPCONFIG_PERL, @ARGV); } else { - #Invoke hipconfig.bin - my $HIPCONFIG_BIN=catfile($SCRIPT_DIR, '/hipconfig.bin'); + $BIN_NAME="/hipconfig.bin"; + if ($isWindows) { + $BIN_NAME="/hipconfig.bin.exe"; + } + my $HIPCONFIG_BIN=catfile($SCRIPT_DIR, $BIN_NAME); if ( -e $HIPCONFIG_BIN ) { - exec($HIPCONFIG_BIN, @ARGV); + #Invoke hipconfig.bin + system($HIPCONFIG_BIN, @ARGV); } else { print "hipconfig.bin not present; Install HIPCC binaries before proceeding"; + exit(-1); } } + +# Because of this wrapper we need to check +# the output of the system command for perl and bin +# else the failures are ignored and build fails silently +if ($? == -1) { + exit($?); +} +elsif ($? & 127) { + exit($?); +} +else { + $CMD_EXIT_CODE = $? >> 8; +} +exit($CMD_EXIT_CODE); diff --git a/bin/hipconfig.bat b/bin/hipconfig.bat index d58c634ef8..16e68a14b7 100644 --- a/bin/hipconfig.bat +++ b/bin/hipconfig.bat @@ -1,2 +1,2 @@ -@set HIPCONFIG="%~dp0/hipconfig" +@set HIPCONFIG="%~dp0hipconfig" @perl %HIPCONFIG% %*