Skip to content

Commit 5c9d0a2

Browse files
jhuber6Meinersbur
andauthored
[LinkerWrapper] Try to fix testing on Windows (#130285)
Summary: Thanks to @Meinersbur for finding this. The `:` character used in AMD's target-id's is invalid on windows. This patch replaces them with `-`. --------- Co-authored-by: Michael Kruse <[email protected]>
1 parent 99c6342 commit 5c9d0a2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

clang/test/Driver/linker-wrapper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ __attribute__((visibility("protected"), used)) int x;
119119

120120
// HIP: clang{{.*}} -o [[IMG_GFX90A:.+]] --target=amdgcn-amd-amdhsa -mcpu=gfx90a
121121
// HIP: clang{{.*}} -o [[IMG_GFX908:.+]] --target=amdgcn-amd-amdhsa -mcpu=gfx908
122-
// HIP: clang-offload-bundler{{.*}}-type=o -bundle-align=4096 -compress -compression-level=6 -targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa--gfx90a,hip-amdgcn-amd-amdhsa--gfx908 -input=/dev/null -input=[[IMG_GFX90A]] -input=[[IMG_GFX908]] -output={{.*}}.hipfb
122+
// HIP: clang-offload-bundler{{.*}}-type=o -bundle-align=4096 -compress -compression-level=6 -targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa--gfx90a,hip-amdgcn-amd-amdhsa--gfx908 -input={{/dev/null|NUL}} -input=[[IMG_GFX90A]] -input=[[IMG_GFX908]] -output={{.*}}.hipfb
123123

124124
// RUN: clang-offload-packager -o %t.out \
125125
// RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
@@ -210,7 +210,7 @@ __attribute__((visibility("protected"), used)) int x;
210210
// RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=RELOCATABLE-LINK-HIP
211211

212212
// RELOCATABLE-LINK-HIP: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa
213-
// RELOCATABLE-LINK-HIP: clang-offload-bundler{{.*}} -type=o -bundle-align=4096 -targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa--gfx90a -input=/dev/null -input={{.*}} -output={{.*}}
213+
// RELOCATABLE-LINK-HIP: clang-offload-bundler{{.*}} -type=o -bundle-align=4096 -targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa--gfx90a -input={{/dev/null|NUL}} -input={{.*}} -output={{.*}}
214214
// RELOCATABLE-LINK-HIP: /usr/bin/ld.lld{{.*}}-r
215215
// RELOCATABLE-LINK-HIP: llvm-objcopy{{.*}}a.out --remove-section .llvm.offloading
216216

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,9 +603,11 @@ Expected<StringRef> writeOffloadFile(const OffloadFile &File) {
603603

604604
StringRef Prefix =
605605
sys::path::stem(Binary.getMemoryBufferRef().getBufferIdentifier());
606-
607-
auto TempFileOrErr = createOutputFile(
608-
Prefix + "-" + Binary.getTriple() + "-" + Binary.getArch(), "o");
606+
SmallString<128> Filename;
607+
(Prefix + "-" + Binary.getTriple() + "-" + Binary.getArch())
608+
.toVector(Filename);
609+
llvm::replace(Filename, ':', '-');
610+
auto TempFileOrErr = createOutputFile(Filename, "o");
609611
if (!TempFileOrErr)
610612
return TempFileOrErr.takeError();
611613

0 commit comments

Comments
 (0)