]>
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 | ||
2f2f92e4 | 28 | |
a645023d A |
29 | IMAGE_INFO = "__image_info" |
30 | ||
31 | ifeq ($(ARCH),x86_64) | |
32 | IMAGE_INFO = "__objc_imageinfo" | |
33 | endif | |
a645023d | 34 | |
afe874b1 | 35 | test: test-${FILEARCH} |
a645023d | 36 | |
afe874b1 A |
37 | test-i386: test-macosx |
38 | test-x86_64: test-macosx | |
39 | test-arm: test-good | |
2f2f92e4 | 40 | |
a61fdf0a A |
41 | # |
42 | # Validate that the linker catches illegal combinations of .o files | |
43 | # compiled with different GC settings. | |
44 | # | |
45 | ||
afe874b1 | 46 | test-macosx: |
a61fdf0a A |
47 | ${CC} ${CCFLAGS} foo.m -c -o foo.o |
48 | ${FAIL_IF_BAD_OBJ} foo.o | |
49 | ||
50 | ${CC} ${CCFLAGS} foo.m -c -o foo-gc.o -fobjc-gc | |
51 | ${FAIL_IF_BAD_OBJ} foo-gc.o | |
52 | ||
53 | ${CC} ${CCFLAGS} foo.m -c -o foo-gc-only.o -fobjc-gc-only | |
54 | ${FAIL_IF_BAD_OBJ} foo-gc-only.o | |
55 | ||
56 | ${CC} ${CCFLAGS} bar.m -c -o bar.o | |
57 | ${FAIL_IF_BAD_OBJ} bar.o | |
58 | ||
59 | ${CC} ${CCFLAGS} bar.m -c -o bar-gc.o -fobjc-gc | |
60 | ${FAIL_IF_BAD_OBJ} bar-gc.o | |
61 | ||
62 | ${CC} ${CCFLAGS} bar.m -c -o bar-gc-only.o -fobjc-gc-only | |
63 | ${FAIL_IF_BAD_OBJ} bar-gc-only.o | |
64 | ||
65 | # check RR + RR -> RR | |
9543cb2f | 66 | ${CC} ${CCFLAGS} foo.o bar.o runtime.c -dynamiclib -o libfoobar.dylib -framework Foundation |
a61fdf0a A |
67 | ${FAIL_IF_BAD_MACHO} libfoobar.dylib |
68 | ||
69 | # check GC/RR + GC/RR -> GC/RR | |
9543cb2f | 70 | ${CC} ${CCFLAGS} foo-gc.o bar-gc.o runtime.c -dynamiclib -o libfoobar.dylib -framework Foundation |
a61fdf0a | 71 | ${FAIL_IF_BAD_MACHO} libfoobar.dylib |
2f2f92e4 | 72 | otool -o libfoobar.dylib | grep -A4 _image | grep flags | grep 0x2 | ${FAIL_IF_EMPTY} |
a61fdf0a A |
73 | |
74 | # check GC + GC -> GC | |
9543cb2f | 75 | ${CC} ${CCFLAGS} foo-gc-only.o bar-gc-only.o runtime.c -dynamiclib -o libfoobar.dylib -framework Foundation |
a61fdf0a | 76 | ${FAIL_IF_BAD_MACHO} libfoobar.dylib |
2f2f92e4 | 77 | otool -o libfoobar.dylib | grep -A4 _image | grep flags | grep 0x6 | ${FAIL_IF_EMPTY} |
a61fdf0a | 78 | |
2f2f92e4 | 79 | # check RR + GC/RR -> RR |
9543cb2f | 80 | ${CC} ${CCFLAGS} foo.o bar-gc.o runtime.c -dynamiclib -o libfoobar.dylib -framework Foundation |
2f2f92e4 A |
81 | ${FAIL_IF_BAD_MACHO} libfoobar.dylib |
82 | otool -o libfoobar.dylib | grep -A4 _image | grep flags | grep 0x[26] | ${FAIL_IF_STDIN} | |
83 | ||
a645023d | 84 | # check GC/RR + RR -> RR |
9543cb2f | 85 | ${CC} ${CCFLAGS} bar-gc.o foo.o runtime.c -dynamiclib -o libfoobar.dylib -framework Foundation |
a645023d A |
86 | ${FAIL_IF_BAD_MACHO} libfoobar.dylib |
87 | otool -o libfoobar.dylib | grep -A4 _image | grep flags | grep 0x[26] | ${FAIL_IF_STDIN} | |
88 | ||
2f2f92e4 | 89 | # check GC + GC/RR -> GC |
9543cb2f | 90 | ${CC} ${CCFLAGS} foo-gc-only.o bar-gc.o runtime.c -dynamiclib -o libfoobar.dylib -framework Foundation |
2f2f92e4 A |
91 | ${FAIL_IF_BAD_MACHO} libfoobar.dylib |
92 | otool -o libfoobar.dylib | grep -A4 _image | grep flags | grep 0x6 | ${FAIL_IF_EMPTY} | |
a61fdf0a A |
93 | |
94 | # check RR + GC -> error | |
9543cb2f | 95 | ${FAIL_IF_SUCCESS} ${CC} ${CCFLAGS} foo.o bar-gc-only.o runtime.c -dynamiclib -o libfoobar.dylib -framework Foundation 2> fail.log |
a61fdf0a | 96 | |
a645023d | 97 | # check cmd line GC/RR, GC/RR + RR -> error |
9543cb2f | 98 | ${FAIL_IF_SUCCESS} ${CC} ${CCFLAGS} foo-gc.o foo.o runtime.c -dynamiclib -o libfoobar.dylib -Wl,-objc_gc -framework Foundation 2> fail.log |
a645023d A |
99 | |
100 | # check GC/RR + compaction | |
9543cb2f | 101 | ${CC} ${CCFLAGS} foo-gc.o bar-gc.o runtime.c -dynamiclib -Wl,-objc_gc_compaction -o libfoobar.dylib -framework Foundation |
a645023d A |
102 | otool -o libfoobar.dylib | grep -A4 _image | grep flags | grep 0x12 | ${FAIL_IF_EMPTY} |
103 | ||
104 | # check GC + compaction | |
9543cb2f | 105 | ${CC} ${CCFLAGS} foo-gc-only.o bar-gc-only.o runtime.c -dynamiclib -Wl,-objc_gc_compaction -o libfoobar.dylib -framework Foundation |
a645023d A |
106 | otool -o libfoobar.dylib | grep -A4 _image | grep flags | grep 0x16 | ${FAIL_IF_EMPTY} |
107 | ||
108 | # none + GC/RR-dylib -> none | |
9543cb2f A |
109 | ${CC} ${CCFLAGS} foo-gc.o runtime.c -dynamiclib -o libfoo.dylib -framework Foundation |
110 | ${CC} ${CCFLAGS} none.c libfoo.dylib -dynamiclib -o libnone.dylib -framework Foundation | |
a645023d A |
111 | size -l libnone.dylib | grep ${IMAGE_INFO} | ${FAIL_IF_STDIN} |
112 | ||
113 | # none + GC-dylib -> none | |
9543cb2f A |
114 | ${CC} ${CCFLAGS} foo-gc-only.o runtime.c -dynamiclib -o libfoo.dylib -framework Foundation |
115 | ${CC} ${CCFLAGS} none.c libfoo.dylib -dynamiclib -o libnone.dylib -framework Foundation | |
a645023d A |
116 | size -l libnone.dylib | grep ${IMAGE_INFO} | ${FAIL_IF_STDIN} |
117 | ||
118 | # none + RR-dylib -> none | |
9543cb2f A |
119 | ${CC} ${CCFLAGS} foo.o runtime.c -dynamiclib -o libfoo.dylib -framework Foundation |
120 | ${CC} ${CCFLAGS} none.c libfoo.dylib -dynamiclib -o libnone.dylib -framework Foundation | |
a645023d A |
121 | size -l libnone.dylib | grep ${IMAGE_INFO} | ${FAIL_IF_STDIN} |
122 | ||
123 | # check RR + GC-dylib -> error | |
9543cb2f A |
124 | ${CC} ${CCFLAGS} foo-gc-only.o runtime.c -dynamiclib -o libfoo.dylib -framework Foundation |
125 | ${FAIL_IF_SUCCESS} ${CC} ${CCFLAGS} bar.o runtime.c -dynamiclib libfoo.dylib -o libbar.dylib -framework Foundation 2> fail.log | |
a645023d A |
126 | |
127 | # check GC + RR-dylib -> error | |
9543cb2f A |
128 | ${CC} ${CCFLAGS} foo.o runtime.c -dynamiclib -o libfoo.dylib -framework Foundation |
129 | ${FAIL_IF_SUCCESS} ${CC} ${CCFLAGS} bar-gc-only.o runtime.c -dynamiclib libfoo.dylib -o libbar.dylib -framework Foundation 2> fail.log | |
a645023d | 130 | |
afe874b1 | 131 | ${PASS_IFF} true |
a645023d | 132 | |
afe874b1 | 133 | test-good: |
a61fdf0a A |
134 | ${PASS_IFF} true |
135 | ||
136 | clean: | |
a645023d | 137 | rm -rf foo*.o bar*.o libfoobar.dylib fail.log libfoo.dylib libnone.dylib |