From 4900ce120ef18ce2ebed0953542141a3d54a5b29 Mon Sep 17 00:00:00 2001 From: ROCm CI Service Account <66695075+rocm-ci@users.noreply.github.com> Date: Fri, 17 Jun 2022 11:02:17 +0530 Subject: [PATCH] SWDEV-341955 - Windows hipcc perl to handle quoted args (#2746) example - hipcc.pl -DGREETING=\"Hello\" hello.cpp Change-Id: Ib7192d46226563a44c87f3fbe2c22ef2ab84ac3e --- bin/hipcc | 8 +++++++- bin/hipcc.pl | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/hipcc b/bin/hipcc index 32494dd345..86622c7a36 100755 --- a/bin/hipcc +++ b/bin/hipcc @@ -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,6 +29,13 @@ use File::Spec::Functions 'catfile'; # TODO: By default select perl script until change incorporated in HIP build script. my $HIPCC_USE_PERL_SCRIPT = 1; +my $isWindows = ($^O eq 'MSWin32' or $^O eq 'msys'); +# escapes args with quotes SWDEV-341955 +foreach $arg (@ARGV) { + if ($isWindows) { + $arg =~ s/[^-a-zA-Z0-9_=+,.:\/\\]/\\$&/g; + } +} my $SCRIPT_DIR=dirname(__FILE__); if ($HIPCC_USE_PERL_SCRIPT) { diff --git a/bin/hipcc.pl b/bin/hipcc.pl index 24edf7c59c..645ae62d03 100755 --- a/bin/hipcc.pl +++ b/bin/hipcc.pl @@ -595,9 +595,12 @@ foreach $arg (@ARGV) # common characters such as alphanumerics. # Do the quoting here because sometimes the $arg is changed in the loop # Important to have all of '-Xlinker' in the set of unquoted characters. - if (not $isWindows and $escapeArg) { # Windows needs different quoting, ignore for now + if (not $isWindows and $escapeArg) { $arg =~ s/[^-a-zA-Z0-9_=+,.\/]/\\$&/g; } + if ($isWindows and $escapeArg) { + $arg =~ s/[^-a-zA-Z0-9_=+,.:\/\\]/\\$&/g; + } $toolArgs .= " $arg" unless $swallowArg; $prevArg = $arg; }