]>
Commit | Line | Data |
---|---|---|
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 | ## | |
23 | TESTROOT = ../.. | |
24 | ||
25 | include ${TESTROOT}/include/common.makefile | |
26 | ||
27 | SHELL = bash # use bash shell so we can redirect just stderr | |
28 | ||
29 | ||
30 | LLVMGCC = /Developer/usr/bin/llvm-gcc-4.2 -arch ${ARCH} | |
31 | LLVMGXX = /Developer/usr/bin/llvm-g++-4.2 -arch ${ARCH} | |
32 | LLVMAR = /usr/local/bin/llvm-ar | |
33 | ||
34 | # | |
35 | # Test the we set the stack execution bit properly. | |
36 | ||
37 | run: | |
38 | if [ -f /Developer/usr/bin/llvm-gcc-4.2 ] ; then \ | |
39 | $(MAKE) all ; \ | |
40 | else \ | |
41 | ${PASS_IFF} /usr/bin/true ; \ | |
42 | fi | |
43 | ||
44 | all: zero one two three four five six seven eight nine ten \ | |
45 | eleven twelve thirteen fourteen fifteen sixteen seventeen \ | |
46 | eighteen nineteen | |
47 | ||
48 | zero: | |
49 | # | |
50 | # llvm : a.c : Dfoo3 | |
51 | # llvm : b.c : Dfoo2 | |
52 | # MachO : main.c : Ufoo2, Ufoo3 | |
53 | # | |
54 | #echo "Zero..." | |
55 | ${LLVMGCC} ${CCFLAGS} --emit-llvm a.c -c -o a.o | |
56 | ${LLVMGCC} ${CCFLAGS} --emit-llvm b.c -c -o b.o | |
57 | ${LLVMGCC} ${CCFLAGS} main.c -c -o main.o | |
58 | ${LLVMGCC} ${CCFLAGS} a.o b.o main.o -o main.exe | |
59 | ${PASS_IFF_GOOD_MACHO} main.exe | |
60 | ||
61 | one: | |
62 | # | |
63 | # llvm : a1.c : Dfoo3, Ufoo4 | |
64 | # llvm : b1.c : Dfoo2, Ufoo4 | |
65 | # MachO : main1.c : Dfoo4, Ufoo2, Ufoo3 | |
66 | # | |
67 | #echo "One..." | |
68 | ${LLVMGCC} ${CCFLAGS} --emit-llvm a1.c -c -o a1.o | |
69 | ${LLVMGCC} ${CCFLAGS} --emit-llvm b1.c -c -o b1.o | |
70 | ${LLVMGCC} ${CCFLAGS} main1.c -c -o main1.o | |
71 | ${LLVMGCC} ${CCFLAGS} a1.o b1.o main1.o -o main1.exe | |
72 | ${PASS_IFF_GOOD_MACHO} main1.exe | |
73 | ||
74 | two: | |
75 | # | |
76 | # llvm : a2.c : Dfoo3, Ufoo4 | |
77 | # llvm : b2.c : Dfoo2, Dfoo4 | |
78 | # MachO : main2.c : Ufoo2, Ufoo3 | |
79 | # | |
80 | #echo "Two..." | |
81 | ${LLVMGCC} ${CCFLAGS} --emit-llvm a2.c -c -o a2.o | |
82 | ${LLVMGCC} ${CCFLAGS} --emit-llvm b2.c -c -o b2.o | |
83 | ${LLVMGCC} ${CCFLAGS} main2.c -c -o main2.o | |
84 | ${LLVMGCC} ${CCFLAGS} a2.o b2.o main2.o -o main2.exe | |
85 | ${PASS_IFF_GOOD_MACHO} main2.exe | |
86 | ||
87 | three: | |
88 | # | |
89 | # llvm : a3.c : Dfoo1, Dbar | |
90 | # llvm : b3.c : Dfoo2, Ubar | |
91 | # MachO : main3.c : Ufoo1, Ufoo2, Ubar | |
92 | # | |
93 | #echo "Three..." | |
94 | ${LLVMGCC} ${CCFLAGS} --emit-llvm a3.c -c -o a3.o | |
95 | ${LLVMGCC} ${CCFLAGS} --emit-llvm b3.c -c -o b3.o | |
96 | ${LLVMGCC} ${CCFLAGS} main3.c -c -o main3.o | |
97 | ${LLVMGCC} ${CCFLAGS} a3.o b3.o main3.o -o main3.exe | |
98 | ${PASS_IFF_GOOD_MACHO} main3.exe | |
99 | ||
100 | four: | |
101 | # | |
102 | # llvm : a4.c : Dfoo3, Ufoo4 | |
103 | # llvm : b4.c : Dfoo2, DLmyfoo, Ufoo4 | |
104 | # MachO : main4.c : Dfoo4, Ufoo2, Ufoo3 | |
105 | # | |
106 | #echo "Four..." | |
107 | ${LLVMGCC} ${CCFLAGS} --emit-llvm a4.c -c -o a4.o | |
108 | ${LLVMGCC} ${CCFLAGS} --emit-llvm b4.c -c -o b4.o | |
109 | ${LLVMGCC} ${CCFLAGS} main4.c -c -o main4.o | |
110 | ${LLVMGCC} ${CCFLAGS} a4.o b4.o main4.o -o main4.exe | |
111 | ${PASS_IFF_GOOD_MACHO} main4.exe | |
112 | ||
113 | five: | |
114 | # | |
115 | # llvm : a5.c : Dfoo1, Ufoo2, Ufoo3 | |
116 | # llvm : b5.c : Dfoo2 | |
117 | # MachO : main5.c : Dfoo3, Ufoo1 | |
118 | # | |
119 | #echo "verify that if call to mach-o is optimized away, mach-o func is dead stripped" | |
120 | ${LLVMGCC} ${CCFLAGS} --emit-llvm a5.c -c -o a5.o | |
121 | ${LLVMGCC} ${CCFLAGS} --emit-llvm b5.c -c -o b5.o | |
122 | ${LLVMGCC} ${CCFLAGS} main5.c -c -o main5.o | |
123 | ${LLVMGCC} ${CCFLAGS} a5.o b5.o main5.o -o main5.exe -Wl,-dead_strip | |
124 | ${OTOOL} -tV main5.exe | grep foo3 | ${PASS_IFF_EMPTY} | |
125 | ${PASS_IFF_GOOD_MACHO} main5.exe | |
126 | ||
127 | six: | |
128 | # | |
129 | # llvm : a6.c : Dfoo1, Dfoo2 | |
130 | # MachO : main6.c : Ufoo1 | |
131 | # | |
132 | #echo "verify dead stripping of foo2 in main executable" | |
133 | ${LLVMGCC} ${CCFLAGS} --emit-llvm a6.c -c -o a6.o | |
134 | ${LLVMGCC} ${CCFLAGS} main6.c -c -o main6.o | |
135 | ${LLVMGCC} ${CCFLAGS} a6.o main6.o -o main6.exe -Wl,-dead_strip | |
136 | ${PASS_IFF_GOOD_MACHO} main6.exe | |
137 | ${OTOOL} -tV main6.exe | grep foo2 | ${PASS_IFF_EMPTY} | |
138 | ||
139 | seven: | |
140 | # | |
141 | # llvm : a7.c : Dfoo1, Dfoo2, Ufoo3 | |
142 | # llvm : b7.c : Dfoo3, ufoo2 | |
143 | # MachO : main7.c : Ufoo1 | |
144 | # | |
145 | #echo "Seven..." | |
146 | ${LLVMGCC} ${CCFLAGS} --emit-llvm a7.c -c -o a7.o | |
147 | ${LLVMGCC} ${CCFLAGS} --emit-llvm b7.c -c -o b7.o | |
148 | ${LLVMGCC} ${CCFLAGS} main7.c -c -o main7.o | |
149 | ${LLVMGCC} ${CCFLAGS} a7.o b7.o main7.o -o main7.exe | |
150 | ${PASS_IFF_GOOD_MACHO} main7.exe | |
151 | ||
152 | eight: | |
153 | # | |
154 | # llvm : a8.c : Dfoo1, Dfoo2 | |
155 | # MachO : main8.c : Ufoo1 | |
156 | # | |
157 | #echo "Eight..." | |
158 | ${LLVMGCC} ${CCFLAGS} --emit-llvm a8.c -c -o a8.o | |
159 | ${LLVMGCC} ${CCFLAGS} main8.c -c -o main8.o | |
160 | ${LLVMGCC} ${CCFLAGS} a8.o main8.o -o main8.exe -Wl,-dead_strip | |
161 | ${OTOOL} -tV main8.exe | grep foo2 | ${PASS_IFF_EMPTY} | |
162 | ${OTOOL} -tV main8.exe | grep unnamed_2_1 | ${PASS_IFF_EMPTY} | |
163 | ||
164 | nine: | |
165 | # | |
166 | # llvm : a9.c : Dfoo1, Dfoo2, Dfoo3, Ufoo3, Ufoo4 | |
167 | # MachO : main9.c : Ufoo1, Dfoo4 | |
168 | # | |
169 | #echo "Nine..." | |
170 | ${LLVMGCC} ${CCFLAGS} --emit-llvm a9.c -c -o a9.o | |
171 | ${LLVMGCC} ${CCFLAGS} main9.c -c -o main9.o | |
172 | ${LLVMGCC} ${CCFLAGS} a9.o main9.o -o main9.exe -Wl,-dead_strip | |
173 | ${OTOOL} -tV main9.exe | grep foo2 | ${PASS_IFF_EMPTY} | |
174 | ${OTOOL} -tV main9.exe | grep foo4 | ${PASS_IFF_EMPTY} | |
175 | ${OTOOL} -tV main9.exe | grep unnamed_2_1 | ${PASS_IFF_EMPTY} | |
176 | ||
177 | ten: | |
178 | # | |
179 | # llvm : a10.c | |
180 | # llvm : b10.c | |
181 | # MachO : main10.c | |
182 | # | |
183 | #echo "Ten..." | |
184 | ${LLVMGCC} ${CCFLAGS} --emit-llvm a10.c -c -o a10.o | |
185 | ${LLVMGCC} ${CCFLAGS} --emit-llvm b10.c -c -o b10.o | |
186 | ${LLVMGCC} ${CCFLAGS} main10.c -c -o main10.o | |
187 | ${LLVMGCC} ${CCFLAGS} a10.o b10.o main10.o -o main10.exe | |
188 | ${PASS_IFF_GOOD_MACHO} main10.exe | |
189 | ||
190 | eleven: | |
191 | # | |
192 | # llvm : a11.c | |
193 | # MachO : main11.c | |
194 | # | |
195 | #echo "Eleven..." | |
196 | ${LLVMGCC} ${CCFLAGS} --emit-llvm a11.c -c -o a11.o | |
197 | ${LLVMGCC} ${CCFLAGS} main11.c -c -o main11.o | |
198 | ${LLVMGCC} ${CCFLAGS} a11.o main11.o -o main11.exe | |
199 | ${PASS_IFF_GOOD_MACHO} main11.exe | |
200 | ||
201 | twelve: | |
202 | # | |
203 | # llvm : a12.c | |
204 | # MachO : main12.c | |
205 | # | |
206 | #echo "verify tentative def in llvm .o referenced from mach-o" | |
207 | ${LLVMGCC} ${CCFLAGS} --emit-llvm a12.c -c -o a12.o | |
208 | ${LLVMGCC} ${CCFLAGS} main12.c -c -o main12.o | |
209 | ${LLVMGCC} ${CCFLAGS} a12.o main12.o -o main12.exe | |
210 | ${PASS_IFF_GOOD_MACHO} main12.exe | |
211 | ||
212 | thirteen: | |
213 | # | |
214 | # llvm : a13.cc | |
215 | # MachO : main13.cc | |
216 | # | |
217 | # echo "Thirteen..." | |
218 | ${LLVMGCC} ${CXXFLAGS} --emit-llvm a13.cc -c -o a13.o | |
219 | ${LLVMGCC} ${CXXFLAGS} main13.cc -c -o main13.o | |
220 | ${LLVMGXX} a13.o main13.o -o main13.exe | |
221 | ||
222 | fourteen: | |
223 | # | |
224 | # llvm : a14.c b14.c | |
225 | # | |
226 | # echo "verify an used hidden symbol is removed from a dylib" | |
227 | ${LLVMGCC} ${CXXFLAGS} -O4 -dynamiclib a14.c b14.c -o ab14.dylib | |
228 | ${FAIL_IF_BAD_MACHO} ab14.dylib | |
229 | nm -m ab14.dylib | grep _X | ${PASS_IFF_EMPTY} | |
230 | ||
231 | fifteen: | |
232 | # echo "verify -dead_strip works with hidden symbols" | |
233 | ${LLVMGCC} ${CXXFLAGS} -O4 -Wl,-dead_strip a15.c c15.c -o main15.exe | |
234 | ${LLVMGCC} ${CXXFLAGS} -O4 a15.c c15.c -o main15.exe | |
235 | ${FAIL_IF_BAD_MACHO} main15.exe | |
236 | ${LLVMGCC} ${CXXFLAGS} -O4 -Wl,-dead_strip -dynamiclib a15.c b15.c -o a15.dylib | |
237 | ${LLVMGCC} ${CXXFLAGS} -O4 a15.c b15.c -dynamiclib -o a15.dylib | |
238 | ${FAIL_IF_BAD_MACHO} a15.dylib | |
239 | ||
240 | sixteen: | |
241 | # echo "verify -save-temps" | |
242 | ${LLVMGCC} ${CCFLAGS} --emit-llvm main16.c -c -o main16.o | |
243 | ${LLVMGCC} ${CCFLAGS} main16.o -o main16.exe -Wl,-save-temps | |
244 | ${PASS_IFF} test -e main16.exe.lto.bc | |
245 | ${PASS_IFF} test -e main16.exe.lto.o | |
246 | ||
247 | seventeen: | |
248 | # echo "verify ld -r of all bitcode files produces a bitcode file" | |
249 | ${LLVMGCC} ${CCFLAGS} --emit-llvm a17.c -c -o a17.o | |
250 | ${LLVMGCC} ${CCFLAGS} --emit-llvm b17.c -c -o b17.o | |
251 | ${LD} -arch ${ARCH} -r a17.o b17.o -o ab17.o | |
252 | file ab17.o | grep "Mach-O" | ${PASS_IFF_EMPTY} | |
253 | # echo "verify ld -r of bitcode and mach-o produces mach-o" | |
254 | ${LLVMGCC} ${CCFLAGS} b17.c -c -o b17m.o | |
255 | ${LD} -arch ${ARCH} -r a17.o b17m.o -o ab17m.o | |
256 | file ab17m.o | grep "Mach-O" | ${PASS_IFF_STDIN} | |
257 | ||
258 | eighteen: | |
259 | #echo verify ld -r -keep_private_externs works | |
260 | ${LLVMGCC} ${CCFLAGS} --emit-llvm a18.c -c -o a18.o | |
261 | ${LD} -arch ${ARCH} -r -keep_private_externs a18.o -o a18-rkpe.o | |
262 | nm -nm a18-rkpe.o | grep _common_hidden1 | grep "private external" | ${FAIL_IF_EMPTY} | |
263 | nm -nm a18-rkpe.o | grep _func_hidden2 | grep "private external" | ${FAIL_IF_EMPTY} | |
264 | #echo verify ld -r makes hidden symbols internal (except for commons) | |
265 | ${LD} -arch ${ARCH} -r a18.o -o a18-r.o | |
266 | #ObjectDump -nm a18-r.o | grep _common_hidden1 | grep " hidden" | ${FAIL_IF_EMPTY} | |
267 | #ObjectDump -nm a18-r.o | grep _func_hidden2 | grep " internal" | ${FAIL_IF_EMPTY} | |
268 | ||
269 | nineteen: | |
270 | #echo verify missing symbol error | |
271 | ${LLVMGCC} ${CCFLAGS} --emit-llvm main19.c -c -o main19.o | |
272 | ${FAIL_IF_SUCCESS} ${LLVMGCC} ${CCFLAGS} main19.o -o main19.exe 2>fail.log | |
273 | grep _foo fail.log | ${PASS_IFF_STDIN} | |
274 | ||
275 | twenty: | |
276 | #echo verify bitcode files in archives works | |
277 | #${LLVMGCC} ${CCFLAGS} --emit-llvm a20.c -c -o a20.o | |
278 | #${LLVMGCC} ${CCFLAGS} --emit-llvm b20.c -c -o b20.o | |
279 | #libtool -static a20.o b20.o -o lib20.a | |
280 | #${LLVMGCC} ${CCFLAGS} main20.c lib20.a -all_load -o main20.exe | |
281 | #nm main20.exe | grep _foo | ${PASS_IFF_STDIN} | |
282 | ||
283 | ||
284 | ||
285 | ||
286 | ||
287 | clean: | |
288 | rm -rf *.o main*.exe big.* *.dylib main16.exe.lto.bc fail.log lib20.a main21.preload lib21.a | |
289 |