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