Skip to content

Commit

Permalink
Fix temporary file name on Windows
Browse files Browse the repository at this point in the history
Bound arch may contain ':', which is invalid in Windows file names.

This patch fixes that.

Differential Revision: https://reviews.llvm.org/D91421
  • Loading branch information
yxsamliu committed Nov 15, 2020
1 parent 5e373b2 commit fb58142
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion clang/lib/Driver/Driver.cpp
Expand Up @@ -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)) {
Expand Down
10 changes: 10 additions & 0 deletions 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"

0 comments on commit fb58142

Please sign in to comment.