xref: /llvm-project/clang/test/Driver/hip-link-bundle-archive.hip (revision 12949c952c4fbad776a860c003ccf176973278a0)
1// Check clang unbundle the archive and link them by lld.
2// If there is a directory which has the same name as the
3// value of the '-l' option, it should not interfere with
4// the discovery and unbundling of the archive.
5
6// RUN: rm -rf %t hipBundled && mkdir %t hipBundled
7// RUN: touch %t/dummy.bc
8// RUN: llvm-ar cr %t/libhipBundled.a %t/dummy.bc
9// RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
10// RUN:   --no-offload-new-driver --target=x86_64-unknown-linux-gnu \
11// RUN:   -nogpuinc -nogpulib %s -fgpu-rdc -L%t -lhipBundled \
12// RUN:   2>&1 | FileCheck -check-prefixes=GNU,GNU1,GNU-L %s
13
14// RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 -nogpuinc \
15// RUN:   --no-offload-new-driver --target=x86_64-unknown-linux-gnu \
16// RUN:   -nogpuinc -nogpulib %s -fgpu-rdc -L%t -l:libhipBundled.a \
17// RUN:   2>&1 | FileCheck -check-prefixes=GNU,GNU1,GNU-LA %s
18
19// RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
20// RUN:   --no-offload-new-driver --target=x86_64-unknown-linux-gnu \
21// RUN:   -nogpuinc -nogpulib %s -fgpu-rdc %t/libhipBundled.a \
22// RUN:   2>&1 | FileCheck -check-prefixes=GNU,GNU1,GNU-A %s
23
24// RUN: llvm-ar cr %t/libhipBundled.a.5.2 %t/dummy.bc
25// RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
26// RUN:   --no-offload-new-driver --target=x86_64-unknown-linux-gnu \
27// RUN:   -nogpuinc -nogpulib %s -fgpu-rdc %t/libhipBundled.a.5.2 \
28// RUN:   2>&1 | FileCheck -check-prefixes=GNU,GNU2,GNU-A %s
29
30// Check if a file is not an archive, it is not unbundled.
31
32// RUN: touch %t/libNonArchive.a
33// RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
34// RUN:   --no-offload-new-driver --target=x86_64-unknown-linux-gnu \
35// RUN:   -nogpuinc -nogpulib %s -fgpu-rdc -L%t -lNonArchive \
36// RUN:   2>&1 | FileCheck -check-prefixes=NONARCHIVE %s
37// RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
38// RUN:   --no-offload-new-driver --target=x86_64-unknown-linux-gnu \
39// RUN:   -nogpuinc -nogpulib %s -fgpu-rdc -L%t -l:libNonArchive.a \
40// RUN:   2>&1 | FileCheck -check-prefixes=NONARCHIVE %s
41// RUN: not %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
42// RUN:   --no-offload-new-driver --target=x86_64-unknown-linux-gnu \
43// RUN:   -nogpuinc -nogpulib %s -fgpu-rdc -L%t libNonArchive.a \
44// RUN:   2>&1 | FileCheck -check-prefixes=NONARCHIVE %s
45
46// Check if a file does not exist, it is not unbundled.
47
48// RUN: not %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
49// RUN:   --no-offload-new-driver --target=x86_64-unknown-linux-gnu \
50// RUN:   -nogpuinc -nogpulib %s -fgpu-rdc %t/NoneExist.a \
51// RUN:   2>&1 | FileCheck -check-prefixes=NONE %s
52
53// Check unbundling archive for MSVC.
54
55// RUN: llvm-ar cr %t/hipBundled2.lib %t/dummy.bc
56// RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
57// RUN:   --no-offload-new-driver --target=x86_64-pc-windows-msvc -fuse-ld= \
58// RUN:   -nogpuinc -nogpulib %s -fgpu-rdc -L%t -lhipBundled2 \
59// RUN:   2>&1 | FileCheck -check-prefix=MSVC %s
60
61// RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
62// RUN:   --no-offload-new-driver --target=x86_64-pc-windows-msvc -fuse-ld= \
63// RUN:   -nogpuinc -nogpulib %s -fgpu-rdc -L%t -l:hipBundled2.lib \
64// RUN:   2>&1 | FileCheck -check-prefix=MSVC %s
65
66// RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
67// RUN:   --no-offload-new-driver --target=x86_64-pc-windows-msvc -fuse-ld= \
68// RUN:   -nogpuinc -nogpulib %s -fgpu-rdc %t/hipBundled2.lib \
69// RUN:   2>&1 | FileCheck -check-prefix=MSVC %s
70
71// GNU1: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" "-input={{.*}}[[LIB:libhipBundled\.a]]" "-targets=hip-amdgcn-amd-amdhsa-gfx1030" "-output=[[A1030:.*\.a]]" "-allow-missing-bundles"
72// GNU2: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" "-input={{.*}}[[LIB:libhipBundled\.a\.5\.2]]" "-targets=hip-amdgcn-amd-amdhsa-gfx1030" "-output=[[A1030:.*\.a]]" "-allow-missing-bundles"
73// GNU: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx1030" {{.*}} "[[A1030]]"
74// GNU: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" "-input={{.*}}[[LIB]]" "-targets=hip-amdgcn-amd-amdhsa-gfx906" "-output=[[A906:.*\.a]]" "-allow-missing-bundles"
75// GNU: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx906" {{.*}} "[[A906]]"
76// GNU-L: "{{.*}}ld{{.*}}" {{.*}}"-o" "a.out" {{.*}}"-lhipBundled"
77// GNU-LA: "{{.*}}ld{{.*}}" {{.*}}"-o" "a.out" {{.*}}"-l:libhipBundled.a"
78// GNU-A: "{{.*}}ld{{.*}}" {{.*}}"-o" "a.out" "{{.*}}[[LIB]]"
79// NONARCHIVE-NOT: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" "-input={{.*libNonArchive\.a}}"
80// NONE-NOT: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" "-input={{.*NoneExist\.a}}"
81
82// MSVC: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" "-input={{.*}}hipBundled2.lib" "-targets=hip-amdgcn-amd-amdhsa-gfx1030" "-output=[[A1030:.*\.a]]" "-allow-missing-bundles"
83// MSVC: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx1030" {{.*}} "[[A1030]]"
84// MSVC: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" "-input={{.*}}hipBundled2.lib" "-targets=hip-amdgcn-amd-amdhsa-gfx906" "-output=[[A906:.*\.a]]" "-allow-missing-bundles"
85// MSVC: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx906" {{.*}} "[[A906]]"
86// MSVC: "{{.*}}link{{.*}}" {{.*}}"-out:a.exe" {{.*}}hipBundled2.lib"
87