3 # RUN: rm -rf %t; split-file %s %t
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/main.s -o %t/main.o
5 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/calls-foo.s -o %t/calls-foo.o
6 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/1.s -o %t/1.o
7 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/2.s -o %t/2.o
8 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/common.s -o %t/common.o
10 # RUN: echo "%t/1.o" > %t/filelist
11 # RUN: echo "%t/2.o" >> %t/filelist
13 # RUN: llvm-as %t/1.ll -o %t/1.bc
14 # RUN: llvm-as %t/2.ll -o %t/2.bc
16 ## Neither 1.o nor 2.o is loaded.
17 # RUN: %lld %t/main.o -o %t/out --start-lib %t/1.o %t/2.o --end-lib -why_load | count 0
18 # RUN: %lld %t/main.o -o %t/out --start-lib -filelist %t/filelist --end-lib -why_load | count 0
19 # RUN: llvm-readobj -s %t/out | FileCheck %s
20 # CHECK-NOT: Name: _foo
21 # CHECK-NOT: Name: _bar
23 ## _bar loads 2.o. The last --end-lib can be omitted.
24 # RUN: %lld %t/main.o -o %t/out -u _bar --start-lib %t/1.o %t/2.o -t -why_load | FileCheck %s --check-prefix=CHECK2WHY
25 # RUN: %lld %t/main.o -o %t/out -u _bar --start-lib -filelist %t/filelist -t -why_load | FileCheck %s --check-prefix=CHECK2WHY
26 # RUN: llvm-readobj -s %t/out | FileCheck --check-prefix=CHECK2 %s
27 # CHECK2WHY: {{.*}}main.o
28 # CHECK2WHY-NEXT: {{.*}}2.o
29 # CHECK2WHY-NEXT: _bar forced load of {{.*}}2.o
31 # CHECK2-NOT: Name: _foo
33 # CHECK2-NOT: Name: _foo
35 ## _foo loads 1.o. 1.o loads 2.o.
36 # RUN: %lld %t/main.o -o %t/out -u _foo --start-lib %t/1.o %t/2.o -why_load | FileCheck %s --check-prefix=CHECK3WHY
37 # RUN: llvm-readobj -s %t/out | FileCheck --check-prefix=CHECK3 %s
38 # RUN: %lld %t/main.o -o %t/out -u _foo --start-lib %t/2.o --end-lib --start-lib %t/1.o -why_load | FileCheck %s --check-prefix=CHECK3WHY
39 # RUN: llvm-readobj -s %t/out | FileCheck --check-prefix=CHECK3 %s
40 # CHECK3WHY: _foo forced load of {{.*}}1.o
41 # CHECK3WHY-NEXT: _bar forced load of {{.*}}2.o
43 # CHECK3-DAG: Name: _foo
44 # CHECK3-DAG: Name: _bar
46 ## Don't treat undefined _bar in 1.o as a lazy definition.
47 # RUN: not %lld %t/main.o -u _bar --start-lib %t/1.o 2>&1 | FileCheck %s --check-prefix=CHECK4
48 # CHECK4: error: undefined symbol: _bar
50 # RUN: %lld %t/main.o -o %t/out -u _common --start-lib %t/common.o
51 # RUN: llvm-readobj -s %t/out | FileCheck %s --check-prefix=COMMON1
52 # COMMON1: Name: _common
54 # RUN: %lld %t/main.o -o %t/out --start-lib %t/common.o
55 # RUN: llvm-readobj -s %t/out | FileCheck %s --check-prefix=COMMON2
56 # COMMON2-NOT: Name: _common
58 ## Neither 1.bc nor 2.bc is loaded.
59 # RUN: %lld %t/main.o -o %t/out --start-lib %t/1.bc %t/2.bc -why_load | count 0
60 # RUN: llvm-readobj -s %t/out | FileCheck %s --check-prefix=BITCODE
61 # BITCODE-NOT: Name: _foo
62 # BITCODE-NOT: Name: _bar
65 # RUN: %lld %t/main.o -o %t/out -u _bar --start-lib %t/1.bc %t/2.bc -why_load | FileCheck %s --check-prefix=BITCODE2WHY
66 # RUN: llvm-readobj -s %t/out | FileCheck %s --check-prefix=BITCODE2
67 # BITCODE2WHY: _bar forced load of {{.*}}2.bc
69 # BITCODE2-NOT: Name: _foo
70 # BITCODE2: Name: _bar
71 # BITCODE2-NOT: Name: _foo
73 ## calls-foo.o loads 1.bc. 1.bc loads 2.bc.
74 # RUN: %lld %t/calls-foo.o -o %t/out --start-lib %t/1.bc %t/2.bc -why_load | FileCheck %s --check-prefix=BITCODE3WHY
75 # RUN: llvm-readobj -s %t/out | FileCheck --check-prefix=BITCODE3 %s
76 # RUN: %lld %t/calls-foo.o -o %t/out --start-lib %t/2.bc --end-lib --start-lib %t/1.bc -why_load | FileCheck %s --check-prefix=BITCODE3WHY
77 # RUN: llvm-readobj -s %t/out | FileCheck --check-prefix=BITCODE3 %s
78 # BITCODE3WHY: _foo forced load of {{.*}}1.bc
79 # BITCODE3WHY-NEXT: _bar forced load of {{.*}}2.bc
81 # BITCODE3-DAG: Name: _foo
83 # RUN: not %lld %t/main.o --start-lib --start-lib 2>&1 | FileCheck -check-prefix=NESTED-LIB %s
84 # NESTED-LIB: error: nested --start-lib
86 # RUN: not %lld --end-lib 2>&1 | FileCheck %s --check-prefix=STRAY
87 # STRAY: error: stray --end-lib
112 target triple
= "x86_64-apple-macosx10.15.0"
113 target datalayout
= "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
116 tail call void
() @bar
()
123 target triple
= "x86_64-apple-macosx10.15.0"
124 target datalayout
= "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"