Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / tapi-link.s
blobafe856f20cca4915668bc73efdc2aa71776a4de4
1 # REQUIRES: x86
3 # RUN: split-file %s %t --no-leading-lines
5 # RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %t/test.s -o %t/test.o
7 # RUN: %lld -o %t/test -lSystem -lc++ -framework CoreFoundation %t/libNested.tbd %t/libTlvWeak.tbd %t/test.o
8 # RUN: llvm-objdump --bind --weak-bind --no-show-raw-insn -d -r %t/test | FileCheck %s
10 ## Targeting an arch not listed in the tbd should fallback to an ABI compatible arch
11 # RUN: %lld -arch x86_64h -o %t/test-compat -lSystem -lc++ -framework CoreFoundation %t/libNested.tbd %t/libTlvWeak.tbd %t/test.o
12 # RUN: llvm-objdump --bind --weak-bind --no-show-raw-insn -d -r %t/test-compat | FileCheck %s
14 ## Setting LD_DYLIB_CPU_SUBTYPES_MUST_MATCH forces exact target arch match.
15 # RUN: env LD_DYLIB_CPU_SUBTYPES_MUST_MATCH=1 not %lld -arch x86_64h -o /dev/null -lSystem -lc++ -framework \
16 # RUN: CoreFoundation %t/libNested.tbd %t/libTlvWeak.tbd %t/test.o 2>&1 | FileCheck %s -check-prefix=INCOMPATIBLE
18 # INCOMPATIBLE: error: {{.*}}libSystem.tbd(/usr/lib/libSystem.dylib) is incompatible with x86_64h (macOS11.0)
19 # INCOMPATIBLE-NEXT: error: {{.*}}libc++.tbd(/usr/lib/libc++.dylib) is incompatible with x86_64h (macOS11.0)
20 # INCOMPATIBLE-NEXT: error: {{.*}}CoreFoundation.tbd(/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation) is incompatible with x86_64h (macOS11.0)
22 ## libReexportSystem.tbd tests that we can reference symbols from a 2nd-level
23 ## tapi document, re-exported by a top-level tapi document, which itself is
24 ## re-exported by another top-level tapi document.
25 # RUN: %lld -o %t/with-reexport -lSystem -L%t %t/libReexportNested.tbd %t/libTlvWeak.tbd -lc++ -framework CoreFoundation %t/test.o
26 # RUN: llvm-objdump --bind --weak-bind --no-show-raw-insn -d -r %t/with-reexport | FileCheck %s
28 # CHECK: Bind table:
29 # CHECK-DAG: __DATA __data {{.*}} pointer 0 CoreFoundation _OBJC_CLASS_$_NSObject
30 # CHECK-DAG: __DATA __data {{.*}} pointer 0 CoreFoundation _OBJC_METACLASS_$_NSObject
31 # CHECK-DAG: __DATA __data {{.*}} pointer 0 CoreFoundation _OBJC_IVAR_$_NSConstantArray._count
32 # CHECK-DAG: __DATA __data {{.*}} pointer 0 CoreFoundation _OBJC_EHTYPE_$_NSException
33 # CHECK-DAG: __DATA __data {{.*}} pointer 0 libc++abi ___gxx_personality_v0
34 # CHECK-DAG: __DATA __data {{.*}} pointer 0 libNested3 _deeply_nested
35 # CHECK-DAG: __DATA __data {{.*}} pointer 0 libTlvWeak _weak
36 # CHECK-DAG: __DATA __thread_ptrs {{.*}} pointer 0 libTlvWeak _tlv
38 # CHECK: Weak bind table:
39 # CHECK-DAG: __DATA __data {{.*}} pointer 0 _weak
41 # RUN: llvm-otool -l %t/test | FileCheck --check-prefix=LOAD %s
43 # RUN: llvm-otool -l %t/with-reexport | \
44 # RUN: FileCheck --check-prefixes=LOAD,LOAD-REEXPORT %s
46 # LOAD: cmd LC_LOAD_DYLIB
47 # LOAD-NEXT: cmdsize
48 # LOAD-NEXT: name /usr/lib/libSystem.dylib
49 # LOAD-NEXT: time stamp
50 # LOAD-NEXT: current version 1.1.1
51 # LOAD-NEXT: compatibility version
53 # LOAD-REEXPORT: cmd LC_LOAD_DYLIB
54 # LOAD-REEXPORT-NEXT: cmdsize
55 # LOAD-REEXPORT-NEXT: name /usr/lib/libReexportNested.dylib
56 # LOAD-REEXPORT-NEXT: time stamp
57 # LOAD-REEXPORT-NEXT: current version 1.0.0
58 # LOAD-REEXPORT-NEXT: compatibility version
60 #--- test.s
61 .section __TEXT,__text
62 .global _main
64 _main:
65 mov _tlv@TLVP(%rip), %rax
66 ret
68 .data
69 .quad _OBJC_CLASS_$_NSObject
70 .quad _OBJC_METACLASS_$_NSObject
71 .quad _OBJC_IVAR_$_NSConstantArray._count
72 .quad _OBJC_EHTYPE_$_NSException
73 ## This symbol is defined in an inner TAPI document within libNested.tbd.
74 .quad _deeply_nested
76 ## This symbol is defined in libc++abi.tbd, but we are linking test.o against
77 ## libc++.tbd (which re-exports libc++abi). Linking against this symbol verifies
78 ## that .tbd file re-exports can refer not just to TAPI documents within the
79 ## same .tbd file, but to other on-disk files as well.
80 .quad ___gxx_personality_v0
82 .quad _weak
84 ## This tests that we can locate a symbol re-exported by a child of a TAPI
85 ## document.
86 #--- libNested.tbd
87 --- !tapi-tbd-v3
88 archs: [ x86_64 ]
89 uuids: [ 'x86_64: 00000000-0000-0000-0000-000000000000' ]
90 platform: macosx
91 install-name: '/usr/lib/libNested.dylib'
92 exports:
93 - archs: [ x86_64 ]
94 re-exports: [ '/usr/lib/libNested2.dylib' ]
95 --- !tapi-tbd-v3
96 archs: [ x86_64 ]
97 uuids: [ 'x86_64: 00000000-0000-0000-0000-000000000001' ]
98 platform: macosx
99 install-name: '/usr/lib/libNested2.dylib'
100 exports:
101 - archs: [ x86_64 ]
102 re-exports: [ '/usr/lib/libNested3.dylib' ]
103 --- !tapi-tbd-v3
104 archs: [ x86_64 ]
105 uuids: [ 'x86_64: 00000000-0000-0000-0000-000000000002' ]
106 platform: macosx
107 install-name: '/usr/lib/libNested3.dylib'
108 exports:
109 - archs: [ x86_64 ]
110 symbols: [ _deeply_nested ]
113 #--- libReexportNested.tbd
114 --- !tapi-tbd-v3
115 archs: [ i386, x86_64 ]
116 uuids: [ 'i386: 00000000-0000-0000-0000-000000000000', 'x86_64: 00000000-0000-0000-0000-000000000001' ]
117 platform: macosx
118 install-name: '/usr/lib/libReexportNested.dylib'
119 exports:
120 - archs: [ i386, x86_64 ]
121 re-exports: [ 'libNested.dylib' ]
124 #--- libTlvWeak.tbd
125 --- !tapi-tbd
126 tbd-version: 4
127 targets: [ x86_64-macos ]
128 uuids:
129 - target: x86_64-macos
130 value: 00000000-0000-0000-0000-000000000000
131 install-name: '/usr/lib/libTlvWeak.dylib'
132 current-version: 0001.001.1
133 exports: # Validate weak & thread-local symbols
134 - targets: [ x86_64-macos ]
135 weak-symbols: [ _weak ]
136 thread-local-symbols: [ _tlv ]