Skip to content

Commit ecda567

Browse files
authored
Merge pull request #108 from ROCm-Developer-Tools/amd/dev/kzhuravl/SWDEV-409068
SWDEV-409068 - Fix paths with spaces in it
2 parents e1491f6 + ea296b3 commit ecda567

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

amd/hipcc/bin/hipcc.pl

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,17 @@ BEGIN
155155
if($isWindows) {
156156
$execExtension = ".exe";
157157
}
158-
$HIPCC="$HIP_CLANG_PATH/clang++" . $execExtension;
158+
$HIPCC="\"$HIP_CLANG_PATH/clang++" . $execExtension . "\"";
159159

160160
# If $HIPCC clang++ is not compiled, use clang instead
161161
if ( ! -e $HIPCC ) {
162-
$HIPCC="$HIP_CLANG_PATH/clang" . $execExtension;
162+
$HIPCC="\"$HIP_CLANG_PATH/clang" . $execExtension . "\"";
163163
$HIPLDFLAGS = "--driver-mode=g++";
164164
}
165165
# to avoid using dk linker or MSVC linker
166166
if($isWindows) {
167167
$HIPLDFLAGS .= " -fuse-ld=lld";
168-
$HIPLDFLAGS .= " --ld-path=$HIP_CLANG_PATH/lld-link.exe";
169-
170-
# escape possible spaces in path name
171-
$HIPCC =~ s/\s/\\$&/g;
168+
$HIPLDFLAGS .= " --ld-path=\"$HIP_CLANG_PATH/lld-link.exe\"";
172169
}
173170

174171
# get Clang RT Builtin path
@@ -204,12 +201,12 @@ BEGIN
204201
print ("CUDA_PATH=$CUDA_PATH\n");
205202
}
206203

207-
$HIPCC="$CUDA_PATH/bin/nvcc";
204+
$HIPCC="\"$CUDA_PATH/bin/nvcc\"";
208205
$HIPCXXFLAGS .= " -Wno-deprecated-gpu-targets ";
209-
$HIPCXXFLAGS .= " -isystem $CUDA_PATH/include";
210-
$HIPCFLAGS .= " -isystem $CUDA_PATH/include";
206+
$HIPCXXFLAGS .= " -isystem \"$CUDA_PATH/include\"";
207+
$HIPCFLAGS .= " -isystem \"$CUDA_PATH/include\"";
211208

212-
$HIPLDFLAGS = " -Wno-deprecated-gpu-targets -lcuda -lcudart -L$CUDA_PATH/lib64";
209+
$HIPLDFLAGS = " -Wno-deprecated-gpu-targets -lcuda -lcudart -L\"$CUDA_PATH/lib64\"";
213210
} else {
214211
printf ("error: unknown HIP_PLATFORM = '$HIP_PLATFORM'");
215212
printf (" or HIP_COMPILER = '$HIP_COMPILER'");
@@ -469,10 +466,7 @@ BEGIN
469466
if (not $isWindows and $escapeArg) {
470467
$arg =~ s/[^-a-zA-Z0-9_=+,.\/]/\\$&/g;
471468
}
472-
if ($isWindows and $escapeArg) {
473-
$arg =~ s/[^-a-zA-Z0-9_=+,.:\/\\]/\\$&/g;
474-
}
475-
$toolArgs .= " $arg" unless $swallowArg;
469+
$toolArgs .= " \"$arg\"" unless $swallowArg;
476470
$prevArg = $arg;
477471
}
478472

amd/hipcc/bin/hipvars.pm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ $isWindows = ($^O eq 'MSWin32' or $^O eq 'msys');
7474
# ROCM_PATH is defined relative to HIP_PATH else it is hardcoded to /opt/rocm.
7575
#
7676
$HIP_PATH=$ENV{'HIP_PATH'} // dirname(Cwd::abs_path("$0/../")); # use parent directory of hipcc
77+
if ($isWindows and defined $ENV{'HIP_PATH'}) {
78+
$HIP_PATH =~ s/^"(.*)"$/$1/;
79+
$HIP_PATH =~ s/\\/\//g;
80+
}
7781
if (-e "$HIP_PATH/bin/rocm_agent_enumerator") {
7882
$ROCM_PATH=$ENV{'ROCM_PATH'} // "$HIP_PATH"; # use HIP_PATH
7983
}elsif (-e "$HIP_PATH/../bin/rocm_agent_enumerator") { # case for backward compatibility
@@ -84,7 +88,7 @@ if (-e "$HIP_PATH/bin/rocm_agent_enumerator") {
8488
$CUDA_PATH=$ENV{'CUDA_PATH'} // '/usr/local/cuda';
8589

8690
# Windows/Distro's have a different structure, all binaries are with hipcc
87-
if (-e "$HIP_PATH/bin/clang" or -e "$HIP_PATH/bin/clang.exe") {
91+
if ($isWindows or -e "$HIP_PATH/bin/clang") {
8892
$HIP_CLANG_PATH=$ENV{'HIP_CLANG_PATH'} // "$HIP_PATH/bin";
8993
} else {
9094
$HIP_CLANG_PATH=$ENV{'HIP_CLANG_PATH'} // "$ROCM_PATH/llvm/bin";
@@ -120,7 +124,7 @@ if (defined $HIP_RUNTIME and $HIP_RUNTIME eq "rocclr" and !defined $HIP_ROCCLR_H
120124
}
121125

122126
if (not defined $HIP_PLATFORM) {
123-
if (can_run("$HIP_CLANG_PATH/clang++") or can_run("clang++")) {
127+
if (can_run("\"$HIP_CLANG_PATH/clang++\"") or can_run("clang++")) {
124128
$HIP_PLATFORM = "amd";
125129
} elsif (can_run("$CUDA_PATH/bin/nvcc") or can_run("nvcc")) {
126130
$HIP_PLATFORM = "nvidia";

0 commit comments

Comments
 (0)