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