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