1// REQUIRES: clang-driver
2// REQUIRES: x86-registered-target
3// REQUIRES: amdgpu-registered-target
4
5// -fgpu-rdc link with output
6// RUN: touch %T/obj1.o
7// RUN: touch %T/obj2.o
8// RUN: %clang -### -target x86_64-linux-gnu -nogpulib -save-temps \
9// RUN:   --hip-link -o executable -fgpu-rdc --cuda-gpu-arch=gfx900 \
10// RUN:   --offload-arch=gfx906  %T/obj1.o %T/obj2.o 2>&1 | \
11// RUN:   FileCheck -check-prefixes=CHECK,OUT %s
12
13// -fgpu-rdc link without output
14// RUN: touch %T/obj1.o
15// RUN: touch %T/obj2.o
16// RUN: %clang -### -target x86_64-linux-gnu -nogpulib -save-temps \
17// RUN:   --hip-link -fgpu-rdc --cuda-gpu-arch=gfx900 \
18// RUN:   --offload-arch=gfx906  %T/obj1.o %T/obj2.o 2>&1 | \
19// RUN:   FileCheck -check-prefixes=CHECK,NOUT %s
20
21// -fgpu-rdc link with output and --emit-static-lib
22// RUN: touch %T/obj1.o
23// RUN: touch %T/obj2.o
24// RUN: %clang -### -target x86_64-linux-gnu -nogpulib -save-temps \
25// RUN:   --hip-link -o libTest.a -fgpu-rdc --cuda-gpu-arch=gfx900 \
26// RUN:   --emit-static-lib \
27// RUN:   --offload-arch=gfx906  %T/obj1.o %T/obj2.o 2>&1 | \
28// RUN:   FileCheck -check-prefixes=CHECK,SLO %s
29
30// -fgpu-rdc link without output and --emit-static-lib
31// RUN: touch %T/obj1.o
32// RUN: touch %T/obj2.o
33// RUN: %clang -### -target x86_64-linux-gnu -nogpulib -save-temps \
34// RUN:   --hip-link -fgpu-rdc --cuda-gpu-arch=gfx900 \
35// RUN:   --emit-static-lib \
36// RUN:   --offload-arch=gfx906  %T/obj1.o %T/obj2.o 2>&1 | \
37// RUN:   FileCheck -check-prefixes=CHECK,SLNO %s
38
39// CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} "-outputs=obj1-host-x86_64-unknown-linux-gnu.o,obj1-hip-amdgcn-amd-amdhsa-gfx900.o,obj1-hip-amdgcn-amd-amdhsa-gfx906.o" "-unbundle"
40// CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} "-outputs=obj2-host-x86_64-unknown-linux-gnu.o,obj2-hip-amdgcn-amd-amdhsa-gfx900.o,obj2-hip-amdgcn-amd-amdhsa-gfx906.o" "-unbundle"
41// CHECK-NOT: {{".*/llvm-link"}}
42// CHECK-NOT: {{".*/opt"}}
43// CHECK-NOT: {{".*/llc"}}
44// CHECK: "{{.*lld.*}}" {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
45// CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" "obj1-hip-amdgcn-amd-amdhsa-gfx900.o" "obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
46// CHECK: "{{.*lld.*}}" {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
47// CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx906" "obj1-hip-amdgcn-amd-amdhsa-gfx906.o" "obj2-hip-amdgcn-amd-amdhsa-gfx906.o"
48// CHECK: {{".*llvm-mc.*"}} "-o" "[[OBJBUNDLE:.*.o]]" "{{.*}}.mcin" "--filetype=obj"
49// OUT: "{{.*ld.*}}" {{.*}} "-o" "executable" {{.*}} "[[OBJBUNDLE]]"
50// NOUT: "{{.*ld.*}}" {{.*}} "-o" "a.out" {{.*}} "[[OBJBUNDLE]]"
51// SLO: "{{.*llvm-ar.*}}" "rcsD" "libTest.a" {{.*}} "[[OBJBUNDLE]]"
52// SLNO: "{{.*llvm-ar.*}}" "rcsD" "a.out" {{.*}} "[[OBJBUNDLE]]"
53