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