Skip to content

Commit 835f196

Browse files
shiltianjharryma
authored andcommitted
[Clang] Use -targets=host-x86_64-unknown-linux-gnu as bundler target (llvm#122627)
This a prime patch to support generic target when using `--offload-compress`. (cherry picked from commit 0d352b2)
1 parent ba32690 commit 835f196

File tree

7 files changed

+44
-44
lines changed

7 files changed

+44
-44
lines changed

clang/lib/Driver/ToolChains/HIPUtility.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ void HIP::constructHIPFatbinCommand(Compilation &C, const JobAction &JA,
292292

293293
// ToDo: Remove the dummy host binary entry which is required by
294294
// clang-offload-bundler.
295-
std::string BundlerTargetArg = "-targets=host-x86_64-unknown-linux";
295+
std::string BundlerTargetArg = "-targets=host-x86_64-unknown-linux-gnu";
296296
// AMDGCN:
297297
// For code object version 2 and 3, the offload kind in bundle ID is 'hip'
298298
// for backward compatibility. For code object version 4 and greater, the

clang/test/Driver/cuda-arch-translation.cu

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -68,33 +68,33 @@
6868

6969
// HIP: clang-offload-bundler
7070

71-
// SM20:--image=profile=sm_20{{.*}}--image=profile=compute_20
72-
// SM21:--image=profile=sm_21{{.*}}--image=profile=compute_20
73-
// SM30:--image=profile=sm_30{{.*}}--image=profile=compute_30
74-
// SM32:--image=profile=sm_32{{.*}}--image=profile=compute_32
75-
// SM35:--image=profile=sm_35{{.*}}--image=profile=compute_35
76-
// SM37:--image=profile=sm_37{{.*}}--image=profile=compute_37
77-
// SM50:--image=profile=sm_50{{.*}}--image=profile=compute_50
78-
// SM52:--image=profile=sm_52{{.*}}--image=profile=compute_52
79-
// SM53:--image=profile=sm_53{{.*}}--image=profile=compute_53
80-
// SM60:--image=profile=sm_60{{.*}}--image=profile=compute_60
81-
// SM61:--image=profile=sm_61{{.*}}--image=profile=compute_61
82-
// SM62:--image=profile=sm_62{{.*}}--image=profile=compute_62
83-
// SM70:--image=profile=sm_70{{.*}}--image=profile=compute_70
84-
// GFX600:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx600
85-
// GFX601:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx601
86-
// GFX602:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx602
87-
// GFX700:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx700
88-
// GFX701:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx701
89-
// GFX702:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx702
90-
// GFX703:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx703
91-
// GFX704:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx704
92-
// GFX705:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx705
93-
// GFX801:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx801
94-
// GFX802:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx802
95-
// GFX803:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx803
96-
// GFX805:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx805
97-
// GFX810:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx810
98-
// GFX900:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx900
99-
// GFX902:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx902
100-
// SPIRV:-targets=host-x86_64-unknown-linux,hip-spirv64-amd-amdhsa--amdgcnspirv
71+
// SM20:--image=profile=sm_20{{.*}}
72+
// SM21:--image=profile=sm_21{{.*}}
73+
// SM30:--image=profile=sm_30{{.*}}
74+
// SM32:--image=profile=sm_32{{.*}}
75+
// SM35:--image=profile=sm_35{{.*}}
76+
// SM37:--image=profile=sm_37{{.*}}
77+
// SM50:--image=profile=sm_50{{.*}}
78+
// SM52:--image=profile=sm_52{{.*}}
79+
// SM53:--image=profile=sm_53{{.*}}
80+
// SM60:--image=profile=sm_60{{.*}}
81+
// SM61:--image=profile=sm_61{{.*}}
82+
// SM62:--image=profile=sm_62{{.*}}
83+
// SM70:--image=profile=sm_70{{.*}}
84+
// GFX600:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx600
85+
// GFX601:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx601
86+
// GFX602:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx602
87+
// GFX700:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx700
88+
// GFX701:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx701
89+
// GFX702:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx702
90+
// GFX703:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx703
91+
// GFX704:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx704
92+
// GFX705:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx705
93+
// GFX801:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx801
94+
// GFX802:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx802
95+
// GFX803:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx803
96+
// GFX805:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx805
97+
// GFX810:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx810
98+
// GFX900:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx900
99+
// GFX902:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx902
100+
// SPIRV:-targets=host-x86_64-unknown-linux-gnu,hip-spirv64-amd-amdhsa--amdgcnspirv

clang/test/Driver/hip-code-object-version.hip

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
// V4: "-mcode-object-version=4"
99
// V4: "-mllvm" "--amdhsa-code-object-version=4"
10-
// V4: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx906"
10+
// V4: "-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx906"
1111

1212
// Check bundle ID for code object version 5.
1313

@@ -18,7 +18,7 @@
1818

1919
// V5: "-mcode-object-version=5"
2020
// V5: "-mllvm" "--amdhsa-code-object-version=5"
21-
// V5: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx906"
21+
// V5: "-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx906"
2222

2323
// Check bundle ID for code object version 6.
2424

@@ -29,7 +29,7 @@
2929

3030
// V6: "-mcode-object-version=6"
3131
// V6: "-mllvm" "--amdhsa-code-object-version=6"
32-
// V6: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx906"
32+
// V6: "-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx906"
3333

3434

3535
// Check bundle ID for code object version default
@@ -38,7 +38,7 @@
3838
// RUN: --offload-arch=gfx906 -nogpuinc -nogpulib \
3939
// RUN: %s 2>&1 | FileCheck -check-prefix=VD %s
4040

41-
// VD: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx906"
41+
// VD: "-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx906"
4242

4343
// Check invalid code object version option.
4444

clang/test/Driver/hip-target-id.hip

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
// CHECK-SAME: "-plugin-opt=-mattr=-sramecc,+xnack"
4444

4545
// CHECK: {{"[^"]*clang-offload-bundler[^"]*"}}
46-
// CHECK-SAME: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx908:sramecc+:xnack+,hipv4-amdgcn-amd-amdhsa--gfx908:sramecc-:xnack+"
46+
// CHECK-SAME: "-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx908:sramecc+:xnack+,hipv4-amdgcn-amd-amdhsa--gfx908:sramecc-:xnack+"
4747

4848
// Check canonicalization and repeating of target ID.
4949

@@ -54,7 +54,7 @@
5454
// RUN: --offload-arch=fiji \
5555
// RUN: --no-offload-new-driver --rocm-path=%S/Inputs/rocm \
5656
// RUN: %s 2>&1 | FileCheck -check-prefix=FIJI %s
57-
// FIJI: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx803"
57+
// FIJI: "-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx803"
5858

5959
// RUN: not %clang -### --target=x86_64-linux-gnu \
6060
// RUN: -x hip \
@@ -65,4 +65,4 @@
6565
// RUN: --offload-arch=gfx906 \
6666
// RUN: --no-offload-new-driver --rocm-path=%S/Inputs/rocm \
6767
// RUN: %s 2>&1 | FileCheck -check-prefix=MULTI %s
68-
// MULTI: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx900:xnack+,hipv4-amdgcn-amd-amdhsa--gfx900:xnack-,hipv4-amdgcn-amd-amdhsa--gfx906,hipv4-amdgcn-amd-amdhsa--gfx908:sramecc+,hipv4-amdgcn-amd-amdhsa--gfx908:sramecc-"
68+
// MULTI: "-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx900:xnack+,hipv4-amdgcn-amd-amdhsa--gfx900:xnack-,hipv4-amdgcn-amd-amdhsa--gfx906,hipv4-amdgcn-amd-amdhsa--gfx908:sramecc+,hipv4-amdgcn-amd-amdhsa--gfx908:sramecc-"

clang/test/Driver/hipspv-toolchain.hip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// CHECK-SAME: [[LOWER_BC]] "-o" "[[SPIRV_OUT:.*out]]"
2525

2626
// CHECK: {{".*clang-offload-bundler"}} "-type=o" "-bundle-align=4096"
27-
// CHECK-SAME: "-targets=host-x86_64-unknown-linux,hip-spirv64----generic"
27+
// CHECK-SAME: "-targets=host-x86_64-unknown-linux-gnu,hip-spirv64----generic"
2828
// CHECK-SAME: "-input={{.*}}" "-input=[[SPIRV_OUT]]" "-output=[[BUNDLE:.*hipfb]]"
2929

3030
// CHECK: [[CLANG]] "-cc1" "-triple" {{".*"}} "-aux-triple" "spirv64"

clang/test/Driver/linker-wrapper.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ __attribute__((visibility("protected"), used)) int x;
2929
// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run --device-debug -O0 \
3030
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=NVPTX-LINK-DEBUG
3131

32-
// NVPTX-LINK-DEBUG: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_70 -O2 {{.*}}.o {{.*}}.o -g
32+
// NVPTX-LINK-DEBUG: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_70 -O2 -flto {{.*}}.o {{.*}}.o -g
3333

3434
// RUN: clang-offload-packager -o %t.out \
3535
// RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
@@ -92,7 +92,7 @@ __attribute__((visibility("protected"), used)) int x;
9292

9393
// CUDA: clang{{.*}} -o [[IMG_SM70:.+]] --target=nvptx64-nvidia-cuda -march=sm_70
9494
// CUDA: clang{{.*}} -o [[IMG_SM52:.+]] --target=nvptx64-nvidia-cuda -march=sm_52
95-
// CUDA: fatbinary{{.*}}-64 --create {{.*}}.fatbin --image=profile=sm_70,file=[[IMG_SM70]] --image=profile=sm_52,file=[[IMG_SM52]]
95+
// CUDA: fatbinary{{.*}}-64 --create {{.*}}.fatbin --image=profile=sm_70,file=[[IMG_SM70]] --image=profile=sm_52,file=[[IMG_SM52]]
9696
// CUDA: usr/bin/ld{{.*}} {{.*}}.openmp.image.{{.*}}.o {{.*}}.cuda.image.{{.*}}.o
9797

9898
// RUN: clang-offload-packager -o %t.out \
@@ -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,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 -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 \
@@ -209,7 +209,7 @@ __attribute__((visibility("protected"), used)) int x;
209209
// RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=RELOCATABLE-LINK-HIP
210210

211211
// RELOCATABLE-LINK-HIP: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa
212-
// RELOCATABLE-LINK-HIP: clang-offload-bundler{{.*}} -type=o -bundle-align=4096 -targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx90a -input=/dev/null -input={{.*}} -output={{.*}}
212+
// 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={{.*}}
213213
// RELOCATABLE-LINK-HIP: /usr/bin/ld.lld{{.*}}-r
214214
// RELOCATABLE-LINK-HIP: llvm-objcopy{{.*}}a.out --remove-section .llvm.offloading
215215

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ fatbinary(ArrayRef<std::pair<StringRef, StringRef>> InputFiles,
461461
CmdArgs.push_back(
462462
Args.MakeArgString(Twine("-compression-level=") + Arg->getValue()));
463463

464-
SmallVector<StringRef> Targets = {"-targets=host-x86_64-unknown-linux"};
464+
SmallVector<StringRef> Targets = {"-targets=host-x86_64-unknown-linux-gnu"};
465465
for (const auto &[File, Arch] : InputFiles)
466466
Targets.push_back(Saver.save("hip-amdgcn-amd-amdhsa--" + Arch));
467467
CmdArgs.push_back(Saver.save(llvm::join(Targets, ",")));

0 commit comments

Comments
 (0)