llvm-project
114 строк · 5.0 Кб
1# REQUIRES: x86
2# RUN: rm -rf %t; mkdir %t
3# RUN: yaml2obj %s > %t/test.dylib
4# RUN: echo "" | llvm-mc -filetype=obj -triple=x86_64-apple-macos10.15 -o %t/test_macos.o
5# RUN: echo "" | llvm-mc -filetype=obj -triple=x86_64-apple-ios13.15.0-macabi -o %t/test_maccatalyst.o
6# RUN: echo "" | llvm-mc -filetype=obj -triple=x86_64-apple-ios13.15.0 -o %t/test_ios.o
7
8## Test linking against a zippered dylib.
9# RUN: %lld -lSystem -dylib %t/test.dylib %t/test_macos.o -o /dev/null
10# RUN: %no-arg-lld -syslibroot %S/Inputs/MacOSX.sdk -lSystem -dylib -arch x86_64 -platform_version mac-catalyst 13.15.0 14.0 %t/test.dylib %t/test_maccatalyst.o -o /dev/null
11
12# RUN: %no-arg-lld -syslibroot %S/Inputs/MacOSX.sdk -lSystem -dylib -arch x86_64 -platform_version mac-catalyst 13.15.0 14.0 %t/test_maccatalyst.o -o /dev/null -framework MacOnly-Indirect
13
14# RUN: not %no-arg-lld -syslibroot %S/Inputs/MacOSX.sdk -lSystem -dylib -arch x86_64 -platform_version mac-catalyst 13.15.0 14.0 %t/test_maccatalyst.o -o /dev/null -framework MacOnly 2>&1 | FileCheck --check-prefix=INCOMPATIBLE %s
15# INCOMPATIBLE: System/Library/Frameworks{{[\\/]}}MacOnly.framework{{[\\/]}}MacOnly.tbd(MacOnly.dylib) is incompatible with x86_64 (macCatalyst13.15.0)
16
17# RUN: not %no-arg-lld -syslibroot %S/Inputs/MacOSX.sdk -lSystem -dylib -arch x86_64 -platform_version ios 13.15.0 14.0 %t/test.dylib %t/test_ios.o -o /dev/null 2>&1 | FileCheck %s
18# CHECK: test.dylib has platform macOS/macCatalyst, which is different from target platform iOS
19
20## Test creating a zippered dylib.
21# RUN: %no-arg-lld -syslibroot %S/Inputs/MacOSX.sdk -lSystem -dylib -arch x86_64 -platform_version macos 12.0 13.0 -platform_version mac-catalyst 13.15.0 14.0 %t/test.dylib %t/test_macos.o -o %t/test_zippered.dylib
22# RUN: llvm-otool -l %t/test_zippered.dylib | FileCheck --check-prefix=ZIPPERED %s
23# ZIPPERED: cmd LC_BUILD_VERSION
24# ZIPPERED-NEXT: cmdsize
25# ZIPPERED-NEXT: platform 1
26# ZIPPERED-NEXT: sdk 13.0
27# ZIPPERED-NEXT: minos 12.0
28# ZIPPERED-NEXT: ntools 1
29# ZIPPERED-NEXT: tool
30# ZIPPERED-NEXT: version
31# ZIPPERED-NEXT: Load command
32# ZIPPERED-NEXT: cmd LC_BUILD_VERSION
33# ZIPPERED-NEXT: cmdsize
34# ZIPPERED-NEXT: platform 6
35# ZIPPERED-NEXT: sdk 14.0
36# ZIPPERED-NEXT: minos 13.15
37# ZIPPERED-NEXT: ntools 1
38# ZIPPERED-NEXT: tool
39# ZIPPERED-NEXT: version
40
41# RUN: %no-arg-lld -syslibroot %S/Inputs/MacOSX.sdk -lSystem -dylib -arch x86_64 -platform_version macos 10.8 13.0 -platform_version mac-catalyst 13.15.0 14.0 %t/test.dylib %t/test_macos.o -o %t/test_zippered.dylib
42# RUN: llvm-otool -l %t/test_zippered.dylib | FileCheck --check-prefix=ZIPPERED-OLD %s
43# ZIPPERED-OLD: cmd LC_VERSION_MIN_MACOSX
44# ZIPPERED-OLD-NEXT: cmdsize
45# ZIPPERED-OLD-NEXT: version 10.8
46# ZIPPERED-OLD-NEXT: sdk 13.0
47# ZIPPERED-OLD-NEXT: Load command
48# ZIPPERED-OLD-NEXT: cmd LC_BUILD_VERSION
49# ZIPPERED-OLD-NEXT: cmdsize
50# ZIPPERED-OLD-NEXT: platform 6
51# ZIPPERED-OLD-NEXT: sdk 14.0
52# ZIPPERED-OLD-NEXT: minos 13.15
53# ZIPPERED-OLD-NEXT: ntools 1
54# ZIPPERED-OLD-NEXT: tool
55# ZIPPERED-OLD-NEXT: version
56
57# RUN: not %no-arg-lld -syslibroot %S/Inputs/MacOSX.sdk -lSystem -arch x86_64 -platform_version macos 10.8 13.0 -platform_version mac-catalyst 13.15.0 14.0 %t/test.dylib %t/test_macos.o -o %t/test_zippered.dylib 2>&1 | FileCheck --check-prefix=ZIPPERED-EXE %s
58# ZIPPERED-EXE: writing zippered outputs only valid for -dylib and -bundle
59
60## Reject .o files which only have the secondary platform.
61# RUN: not %no-arg-lld -syslibroot %S/Inputs/MacOSX.sdk -lSystem -dylib -arch x86_64 -platform_version macos 12.0 13.0 -platform_version mac-catalyst 13.15.0 14.0 %t/test.dylib %t/test_maccatalyst.o -o %t/test_zippered.dylib 2>&1 | FileCheck --check-prefix=CAT %s
62# CAT: test_maccatalyst.o has platform macCatalyst, which is different from target platform macOS
63
64--- !mach-o
65FileHeader:
66magic: 0xFEEDFACF
67cputype: 0x1000007
68cpusubtype: 0x3
69filetype: 0x6
70ncmds: 4
71sizeofcmds: 600
72flags: 0x100085
73reserved: 0x0
74LoadCommands:
75- cmd: LC_ID_DYLIB
76cmdsize: 32
77dylib:
78name: 24
79timestamp: 1
80current_version: 0
81compatibility_version: 0
82Content: test
83ZeroPadBytes: 4
84- cmd: LC_DYLD_INFO_ONLY
85cmdsize: 48
86rebase_off: 0
87rebase_size: 0
88bind_off: 0
89bind_size: 0
90weak_bind_off: 0
91weak_bind_size: 0
92lazy_bind_off: 0
93lazy_bind_size: 0
94export_off: 0
95export_size: 0
96- cmd: LC_BUILD_VERSION
97cmdsize: 32
98platform: 1
99minos: 659200
100sdk: 720896
101ntools: 1
102Tools:
103- tool: 3
104version: 39913472
105- cmd: LC_BUILD_VERSION
106cmdsize: 32
107platform: 6
108minos: 855808
109sdk: 917504
110ntools: 1
111Tools:
112- tool: 3
113version: 39913472
114...
115