Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / archive.s
blobc324be0ac579f8e81d45fcc0fa3fd38fc82f648f
1 # REQUIRES: x86
2 # RUN: rm -rf %t; split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/2.s -o %t/2.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/3.s -o %t/3.o
5 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/4.s -o %t/4.o
6 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/main.s -o %t/main.o
8 # RUN: llvm-ar rcs %t/test.a %t/2.o %t/3.o %t/4.o
9 # RUN: %lld %t/main.o %t/test.a -o %t/test.out
11 ## TODO: Run llvm-nm -p to validate symbol order
12 # RUN: llvm-nm %t/test.out | FileCheck %s
13 # CHECK: T _bar
14 # CHECK: T _boo
15 # CHECK: T _main
17 ## Linking with the archive first in the command line shouldn't change anything
18 # RUN: %lld %t/test.a %t/main.o -o %t/test.out
19 # RUN: llvm-nm %t/test.out | FileCheck %s --check-prefix ARCHIVE-FIRST
20 # ARCHIVE-FIRST: T _bar
21 # ARCHIVE-FIRST: T _boo
22 # ARCHIVE-FIRST: T _main
24 # RUN: llvm-nm %t/test.out | FileCheck %s --check-prefix VISIBLE
25 # VISIBLE-NOT: T _undefined
26 # VISIBLE-NOT: T _unused
28 # RUN: %lld %t/test.a %t/main.o -o %t/all-load -noall_load -all_load
29 # RUN: llvm-nm %t/all-load | FileCheck %s --check-prefix ALL-LOAD
30 # ALL-LOAD: T _bar
31 # ALL-LOAD: T _boo
32 # ALL-LOAD: T _main
33 # ALL-LOAD: T _unused
35 # RUN: %lld %t/test.a %t/main.o -o %t/no-all-load -all_load -noall_load
36 # RUN: llvm-nm %t/no-all-load | FileCheck %s --check-prefix NO-ALL-LOAD
37 # RUN: %lld %t/test.a %t/main.o -o %t/no-all-load-only -noall_load
38 # RUN: llvm-nm %t/no-all-load-only | FileCheck %s --check-prefix NO-ALL-LOAD
39 # NO-ALL-LOAD-NOT: T _unused
41 ## Multiple archives defining the same symbols aren't an issue, due to lazy
42 ## loading
43 # RUN: cp %t/test.a %t/test2.a
44 # RUN: %lld %t/test.a %t/test2.a %t/main.o -o /dev/null
46 #--- 2.s
47 .globl _boo
48 _boo:
49 ret
51 #--- 3.s
52 .globl _bar
53 _bar:
54 ret
56 #--- 4.s
57 .globl _undefined, _unused
58 _unused:
59 ret
61 #--- main.s
62 .globl _main
63 _main:
64 callq _boo
65 callq _bar
66 ret