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