1# REQUIRES: x86
2
3# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
4# RUN: echo '.globl weak; weak:' | llvm-mc -filetype=obj -triple=x86_64 - -o %tweak.o
5# RUN: echo '.global foo; foo:' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
6# RUN: echo '.global bar; bar:' | llvm-mc -filetype=obj -triple=x86_64 - -o %t2.o
7# RUN: echo '.global baz; baz:' | llvm-mc -filetype=obj -triple=x86_64 - -o %t3.o
8# RUN: rm -f %tweak.a && llvm-ar rc %tweak.a %tweak.o
9# RUN: rm -f %t1.a && llvm-ar rc %t1.a %t1.o %t2.o %t3.o
10
11# RUN: ld.lld %t.o %tweak.a %t1.a --print-archive-stats=%t.txt -o /dev/null
12# RUN: FileCheck --input-file=%t.txt -DT=%t %s --match-full-lines --strict-whitespace
13
14## Fetches 0 member from %tweak.a and 2 members from %t1.a
15#      CHECK:members	fetched	archive
16# CHECK-NEXT:1	0	[[T]]weak.a
17# CHECK-NEXT:3	2	[[T]]1.a
18
19## - means stdout.
20# RUN: ld.lld %t.o %tweak.a %t1.a --print-archive-stats=- -o /dev/null | diff %t.txt -
21
22## The second %t1.a has 0 fetched member.
23# RUN: ld.lld %t.o %tweak.a %t1.a %t1.a --print-archive-stats=- -o /dev/null | \
24# RUN:   FileCheck --check-prefix=CHECK2 %s
25# CHECK2:      members	fetched	archive
26# CHECK2-NEXT: 1	0	{{.*}}weak.a
27# CHECK2-NEXT: 3	2	{{.*}}1.a
28# CHECK2-NEXT: 3	0	{{.*}}1.a
29
30# RUN: not ld.lld -shared %t.o --print-archive-stats=/ -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s
31# ERR: error: --print-archive-stats=: cannot open /: {{.*}}
32
33.globl _start
34.weak weak
35_start:
36  call foo
37  call bar
38  call weak
39