Author: Yaxun (Sam) Liu Date: 2020-11-15T08:11:05-05:00 New Revision: fb58142e00ad73c2e6bfd80452e5e9b080c81552
URL: https://github.com/llvm/llvm-project/commit/fb58142e00ad73c2e6bfd80452e5e9b080c81552 DIFF: https://github.com/llvm/llvm-project/commit/fb58142e00ad73c2e6bfd80452e5e9b080c81552.diff LOG: Fix temporary file name on Windows Bound arch may contain ':', which is invalid in Windows file names. This patch fixes that. Differential Revision: https://reviews.llvm.org/D91421 Added: clang/test/Driver/hip-windows-filename.hip Modified: clang/lib/Driver/Driver.cpp Removed: ################################################################################ diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index bcea01126e0d..5f4e7f271764 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -4692,9 +4692,16 @@ static bool HasPreprocessOutput(const Action &JA) { const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA, const char *BaseInput, - StringRef BoundArch, bool AtTopLevel, + StringRef OrigBoundArch, bool AtTopLevel, bool MultipleArchs, StringRef OffloadingPrefix) const { + std::string BoundArch = OrigBoundArch.str(); +#if defined(_WIN32) + // BoundArch may contains ':', which is invalid in file names on Windows, + // therefore replace it with '%'. + std::replace(BoundArch.begin(), BoundArch.end(), ':', '@'); +#endif + llvm::PrettyStackTraceString CrashInfo("Computing output path"); // Output to a user requested destination? if (AtTopLevel && !isa<DsymutilJobAction>(JA) && !isa<VerifyJobAction>(JA)) { diff --git a/clang/test/Driver/hip-windows-filename.hip b/clang/test/Driver/hip-windows-filename.hip new file mode 100644 index 000000000000..9244f16c378f --- /dev/null +++ b/clang/test/Driver/hip-windows-filename.hip @@ -0,0 +1,10 @@ +// REQUIRES: system-windows, clang-driver, amdgpu-registered-target + +// RUN: %clang -### -target x86_64-pc-windows-msvc \ +// RUN: -x hip \ +// RUN: --offload-arch=gfx908:xnack+ \ +// RUN: -nogpuinc -nogpulib -save-temps \ +// RUN: %s 2>&1 | FileCheck %s + +// CHECK: "-o" "hip-windows-filename-hip-amdgcn-amd-amdhsa-gfx908@xnack+.cui" +// CHECK-NOT: "-o" "hip-windows-filename-hip-amdgcn-amd-amdhsa-gfx908:xnack+.cui" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits