]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Driver/darwin-ld.c
Vendor import of clang RELEASE_350/final tag r216957 (effectively, 3.5.0 release):
[FreeBSD/FreeBSD.git] / test / Driver / darwin-ld.c
1 // Check that ld gets arch_multiple.
2
3 // RUN: %clang -target i386-apple-darwin9 -arch i386 -arch x86_64 %s -### -o foo 2> %t.log
4 // RUN: grep '".*ld.*" .*"-arch_multiple" "-final_output" "foo"' %t.log
5
6 // Make sure we run dsymutil on source input files.
7 // RUN: %clang -target i386-apple-darwin9 -### -g %s -o BAR 2> %t.log
8 // RUN: grep '".*dsymutil" "-o" "BAR.dSYM" "BAR"' %t.log
9 // RUN: %clang -target i386-apple-darwin9 -### -g -filelist FOO %s -o BAR 2> %t.log
10 // RUN: grep '".*dsymutil" "-o" "BAR.dSYM" "BAR"' %t.log
11
12 // Check linker changes that came with new linkedit format.
13 // RUN: touch %t.o
14 // RUN: %clang -target i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 %t.o 2> %t.log
15 // RUN: %clang -target i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 -dynamiclib %t.o 2>> %t.log
16 // RUN: %clang -target i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 -bundle %t.o 2>> %t.log
17 // RUN: FileCheck -check-prefix=LINK_IPHONE_3_0 %s < %t.log
18
19 // LINK_IPHONE_3_0: {{ld(.exe)?"}}
20 // LINK_IPHONE_3_0-NOT: -lcrt1.3.1.o
21 // LINK_IPHONE_3_0: -lcrt1.o
22 // LINK_IPHONE_3_0: -lSystem
23 // LINK_IPHONE_3_0: {{ld(.exe)?"}}
24 // LINK_IPHONE_3_0: -dylib
25 // LINK_IPHONE_3_0: -ldylib1.o
26 // LINK_IPHONE_3_0: -lSystem
27 // LINK_IPHONE_3_0: {{ld(.exe)?"}}
28 // LINK_IPHONE_3_0: -lbundle1.o
29 // LINK_IPHONE_3_0: -lSystem
30
31 // RUN: %clang -target i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 %t.o 2> %t.log
32 // RUN: %clang -target i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 -dynamiclib %t.o 2>> %t.log
33 // RUN: %clang -target i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 -bundle %t.o 2>> %t.log
34 // RUN: FileCheck -check-prefix=LINK_IPHONE_3_1 %s < %t.log
35
36 // LINK_IPHONE_3_1: {{ld(.exe)?"}}
37 // LINK_IPHONE_3_1-NOT: -lcrt1.o
38 // LINK_IPHONE_3_1: -lcrt1.3.1.o
39 // LINK_IPHONE_3_1: -lSystem
40 // LINK_IPHONE_3_1: {{ld(.exe)?"}}
41 // LINK_IPHONE_3_1: -dylib
42 // LINK_IPHONE_3_1-NOT: -ldylib1.o
43 // LINK_IPHONE_3_1: -lSystem
44 // LINK_IPHONE_3_1: {{ld(.exe)?"}}
45 // LINK_IPHONE_3_1-NOT: -lbundle1.o
46 // LINK_IPHONE_3_1: -lSystem
47
48 // RUN: %clang -target i386-apple-darwin9 -### -arch i386 -mios-simulator-version-min=3.0 %t.o 2> %t.log
49 // RUN: %clang -target i386-apple-darwin9 -### -arch i386 -mios-simulator-version-min=3.0 -dynamiclib %t.o 2>> %t.log
50 // RUN: %clang -target i386-apple-darwin9 -### -arch i386 -mios-simulator-version-min=3.0 -bundle %t.o 2>> %t.log
51 // RUN: FileCheck -check-prefix=LINK_IOSSIM_3_0 %s < %t.log
52
53 // LINK_IOSSIM_3_0: {{ld(.exe)?"}}
54 // LINK_IOSSIM_3_0-NOT: -lcrt1.o
55 // LINK_IOSSIM_3_0: -lSystem
56 // LINK_IOSSIM_3_0: {{ld(.exe)?"}}
57 // LINK_IOSSIM_3_0: -dylib
58 // LINK_IOSSIM_3_0-NOT: -ldylib1.o
59 // LINK_IOSSIM_3_0: -lSystem
60 // LINK_IOSSIM_3_0: {{ld(.exe)?"}}
61 // LINK_IOSSIM_3_0-NOT: -lbundle1.o
62 // LINK_IOSSIM_3_0: -lSystem
63
64 // RUN: %clang -target i386-apple-darwin9 -### -fpie %t.o 2> %t.log
65 // RUN: FileCheck -check-prefix=LINK_EXPLICIT_PIE %s < %t.log
66 //
67 // LINK_EXPLICIT_PIE: {{ld(.exe)?"}}
68 // LINK_EXPLICIT_PIE: "-pie"
69
70 // RUN: %clang -target i386-apple-darwin9 -### -fno-pie %t.o 2> %t.log
71 // RUN: FileCheck -check-prefix=LINK_EXPLICIT_NO_PIE %s < %t.log
72 //
73 // LINK_EXPLICIT_NO_PIE: {{ld(.exe)?"}}
74 // LINK_EXPLICIT_NO_PIE: "-no_pie"
75
76 // RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
77 // RUN:   -mlinker-version=100 2> %t.log
78 // RUN: FileCheck -check-prefix=LINK_NEWER_DEMANGLE %s < %t.log
79 //
80 // LINK_NEWER_DEMANGLE: {{ld(.exe)?"}}
81 // LINK_NEWER_DEMANGLE: "-demangle"
82
83 // RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
84 // RUN:   -mlinker-version=100 -Wl,--no-demangle 2> %t.log
85 // RUN: FileCheck -check-prefix=LINK_NEWER_NODEMANGLE %s < %t.log
86 //
87 // LINK_NEWER_NODEMANGLE: {{ld(.exe)?"}}
88 // LINK_NEWER_NODEMANGLE-NOT: "-demangle"
89 // LINK_NEWER_NODEMANGLE: "-lSystem"
90
91 // RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
92 // RUN:   -mlinker-version=95 2> %t.log
93 // RUN: FileCheck -check-prefix=LINK_OLDER_NODEMANGLE %s < %t.log
94 //
95 // LINK_OLDER_NODEMANGLE: {{ld(.exe)?"}}
96 // LINK_OLDER_NODEMANGLE-NOT: "-demangle"
97 // LINK_OLDER_NODEMANGLE: "-lSystem"
98
99 // RUN: %clang -target x86_64-apple-darwin10 -### %s \
100 // RUN:   -mlinker-version=117 -flto 2> %t.log
101 // RUN: cat %t.log
102 // RUN: FileCheck -check-prefix=LINK_OBJECT_LTO_PATH %s < %t.log
103 //
104 // LINK_OBJECT_LTO_PATH: {{ld(.exe)?"}}
105 // LINK_OBJECT_LTO_PATH: "-object_path_lto"
106
107 // RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
108 // RUN:   -force_load a -force_load b 2> %t.log
109 // RUN: cat %t.log
110 // RUN: FileCheck -check-prefix=FORCE_LOAD %s < %t.log
111 //
112 // FORCE_LOAD: {{ld(.exe)?"}}
113 // FORCE_LOAD: "-force_load" "a" "-force_load" "b"
114
115 // RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
116 // RUN:   -lazy_framework Framework 2> %t.log
117 //
118 // RUN: FileCheck -check-prefix=LINK_LAZY_FRAMEWORK %s < %t.log
119 // LINK_LAZY_FRAMEWORK: {{ld(.exe)?"}}
120 // LINK_LAZY_FRAMEWORK: "-lazy_framework" "Framework"
121
122 // RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
123 // RUN:   -lazy_library Library 2> %t.log
124 //
125 // RUN: FileCheck -check-prefix=LINK_LAZY_LIBRARY %s < %t.log
126 // LINK_LAZY_LIBRARY: {{ld(.exe)?"}}
127 // LINK_LAZY_LIBRARY: "-lazy_library" "Library"
128
129 // RUN: %clang -target x86_64-apple-darwin10 -### %t.o 2> %t.log
130 // RUN: %clang -target x86_64-apple-macosx10.7 -### %t.o 2>> %t.log
131 // RUN: FileCheck -check-prefix=LINK_VERSION_MIN %s < %t.log
132 // LINK_VERSION_MIN: {{ld(.exe)?"}}
133 // LINK_VERSION_MIN: "-macosx_version_min" "10.6.0"
134 // LINK_VERSION_MIN: {{ld(.exe)?"}}
135 // LINK_VERSION_MIN: "-macosx_version_min" "10.7.0"
136
137 // RUN: %clang -target x86_64-apple-darwin12 -### %t.o 2> %t.log
138 // RUN: FileCheck -check-prefix=LINK_NO_CRT1 %s < %t.log
139 // LINK_NO_CRT1-NOT: crt
140
141 // RUN: %clang -target armv7-apple-ios6.0 -miphoneos-version-min=6.0 -### %t.o 2> %t.log
142 // RUN: FileCheck -check-prefix=LINK_NO_IOS_CRT1 %s < %t.log
143 // LINK_NO_IOS_CRT1-NOT: crt
144
145 // RUN: %clang -target arm64-apple-ios5.0 -miphoneos-version-min=5.0 -### %t.o 2> %t.log
146 // RUN: FileCheck -check-prefix=LINK_NO_IOS_ARM64_CRT1 %s < %t.log
147 // LINK_NO_IOS_ARM64_CRT1-NOT: crt
148
149 // RUN: %clang -target i386-apple-darwin12 -pg -### %t.o 2> %t.log
150 // RUN: FileCheck -check-prefix=LINK_PG %s < %t.log
151 // LINK_PG: -lgcrt1.o
152 // LINK_PG: -no_new_main
153
154 // Check that clang links with libgcc_s.1 for iOS 4 and earlier, but not arm64.
155 // RUN: %clang -target armv7-apple-ios4.0 -miphoneos-version-min=4.0 -### %t.o 2> %t.log
156 // RUN: FileCheck -check-prefix=LINK_IOS_LIBGCC_S %s < %t.log
157 // LINK_IOS_LIBGCC_S: lgcc_s.1
158
159 // RUN: %clang -target arm64-apple-ios4.0 -miphoneos-version-min=4.0 -### %t.o 2> %t.log
160 // RUN: FileCheck -check-prefix=LINK_NO_IOS_ARM64_LIBGCC_S %s < %t.log
161 // LINK_NO_IOS_ARM64_LIBGCC_S-NOT: lgcc_s.1
162
163 // RUN: %clang -target x86_64-apple-darwin12 -rdynamic -### %t.o \
164 // RUN:   -mlinker-version=100 2> %t.log
165 // RUN: FileCheck -check-prefix=LINK_NO_EXPORT_DYNAMIC %s < %t.log
166 // LINK_NO_EXPORT_DYNAMIC: {{ld(.exe)?"}}
167 // LINK_NO_EXPORT_DYNAMIC-NOT: "-export_dynamic"
168
169 // RUN: %clang -target x86_64-apple-darwin12 -rdynamic -### %t.o \
170 // RUN:   -mlinker-version=137 2> %t.log
171 // RUN: FileCheck -check-prefix=LINK_EXPORT_DYNAMIC %s < %t.log
172 // LINK_EXPORT_DYNAMIC: {{ld(.exe)?"}}
173 // LINK_EXPORT_DYNAMIC: "-export_dynamic"
174
175 // RUN: %clang -target x86_64h-apple-darwin -### %t.o 2> %t.log
176 // RUN: FileCheck -check-prefix=LINK_X86_64H_ARCH %s < %t.log
177 //
178 // LINK_X86_64H_ARCH: {{ld(.exe)?"}}
179 // LINK_X86_64H_ARCH: "x86_64h"
180
181 // RUN: %clang -target x86_64-apple-darwin -arch x86_64 -arch x86_64h -### %t.o 2> %t.log
182 // RUN: FileCheck -check-prefix=LINK_X86_64H_MULTIARCH %s < %t.log
183 //
184 // LINK_X86_64H_MULTIARCH: {{ld(.exe)?"}}
185 // LINK_X86_64H_MULTIARCH: "x86_64"
186 //
187 // LINK_X86_64H_MULTIARCH: {{ld(.exe)?"}}
188 // LINK_X86_64H_MULTIARCH: "x86_64h"
189
190 // Check that clang passes -iphoneos_version_min to the linker when building
191 // for the iOS simulator but when -mios-simulator-version-min is not
192 // explicitly specified (<rdar://problem/15959009>).
193 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
194 // RUN:   %clang -target i386-apple-darwin -### %t.o 2> %t.log
195 // RUN: FileCheck -check-prefix=LINK_IPHONEOS_VERSION_MIN %s < %t.log
196 // LINK_IPHONEOS_VERSION_MIN: -iphoneos_version_min