diff --git a/bin/hipcc.pl b/bin/hipcc.pl index 56dcda2..90e2333 100755 --- a/bin/hipcc.pl +++ b/bin/hipcc.pl @@ -155,20 +155,17 @@ BEGIN if($isWindows) { $execExtension = ".exe"; } - $HIPCC="$HIP_CLANG_PATH/clang++" . $execExtension; + $HIPCC="\"$HIP_CLANG_PATH/clang++" . $execExtension . "\""; # If $HIPCC clang++ is not compiled, use clang instead if ( ! -e $HIPCC ) { - $HIPCC="$HIP_CLANG_PATH/clang" . $execExtension; + $HIPCC="\"$HIP_CLANG_PATH/clang" . $execExtension . "\""; $HIPLDFLAGS = "--driver-mode=g++"; } # to avoid using dk linker or MSVC linker if($isWindows) { $HIPLDFLAGS .= " -fuse-ld=lld"; - $HIPLDFLAGS .= " --ld-path=$HIP_CLANG_PATH/lld-link.exe"; - - # escape possible spaces in path name - $HIPCC =~ s/\s/\\$&/g; + $HIPLDFLAGS .= " --ld-path=\"$HIP_CLANG_PATH/lld-link.exe\""; } # get Clang RT Builtin path @@ -204,12 +201,12 @@ BEGIN print ("CUDA_PATH=$CUDA_PATH\n"); } - $HIPCC="$CUDA_PATH/bin/nvcc"; + $HIPCC="\"$CUDA_PATH/bin/nvcc\""; $HIPCXXFLAGS .= " -Wno-deprecated-gpu-targets "; - $HIPCXXFLAGS .= " -isystem $CUDA_PATH/include"; - $HIPCFLAGS .= " -isystem $CUDA_PATH/include"; + $HIPCXXFLAGS .= " -isystem \"$CUDA_PATH/include\""; + $HIPCFLAGS .= " -isystem \"$CUDA_PATH/include\""; - $HIPLDFLAGS = " -Wno-deprecated-gpu-targets -lcuda -lcudart -L$CUDA_PATH/lib64"; + $HIPLDFLAGS = " -Wno-deprecated-gpu-targets -lcuda -lcudart -L\"$CUDA_PATH/lib64\""; } else { printf ("error: unknown HIP_PLATFORM = '$HIP_PLATFORM'"); printf (" or HIP_COMPILER = '$HIP_COMPILER'"); @@ -469,10 +466,7 @@ BEGIN 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; + $toolArgs .= " \"$arg\"" unless $swallowArg; $prevArg = $arg; } diff --git a/bin/hipvars.pm b/bin/hipvars.pm index 0bf8c69..c4b37d5 100644 --- a/bin/hipvars.pm +++ b/bin/hipvars.pm @@ -74,6 +74,10 @@ $isWindows = ($^O eq 'MSWin32' or $^O eq 'msys'); # ROCM_PATH is defined relative to HIP_PATH else it is hardcoded to /opt/rocm. # $HIP_PATH=$ENV{'HIP_PATH'} // dirname(Cwd::abs_path("$0/../")); # use parent directory of hipcc +if ($isWindows and defined $ENV{'HIP_PATH'}) { + $HIP_PATH =~ s/^"(.*)"$/$1/; + $HIP_PATH =~ s/\\/\//g; +} if (-e "$HIP_PATH/bin/rocm_agent_enumerator") { $ROCM_PATH=$ENV{'ROCM_PATH'} // "$HIP_PATH"; # use HIP_PATH }elsif (-e "$HIP_PATH/../bin/rocm_agent_enumerator") { # case for backward compatibility @@ -84,7 +88,7 @@ if (-e "$HIP_PATH/bin/rocm_agent_enumerator") { $CUDA_PATH=$ENV{'CUDA_PATH'} // '/usr/local/cuda'; # Windows/Distro's have a different structure, all binaries are with hipcc -if (-e "$HIP_PATH/bin/clang" or -e "$HIP_PATH/bin/clang.exe") { +if ($isWindows or -e "$HIP_PATH/bin/clang") { $HIP_CLANG_PATH=$ENV{'HIP_CLANG_PATH'} // "$HIP_PATH/bin"; } else { $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 } if (not defined $HIP_PLATFORM) { - if (can_run("$HIP_CLANG_PATH/clang++") or can_run("clang++")) { + if (can_run("\"$HIP_CLANG_PATH/clang++\"") or can_run("clang++")) { $HIP_PLATFORM = "amd"; } elsif (can_run("$CUDA_PATH/bin/nvcc") or can_run("nvcc")) { $HIP_PLATFORM = "nvidia";