@@ -121,6 +121,7 @@ BEGIN
121
121
122
122
use hipvars;
123
123
$isWindows = $hipvars::isWindows ;
124
+ $doubleQuote = $hipvars::doubleQuote ;
124
125
$HIP_RUNTIME = $hipvars::HIP_RUNTIME ;
125
126
$HIP_PLATFORM = $hipvars::HIP_PLATFORM ;
126
127
$HIP_COMPILER = $hipvars::HIP_COMPILER ;
@@ -131,6 +132,10 @@ BEGIN
131
132
$HIP_VERSION = $hipvars::HIP_VERSION ;
132
133
$HIP_ROCCLR_HOME = $hipvars::HIP_ROCCLR_HOME ;
133
134
135
+ sub get_normalized_path {
136
+ return $doubleQuote . $_ [0] . $doubleQuote ;
137
+ }
138
+
134
139
if ($HIP_PLATFORM eq " amd" ) {
135
140
$HIP_INCLUDE_PATH = " $HIP_ROCCLR_HOME /include" ;
136
141
if (!defined $HIP_LIB_PATH ) {
@@ -155,17 +160,17 @@ BEGIN
155
160
if ($isWindows ) {
156
161
$execExtension = " .exe" ;
157
162
}
158
- $HIPCC =" \" $HIP_CLANG_PATH /clang++" . $execExtension . " \" " ;
163
+ $HIPCC =get_normalized_path( " $HIP_CLANG_PATH /clang++" . $execExtension ) ;
159
164
160
165
# If $HIPCC clang++ is not compiled, use clang instead
161
166
if ( ! -e $HIPCC ) {
162
- $HIPCC =" \" $HIP_CLANG_PATH /clang" . $execExtension . " \" " ;
167
+ $HIPCC =get_normalized_path( " $HIP_CLANG_PATH /clang" . $execExtension ) ;
163
168
$HIPLDFLAGS = " --driver-mode=g++" ;
164
169
}
165
170
# to avoid using dk linker or MSVC linker
166
171
if ($isWindows ) {
167
172
$HIPLDFLAGS .= " -fuse-ld=lld" ;
168
- $HIPLDFLAGS .= " --ld-path=\" $HIP_CLANG_PATH /lld-link.exe\" " ;
173
+ $HIPLDFLAGS .= " --ld-path=" . get_normalized_path( " $HIP_CLANG_PATH /lld-link.exe" ) ;
169
174
}
170
175
171
176
# get Clang RT Builtin path
@@ -201,21 +206,21 @@ BEGIN
201
206
print (" CUDA_PATH=$CUDA_PATH \n " );
202
207
}
203
208
204
- $HIPCC =" \" $CUDA_PATH /bin/nvcc\" " ;
209
+ $HIPCC =get_normalized_path( " $CUDA_PATH /bin/nvcc" ) ;
205
210
$HIPCXXFLAGS .= " -Wno-deprecated-gpu-targets " ;
206
- $HIPCXXFLAGS .= " -isystem \" $CUDA_PATH /include\" " ;
207
- $HIPCFLAGS .= " -isystem \" $CUDA_PATH /include\" " ;
211
+ $HIPCXXFLAGS .= " -isystem " . get_normalized_path( " $CUDA_PATH /include" ) ;
212
+ $HIPCFLAGS .= " -isystem " . get_normalized_path( " $CUDA_PATH /include" ) ;
208
213
209
- $HIPLDFLAGS = " -Wno-deprecated-gpu-targets -lcuda -lcudart -L\" $CUDA_PATH /lib64\" " ;
214
+ $HIPLDFLAGS = " -Wno-deprecated-gpu-targets -lcuda -lcudart -L" . get_normalized_path( " $CUDA_PATH /lib64" ) ;
210
215
} else {
211
216
printf (" error: unknown HIP_PLATFORM = '$HIP_PLATFORM '" );
212
217
printf (" or HIP_COMPILER = '$HIP_COMPILER '" );
213
218
exit (-1);
214
219
}
215
220
216
221
# Add paths to common HIP includes:
217
- $HIPCXXFLAGS .= " -isystem \" $HIP_INCLUDE_PATH \" " ;
218
- $HIPCFLAGS .= " -isystem \" $HIP_INCLUDE_PATH \" " ;
222
+ $HIPCXXFLAGS .= " -isystem " . get_normalized_path( " $HIP_INCLUDE_PATH " ) ;
223
+ $HIPCFLAGS .= " -isystem " . get_normalized_path( " $HIP_INCLUDE_PATH " ) ;
219
224
220
225
my $compileOnly = 0;
221
226
my $needCXXFLAGS = 0; # need to add CXX flags to compile step
@@ -294,7 +299,7 @@ BEGIN
294
299
295
300
if ($skipOutputFile ) {
296
301
# TODO: handle filename with shell metacharacters
297
- $toolArgs .= " \" $arg \" " ;
302
+ $toolArgs .= " " . get_normalized_path( " $arg " ) ;
298
303
$prevArg = $arg ;
299
304
$skipOutputFile = 0;
300
305
next ;
@@ -466,7 +471,7 @@ BEGIN
466
471
if (not $isWindows and $escapeArg ) {
467
472
$arg =~ s / [^-a-zA-Z0-9_=+,.\/ ]/ \\ $& / g ;
468
473
}
469
- $toolArgs .= " \" $arg \" " unless $swallowArg ;
474
+ $toolArgs .= " $arg " unless $swallowArg ;
470
475
$prevArg = $arg ;
471
476
}
472
477
@@ -561,14 +566,14 @@ BEGIN
561
566
562
567
# If the HIP_PATH env var is defined, pass that path to Clang
563
568
if ($ENV {' HIP_PATH' }) {
564
- my $hip_path_flag = " --hip-path=\" $HIP_PATH \" " ;
569
+ my $hip_path_flag = " --hip-path=" . get_normalized_path( " $HIP_PATH " ) ;
565
570
$HIPCXXFLAGS .= $hip_path_flag ;
566
571
$HIPLDFLAGS .= $hip_path_flag ;
567
572
}
568
573
569
574
if ($hasHIP ) {
570
575
if (defined $DEVICE_LIB_PATH ) {
571
- $HIPCXXFLAGS .= " --hip-device-lib-path=\" $DEVICE_LIB_PATH \" " ;
576
+ $HIPCXXFLAGS .= " --hip-device-lib-path=" . get_normalized_path( " $DEVICE_LIB_PATH " ) ;
572
577
}
573
578
}
574
579
0 commit comments