]>
Commit | Line | Data |
---|---|---|
a61fdf0a | 1 | ## |
2f2f92e4 | 2 | # Copyright (c) 2007-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 = ../.. | |
24 | include ${TESTROOT}/include/common.makefile | |
25 | ||
26 | SHELL = bash # use bash shell so we can redirect just stderr | |
27 | ||
0a8dc3df A |
28 | # |
29 | # Validate that the linker catches illegal combinations of .o files | |
30 | # compiled with different GC settings. | |
31 | # | |
2f2f92e4 | 32 | |
0a8dc3df A |
33 | IMAGE_INFO = "__objc_imageinfo" |
34 | ifeq ($(ARCH),i386) | |
35 | IMAGE_INFO = "__image_info" | |
36 | endif | |
a645023d | 37 | |
0a8dc3df A |
38 | ifeq ($(ARCH),i386) |
39 | ALL = all-gc | |
40 | else | |
a645023d | 41 | ifeq ($(ARCH),x86_64) |
0a8dc3df A |
42 | ALL = all-gc |
43 | else | |
44 | ALL = all-nogc | |
45 | endif | |
a645023d | 46 | endif |
a645023d | 47 | |
0a8dc3df | 48 | all: ${ALL} |
2f2f92e4 | 49 | |
0a8dc3df A |
50 | # For platforms that do not support GC. |
51 | all-nogc: | |
52 | ${PASS_IFF} true | |
a61fdf0a | 53 | |
0a8dc3df A |
54 | # For platforms that support GC. |
55 | all-gc: | |
a61fdf0a A |
56 | ${CC} ${CCFLAGS} foo.m -c -o foo.o |
57 | ${FAIL_IF_BAD_OBJ} foo.o | |
58 | ||
a61fdf0a A |
59 | ${CC} ${CCFLAGS} bar.m -c -o bar.o |
60 | ${FAIL_IF_BAD_OBJ} bar.o | |
61 | ||
0a8dc3df A |
62 | # clang no longer builds GC so we create fake GC object files instead. |
63 | ||
64 | cp -f foo.o foo-gc.o | |
65 | ${OBJCIMAGEINFO} +supports-gc foo-gc.o | |
a61fdf0a | 66 | |
0a8dc3df A |
67 | cp -f foo.o foo-gc-only.o |
68 | ${OBJCIMAGEINFO} +supports-gc +requires-gc foo-gc-only.o | |
69 | ||
70 | cp -f bar.o bar-gc.o | |
71 | ${OBJCIMAGEINFO} +supports-gc bar-gc.o | |
72 | ||
73 | cp -f bar.o bar-gc-only.o | |
74 | ${OBJCIMAGEINFO} +supports-gc +requires-gc bar-gc-only.o | |
a61fdf0a A |
75 | |
76 | # check RR + RR -> RR | |
9543cb2f | 77 | ${CC} ${CCFLAGS} foo.o bar.o runtime.c -dynamiclib -o libfoobar.dylib -framework Foundation |
a61fdf0a A |
78 | ${FAIL_IF_BAD_MACHO} libfoobar.dylib |
79 | ||
80 | # check GC/RR + GC/RR -> GC/RR | |
9543cb2f | 81 | ${CC} ${CCFLAGS} foo-gc.o bar-gc.o runtime.c -dynamiclib -o libfoobar.dylib -framework Foundation |
a61fdf0a | 82 | ${FAIL_IF_BAD_MACHO} libfoobar.dylib |
0a8dc3df | 83 | ${OBJCIMAGEINFO} libfoobar.dylib | grep supports-gc | ${FAIL_IF_EMPTY} |
a61fdf0a A |
84 | |
85 | # check GC + GC -> GC | |
9543cb2f | 86 | ${CC} ${CCFLAGS} foo-gc-only.o bar-gc-only.o runtime.c -dynamiclib -o libfoobar.dylib -framework Foundation |
a61fdf0a | 87 | ${FAIL_IF_BAD_MACHO} libfoobar.dylib |
0a8dc3df | 88 | ${OBJCIMAGEINFO} libfoobar.dylib | grep 'supports-gc requires-gc' | ${FAIL_IF_EMPTY} |
a61fdf0a | 89 | |
2f2f92e4 | 90 | # check RR + GC/RR -> RR |
9543cb2f | 91 | ${CC} ${CCFLAGS} foo.o bar-gc.o runtime.c -dynamiclib -o libfoobar.dylib -framework Foundation |
2f2f92e4 | 92 | ${FAIL_IF_BAD_MACHO} libfoobar.dylib |
0a8dc3df | 93 | ${OBJCIMAGEINFO} libfoobar.dylib | grep gc | ${FAIL_IF_STDIN} |
2f2f92e4 | 94 | |
a645023d | 95 | # check GC/RR + RR -> RR |
9543cb2f | 96 | ${CC} ${CCFLAGS} bar-gc.o foo.o runtime.c -dynamiclib -o libfoobar.dylib -framework Foundation |
a645023d | 97 | ${FAIL_IF_BAD_MACHO} libfoobar.dylib |
0a8dc3df | 98 | ${OBJCIMAGEINFO} libfoobar.dylib | grep gc | ${FAIL_IF_STDIN} |
a645023d | 99 | |
2f2f92e4 | 100 | # check GC + GC/RR -> GC |
9543cb2f | 101 | ${CC} ${CCFLAGS} foo-gc-only.o bar-gc.o runtime.c -dynamiclib -o libfoobar.dylib -framework Foundation |
2f2f92e4 | 102 | ${FAIL_IF_BAD_MACHO} libfoobar.dylib |
0a8dc3df | 103 | ${OBJCIMAGEINFO} libfoobar.dylib | grep 'supports-gc requires-gc' | ${FAIL_IF_EMPTY} |
a61fdf0a A |
104 | |
105 | # check RR + GC -> error | |
9543cb2f | 106 | ${FAIL_IF_SUCCESS} ${CC} ${CCFLAGS} foo.o bar-gc-only.o runtime.c -dynamiclib -o libfoobar.dylib -framework Foundation 2> fail.log |
a61fdf0a | 107 | |
a645023d | 108 | # check cmd line GC/RR, GC/RR + RR -> error |
9543cb2f | 109 | ${FAIL_IF_SUCCESS} ${CC} ${CCFLAGS} foo-gc.o foo.o runtime.c -dynamiclib -o libfoobar.dylib -Wl,-objc_gc -framework Foundation 2> fail.log |
0a8dc3df | 110 | |
a645023d | 111 | # check GC/RR + compaction |
9543cb2f | 112 | ${CC} ${CCFLAGS} foo-gc.o bar-gc.o runtime.c -dynamiclib -Wl,-objc_gc_compaction -o libfoobar.dylib -framework Foundation |
0a8dc3df | 113 | ${OBJCIMAGEINFO} libfoobar.dylib | grep 0x12 | ${FAIL_IF_EMPTY} |
a645023d A |
114 | |
115 | # check GC + compaction | |
9543cb2f | 116 | ${CC} ${CCFLAGS} foo-gc-only.o bar-gc-only.o runtime.c -dynamiclib -Wl,-objc_gc_compaction -o libfoobar.dylib -framework Foundation |
0a8dc3df | 117 | ${OBJCIMAGEINFO} libfoobar.dylib | grep 0x16 | ${FAIL_IF_EMPTY} |
a645023d A |
118 | |
119 | # none + GC/RR-dylib -> none | |
9543cb2f A |
120 | ${CC} ${CCFLAGS} foo-gc.o runtime.c -dynamiclib -o libfoo.dylib -framework Foundation |
121 | ${CC} ${CCFLAGS} none.c libfoo.dylib -dynamiclib -o libnone.dylib -framework Foundation | |
0a8dc3df | 122 | size -m -l libnone.dylib | grep ${IMAGE_INFO} | ${FAIL_IF_STDIN} |
a645023d A |
123 | |
124 | # none + GC-dylib -> none | |
9543cb2f A |
125 | ${CC} ${CCFLAGS} foo-gc-only.o runtime.c -dynamiclib -o libfoo.dylib -framework Foundation |
126 | ${CC} ${CCFLAGS} none.c libfoo.dylib -dynamiclib -o libnone.dylib -framework Foundation | |
0a8dc3df | 127 | size -m -l libnone.dylib | grep ${IMAGE_INFO} | ${FAIL_IF_STDIN} |
a645023d A |
128 | |
129 | # none + RR-dylib -> none | |
9543cb2f A |
130 | ${CC} ${CCFLAGS} foo.o runtime.c -dynamiclib -o libfoo.dylib -framework Foundation |
131 | ${CC} ${CCFLAGS} none.c libfoo.dylib -dynamiclib -o libnone.dylib -framework Foundation | |
0a8dc3df | 132 | size -m -l libnone.dylib | grep ${IMAGE_INFO} | ${FAIL_IF_STDIN} |
a645023d A |
133 | |
134 | # check RR + GC-dylib -> error | |
9543cb2f A |
135 | ${CC} ${CCFLAGS} foo-gc-only.o runtime.c -dynamiclib -o libfoo.dylib -framework Foundation |
136 | ${FAIL_IF_SUCCESS} ${CC} ${CCFLAGS} bar.o runtime.c -dynamiclib libfoo.dylib -o libbar.dylib -framework Foundation 2> fail.log | |
a645023d A |
137 | |
138 | # check GC + RR-dylib -> error | |
9543cb2f A |
139 | ${CC} ${CCFLAGS} foo.o runtime.c -dynamiclib -o libfoo.dylib -framework Foundation |
140 | ${FAIL_IF_SUCCESS} ${CC} ${CCFLAGS} bar-gc-only.o runtime.c -dynamiclib libfoo.dylib -o libbar.dylib -framework Foundation 2> fail.log | |
a645023d | 141 | |
afe874b1 | 142 | ${PASS_IFF} true |
a645023d | 143 | |
a61fdf0a | 144 | clean: |
a645023d | 145 | rm -rf foo*.o bar*.o libfoobar.dylib fail.log libfoo.dylib libnone.dylib |