]> git.saurik.com Git - apple/ld64.git/blame_incremental - unit-tests/test-cases/llvm-integration/Makefile
ld64-127.2.tar.gz
[apple/ld64.git] / unit-tests / test-cases / llvm-integration / Makefile
... / ...
CommitLineData
1##
2# Copyright (c) 2006-2008 Apple Inc. All rights reserved.
3#
4# @APPLE_LICENSE_HEADER_START@
5#
6# This file contains Original Code and/or Modifications of Original Code
7# as defined in and that are subject to the Apple Public Source License
8# Version 2.0 (the 'License'). You may not use this file except in
9# compliance with the License. Please obtain a copy of the License at
10# http://www.opensource.apple.com/apsl/ and read it before using this
11# file.
12#
13# The Original Code and all software distributed under the License are
14# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18# Please see the License for the specific language governing rights and
19# limitations under the License.
20#
21# @APPLE_LICENSE_HEADER_END@
22##
23TESTROOT = ../..
24
25include ${TESTROOT}/include/common.makefile
26
27SHELL = bash # use bash shell so we can redirect just stderr
28
29
30LLVMAR = /usr/local/bin/llvm-ar
31
32#
33# Test the we set the stack execution bit properly.
34
35run:
36 if [ -f /Developer/usr/bin/llvm-gcc-4.2 ] ; then \
37 $(MAKE) all ; \
38 else \
39 ${PASS_IFF} /usr/bin/true ; \
40 fi
41
42all: zero one two three four five six seven eight nine ten \
43 eleven twelve thirteen fourteen fifteen sixteen seventeen \
44 eighteen nineteen
45
46zero:
47 #
48 # llvm : a.c : Dfoo3
49 # llvm : b.c : Dfoo2
50 # MachO : main.c : Ufoo2, Ufoo3
51 #
52 #echo "Zero..."
53 ${CC} ${CCFLAGS} -flto a.c -c -o a.o
54 ${CC} ${CCFLAGS} -flto b.c -c -o b.o
55 ${CC} ${CCFLAGS} main.c -c -o main.o
56 ${CC} ${CCFLAGS} a.o b.o main.o -o main.exe
57 ${PASS_IFF_GOOD_MACHO} main.exe
58
59one:
60 #
61 # llvm : a1.c : Dfoo3, Ufoo4
62 # llvm : b1.c : Dfoo2, Ufoo4
63 # MachO : main1.c : Dfoo4, Ufoo2, Ufoo3
64 #
65 #echo "One..."
66 ${CC} ${CCFLAGS} -flto a1.c -c -o a1.o
67 ${CC} ${CCFLAGS} -flto b1.c -c -o b1.o
68 ${CC} ${CCFLAGS} main1.c -c -o main1.o
69 ${CC} ${CCFLAGS} a1.o b1.o main1.o -o main1.exe
70 ${PASS_IFF_GOOD_MACHO} main1.exe
71
72two:
73 #
74 # llvm : a2.c : Dfoo3, Ufoo4
75 # llvm : b2.c : Dfoo2, Dfoo4
76 # MachO : main2.c : Ufoo2, Ufoo3
77 #
78 #echo "Two..."
79 ${CC} ${CCFLAGS} -flto a2.c -c -o a2.o
80 ${CC} ${CCFLAGS} -flto b2.c -c -o b2.o
81 ${CC} ${CCFLAGS} main2.c -c -o main2.o
82 ${CC} ${CCFLAGS} a2.o b2.o main2.o -o main2.exe
83 ${PASS_IFF_GOOD_MACHO} main2.exe
84
85three:
86 #
87 # llvm : a3.c : Dfoo1, Dbar
88 # llvm : b3.c : Dfoo2, Ubar
89 # MachO : main3.c : Ufoo1, Ufoo2, Ubar
90 #
91 #echo "Three..."
92 ${CC} ${CCFLAGS} -flto a3.c -c -o a3.o
93 ${CC} ${CCFLAGS} -flto b3.c -c -o b3.o
94 ${CC} ${CCFLAGS} main3.c -c -o main3.o
95 ${CC} ${CCFLAGS} a3.o b3.o main3.o -o main3.exe
96 ${PASS_IFF_GOOD_MACHO} main3.exe
97
98four:
99 #
100 # llvm : a4.c : Dfoo3, Ufoo4
101 # llvm : b4.c : Dfoo2, DLmyfoo, Ufoo4
102 # MachO : main4.c : Dfoo4, Ufoo2, Ufoo3
103 #
104 #echo "Four..."
105 ${CC} ${CCFLAGS} -flto a4.c -c -o a4.o
106 ${CC} ${CCFLAGS} -flto b4.c -c -o b4.o
107 ${CC} ${CCFLAGS} main4.c -c -o main4.o
108 ${CC} ${CCFLAGS} a4.o b4.o main4.o -o main4.exe
109 ${PASS_IFF_GOOD_MACHO} main4.exe
110
111five:
112 #
113 # llvm : a5.c : Dfoo1, Ufoo2, Ufoo3
114 # llvm : b5.c : Dfoo2
115 # MachO : main5.c : Dfoo3, Ufoo1
116 #
117 #echo "verify that if call to mach-o is optimized away, mach-o func is dead stripped"
118 ${CC} ${CCFLAGS} -flto a5.c -c -o a5.o
119 ${CC} ${CCFLAGS} -flto b5.c -c -o b5.o
120 ${CC} ${CCFLAGS} main5.c -c -o main5.o
121 ${CC} ${CCFLAGS} a5.o b5.o main5.o -o main5.exe -Wl,-dead_strip
122 ${OTOOL} -tV main5.exe | grep foo3 | ${PASS_IFF_EMPTY}
123 ${PASS_IFF_GOOD_MACHO} main5.exe
124
125six:
126 #
127 # llvm : a6.c : Dfoo1, Dfoo2
128 # MachO : main6.c : Ufoo1
129 #
130 #echo "verify dead stripping of foo2 in main executable"
131 ${CC} ${CCFLAGS} -flto a6.c -c -o a6.o
132 ${CC} ${CCFLAGS} main6.c -c -o main6.o
133 ${CC} ${CCFLAGS} a6.o main6.o -o main6.exe -Wl,-dead_strip
134 ${PASS_IFF_GOOD_MACHO} main6.exe
135 ${OTOOL} -tV main6.exe | grep foo2 | ${PASS_IFF_EMPTY}
136
137seven:
138 #
139 # llvm : a7.c : Dfoo1, Dfoo2, Ufoo3
140 # llvm : b7.c : Dfoo3, ufoo2
141 # MachO : main7.c : Ufoo1
142 #
143 #echo "Seven..."
144 ${CC} ${CCFLAGS} -flto a7.c -c -o a7.o
145 ${CC} ${CCFLAGS} -flto b7.c -c -o b7.o
146 ${CC} ${CCFLAGS} main7.c -c -o main7.o
147 ${CC} ${CCFLAGS} a7.o b7.o main7.o -o main7.exe
148 ${PASS_IFF_GOOD_MACHO} main7.exe
149
150eight:
151 #
152 # llvm : a8.c : Dfoo1, Dfoo2
153 # MachO : main8.c : Ufoo1
154 #
155 #echo "Eight..."
156 ${CC} ${CCFLAGS} -flto a8.c -c -o a8.o
157 ${CC} ${CCFLAGS} main8.c -c -o main8.o
158 ${CC} ${CCFLAGS} a8.o main8.o -o main8.exe -Wl,-dead_strip
159 ${OTOOL} -tV main8.exe | grep foo2 | ${PASS_IFF_EMPTY}
160 ${OTOOL} -tV main8.exe | grep unnamed_2_1 | ${PASS_IFF_EMPTY}
161
162nine:
163 #
164 # llvm : a9.c : Dfoo1, Dfoo2, Dfoo3, Ufoo3, Ufoo4
165 # MachO : main9.c : Ufoo1, Dfoo4
166 #
167 #echo "Nine..."
168 ${CC} ${CCFLAGS} -flto a9.c -c -o a9.o
169 ${CC} ${CCFLAGS} main9.c -c -o main9.o
170 ${CC} ${CCFLAGS} a9.o main9.o -o main9.exe -Wl,-dead_strip
171 ${OTOOL} -tV main9.exe | grep foo2 | ${PASS_IFF_EMPTY}
172 ${OTOOL} -tV main9.exe | grep foo4 | ${PASS_IFF_EMPTY}
173 ${OTOOL} -tV main9.exe | grep unnamed_2_1 | ${PASS_IFF_EMPTY}
174
175ten:
176 #
177 # llvm : a10.c
178 # llvm : b10.c
179 # MachO : main10.c
180 #
181 #echo "Ten..."
182 ${CC} ${CCFLAGS} -flto a10.c -c -o a10.o
183 ${CC} ${CCFLAGS} -flto b10.c -c -o b10.o
184 ${CC} ${CCFLAGS} main10.c -c -o main10.o
185 ${CC} ${CCFLAGS} a10.o b10.o main10.o -o main10.exe
186 ${PASS_IFF_GOOD_MACHO} main10.exe
187
188eleven:
189 #
190 # llvm : a11.c
191 # MachO : main11.c
192 #
193 #echo "Eleven..."
194 ${CC} ${CCFLAGS} -flto a11.c -c -o a11.o
195 ${CC} ${CCFLAGS} main11.c -c -o main11.o
196 ${CC} ${CCFLAGS} a11.o main11.o -o main11.exe
197 ${PASS_IFF_GOOD_MACHO} main11.exe
198
199twelve:
200 #
201 # llvm : a12.c
202 # MachO : main12.c
203 #
204 #echo "verify tentative def in llvm .o referenced from mach-o"
205 ${CC} ${CCFLAGS} -flto a12.c -c -o a12.o
206 ${CC} ${CCFLAGS} main12.c -c -o main12.o
207 ${CC} ${CCFLAGS} a12.o main12.o -o main12.exe
208 ${PASS_IFF_GOOD_MACHO} main12.exe
209
210thirteen:
211 #
212 # llvm : a13.cc
213 # MachO : main13.cc
214 #
215 # echo "Thirteen..."
216 ${CC} ${CXXFLAGS} -flto a13.cc -c -o a13.o
217 ${CC} ${CXXFLAGS} main13.cc -c -o main13.o
218 ${CXX} a13.o main13.o -o main13.exe
219
220fourteen:
221 #
222 # llvm : a14.c b14.c
223 #
224 # echo "verify an used hidden symbol is removed from a dylib"
225 ${CC} ${CXXFLAGS} -O4 -dynamiclib a14.c b14.c -o ab14.dylib
226 ${FAIL_IF_BAD_MACHO} ab14.dylib
227 nm -m ab14.dylib | grep _X | ${PASS_IFF_EMPTY}
228
229fifteen:
230 # echo "verify -dead_strip works with hidden symbols"
231 ${CC} ${CXXFLAGS} -O4 -Wl,-dead_strip a15.c c15.c -o main15.exe
232 ${CC} ${CXXFLAGS} -O4 a15.c c15.c -o main15.exe
233 ${FAIL_IF_BAD_MACHO} main15.exe
234 ${CC} ${CXXFLAGS} -O4 -Wl,-dead_strip -dynamiclib a15.c b15.c -o a15.dylib
235 ${CC} ${CXXFLAGS} -O4 a15.c b15.c -dynamiclib -o a15.dylib
236 ${FAIL_IF_BAD_MACHO} a15.dylib
237
238sixteen:
239 # echo "verify -save-temps"
240 ${CC} ${CCFLAGS} -flto main16.c -c -o main16.o
241 ${CC} ${CCFLAGS} main16.o -o main16.exe -Wl,-save-temps
242 ${PASS_IFF} test -e main16.exe.lto.bc
243 ${PASS_IFF} test -e main16.exe.lto.o
244
245seventeen:
246 # echo "verify ld -r of all bitcode files produces a bitcode file"
247 ${CC} ${CCFLAGS} -flto a17.c -c -o a17.o
248 ${CC} ${CCFLAGS} -flto b17.c -c -o b17.o
249 ${LD} -arch ${ARCH} -r a17.o b17.o -o ab17.o
250 file ab17.o | grep "Mach-O" | ${PASS_IFF_EMPTY}
251 # echo "verify ld -r of bitcode and mach-o produces mach-o"
252 ${CC} ${CCFLAGS} b17.c -c -o b17m.o
253 ${LD} -arch ${ARCH} -r a17.o b17m.o -o ab17m.o
254 file ab17m.o | grep "Mach-O" | ${PASS_IFF_STDIN}
255
256eighteen:
257 #echo verify ld -r -keep_private_externs works
258 ${CC} ${CCFLAGS} -flto a18.c -c -o a18.o
259 ${LD} -arch ${ARCH} -r -keep_private_externs a18.o -o a18-rkpe.o
260 nm -nm a18-rkpe.o | grep _common_hidden1 | grep "private external" | ${FAIL_IF_EMPTY}
261 nm -nm a18-rkpe.o | grep _func_hidden2 | grep "private external" | ${FAIL_IF_EMPTY}
262 #echo verify ld -r makes hidden symbols internal (except for commons)
263 ${LD} -arch ${ARCH} -r a18.o -o a18-r.o
264 #ObjectDump -nm a18-r.o | grep _common_hidden1 | grep " hidden" | ${FAIL_IF_EMPTY}
265 #ObjectDump -nm a18-r.o | grep _func_hidden2 | grep " internal" | ${FAIL_IF_EMPTY}
266
267nineteen:
268 #echo verify missing symbol error
269 ${CC} ${CCFLAGS} -flto main19.c -c -o main19.o
270 ${FAIL_IF_SUCCESS} ${CC} ${CCFLAGS} main19.o -o main19.exe 2>fail.log
271 grep _foo fail.log | ${PASS_IFF_STDIN}
272
273twenty:
274 #echo verify bitcode files in archives works
275 #${CC} ${CCFLAGS} -flto a20.c -c -o a20.o
276 #${CC} ${CCFLAGS} -flto b20.c -c -o b20.o
277 #libtool -static a20.o b20.o -o lib20.a
278 #${CC} ${CCFLAGS} main20.c lib20.a -all_load -o main20.exe
279 #nm main20.exe | grep _foo | ${PASS_IFF_STDIN}
280
281
282
283
284
285clean:
286 rm -rf *.o main*.exe big.* *.dylib main16.*.bc fail.log lib20.a main21.preload lib21.a
287