ARM: implement __sync_fetch_and_* operations
[blocksruntime.git] / make / platform / clang_macho_embedded.mk
blob827978e7fe9403a9b48d82cde966c3b391e5f46d
1 # These are the functions which clang needs when it is targetting a previous
2 # version of the OS. The issue is that the backend may use functions which were
3 # not present in the libgcc that shipped on the platform. In such cases, we link
4 # with a version of the library which contains private_extern definitions of all
5 # the extra functions which might be referenced.
7 Description := Static runtime libraries for embedded clang/Darwin
9 # A function that ensures we don't try to build for architectures that we
10 # don't have working toolchains for.
11 CheckArches = \
12 $(shell \
13 result=""; \
14 for arch in $(1); do \
15 if $(CC) -arch $$arch -c \
16 -integrated-as \
17 $(ProjSrcRoot)/make/platform/clang_macho_embedded_test_input.c \
18 -o /dev/null > /dev/null 2> /dev/null; then \
19 result="$$result$$arch "; \
20 else \
21 printf 1>&2 \
22 "warning: clang_macho_embedded.mk: dropping arch '$$arch' from lib '$(2)'\n"; \
23 fi; \
24 done; \
25 echo $$result)
27 XCRun = \
28 $(shell \
29 result=`xcrun -find $(1) 2> /dev/null`; \
30 if [ "$$?" != "0" ]; then result=$(1); fi; \
31 echo $$result)
33 ###
35 CC := $(call XCRun,clang)
36 AR := $(call XCRun,ar)
37 RANLIB := $(call XCRun,ranlib)
38 STRIP := $(call XCRun,strip)
39 LIPO := $(call XCRun,lipo)
40 DSYMUTIL := $(call XCRun,dsymutil)
42 Configs :=
43 UniversalArchs :=
45 # Soft-float version of the runtime. No floating-point instructions will be used
46 # and the ABI (out of necessity) passes floating values in normal registers:
47 # non-VFP variant of the AAPCS.
48 UniversalArchs.soft_static := $(call CheckArches,armv6m armv7m armv7em armv7,soft_static)
49 Configs += $(if $(UniversalArchs.soft_static),soft_static)
51 # Hard-float version of the runtime. On ARM VFP instructions and registers are
52 # allowed, and floating point values get passed in them. VFP variant of the
53 # AAPCS.
54 UniversalArchs.hard_static := $(call CheckArches,armv7em armv7 i386 x86_64,hard_static)
55 Configs += $(if $(UniversalArchs.hard_static),hard_static)
57 UniversalArchs.soft_pic := $(call CheckArches,armv6m armv7m armv7em armv7,soft_pic)
58 Configs += $(if $(UniversalArchs.soft_pic),soft_pic)
60 UniversalArchs.hard_pic := $(call CheckArches,armv7em armv7 i386 x86_64,hard_pic)
61 Configs += $(if $(UniversalArchs.hard_pic),hard_pic)
63 CFLAGS := -Wall -Werror -Oz -fomit-frame-pointer -ffreestanding
65 PIC_CFLAGS := -fPIC
66 STATIC_CFLAGS := -static
68 CFLAGS_SOFT := -mfloat-abi=soft
69 CFLAGS_HARD := -mfloat-abi=hard
71 CFLAGS_ARMV7 := -target thumbv7-apple-darwin-eabi
72 CFLAGS_I386 := -march=pentium
74 CFLAGS.soft_static := $(CFLAGS) $(STATIC_CFLAGS) $(CFLAGS_SOFT)
75 CFLAGS.hard_static := $(CFLAGS) $(STATIC_CFLAGS) $(CFLAGS_HARD)
76 CFLAGS.soft_pic := $(CFLAGS) $(PIC_CFLAGS) $(CFLAGS_SOFT)
77 CFLAGS.hard_pic := $(CFLAGS) $(PIC_CFLAGS) $(CFLAGS_HARD)
79 CFLAGS.soft_static.armv7 := $(CFLAGS.soft_static) $(CFLAGS_ARMV7)
80 CFLAGS.hard_static.armv7 := $(CFLAGS.hard_static) $(CFLAGS_ARMV7)
81 CFLAGS.soft_pic.armv7 := $(CFLAGS.soft_pic) $(CFLAGS_ARMV7)
82 CFLAGS.hard_pic.armv7 := $(CFLAGS.hard_pic) $(CFLAGS_ARMV7)
84 # x86 platforms ignore -mfloat-abi options and complain about doing so. Despite
85 # this they're hard-float.
86 CFLAGS.hard_static.i386 := $(CFLAGS) $(STATIC_CFLAGS) $(CFLAGS_I386)
87 CFLAGS.hard_pic.i386 := $(CFLAGS) $(PIC_CFLAGS) $(CFLAGS_I386)
88 CFLAGS.hard_static.x86_64 := $(CFLAGS) $(STATIC_CFLAGS)
89 CFLAGS.hard_pic.x86_64 := $(CFLAGS) $(PIC_CFLAGS)
91 # Functions not wanted:
92 # + eprintf is obsolete anyway
93 # + *vfp: designed for Thumb1 CPUs with VFPv2
95 COMMON_FUNCTIONS := \
96 absvdi2 \
97 absvsi2 \
98 addvdi3 \
99 addvsi3 \
100 ashldi3 \
101 ashrdi3 \
102 bswapdi2 \
103 bswapsi2 \
104 clzdi2 \
105 clzsi2 \
106 cmpdi2 \
107 ctzdi2 \
108 ctzsi2 \
109 divdc3 \
110 divdi3 \
111 divsc3 \
112 divmodsi4 \
113 udivmodsi4 \
114 do_global_dtors \
115 ffsdi2 \
116 fixdfdi \
117 fixsfdi \
118 fixunsdfdi \
119 fixunsdfsi \
120 fixunssfdi \
121 fixunssfsi \
122 floatdidf \
123 floatdisf \
124 floatundidf \
125 floatundisf \
126 gcc_bcmp \
127 lshrdi3 \
128 moddi3 \
129 muldc3 \
130 muldi3 \
131 mulsc3 \
132 mulvdi3 \
133 mulvsi3 \
134 negdi2 \
135 negvdi2 \
136 negvsi2 \
137 paritydi2 \
138 paritysi2 \
139 popcountdi2 \
140 popcountsi2 \
141 powidf2 \
142 powisf2 \
143 subvdi3 \
144 subvsi3 \
145 ucmpdi2 \
146 udiv_w_sdiv \
147 udivdi3 \
148 udivmoddi4 \
149 umoddi3 \
150 adddf3 \
151 addsf3 \
152 cmpdf2 \
153 cmpsf2 \
154 div0 \
155 divdf3 \
156 divsf3 \
157 divsi3 \
158 extendsfdf2 \
159 ffssi2 \
160 fixdfsi \
161 fixsfsi \
162 floatsidf \
163 floatsisf \
164 floatunsidf \
165 floatunsisf \
166 comparedf2 \
167 comparesf2 \
168 modsi3 \
169 muldf3 \
170 mulsf3 \
171 negdf2 \
172 negsf2 \
173 subdf3 \
174 subsf3 \
175 truncdfsf2 \
176 udivsi3 \
177 umodsi3 \
178 unorddf2 \
179 unordsf2
181 ARM_FUNCTIONS := \
182 aeabi_cdcmpeq \
183 aeabi_cdrcmple \
184 aeabi_cfcmpeq \
185 aeabi_cfrcmple \
186 aeabi_dcmpeq \
187 aeabi_dcmpge \
188 aeabi_dcmpgt \
189 aeabi_dcmple \
190 aeabi_dcmplt \
191 aeabi_drsub \
192 aeabi_fcmpeq \
193 aeabi_fcmpge \
194 aeabi_fcmpgt \
195 aeabi_fcmple \
196 aeabi_fcmplt \
197 aeabi_frsub \
198 aeabi_idivmod \
199 aeabi_uidivmod \
201 # ARM Assembly implementation which requires Thumb2 (i.e. won't work on v6M).
202 THUMB2_FUNCTIONS := \
203 switch16 \
204 switch32 \
205 switch8 \
206 switchu8 \
207 sync_fetch_and_add_4 \
208 sync_fetch_and_sub_4 \
209 sync_fetch_and_and_4 \
210 sync_fetch_and_or_4 \
211 sync_fetch_and_xor_4 \
212 sync_fetch_and_nand_4 \
213 sync_fetch_and_max_4 \
214 sync_fetch_and_umax_4 \
215 sync_fetch_and_min_4 \
216 sync_fetch_and_umin_4 \
217 sync_fetch_and_add_8 \
218 sync_fetch_and_sub_8 \
219 sync_fetch_and_and_8 \
220 sync_fetch_and_or_8 \
221 sync_fetch_and_xor_8 \
222 sync_fetch_and_nand_8 \
223 sync_fetch_and_max_8 \
224 sync_fetch_and_umax_8 \
225 sync_fetch_and_min_8 \
226 sync_fetch_and_umin_8
228 I386_FUNCTIONS := \
229 i686.get_pc_thunk.eax \
230 i686.get_pc_thunk.ebp \
231 i686.get_pc_thunk.ebx \
232 i686.get_pc_thunk.ecx \
233 i686.get_pc_thunk.edi \
234 i686.get_pc_thunk.edx \
235 i686.get_pc_thunk.esi
237 # FIXME: Currently, compiler-rt is missing implementations for a number of the
238 # functions. Filter them out for now.
239 MISSING_FUNCTIONS := \
240 cmpdf2 cmpsf2 div0 \
241 ffssi2 \
242 udiv_w_sdiv unorddf2 unordsf2 bswapdi2 \
243 bswapsi2 \
244 gcc_bcmp \
245 do_global_dtors \
246 i686.get_pc_thunk.eax i686.get_pc_thunk.ebp i686.get_pc_thunk.ebx \
247 i686.get_pc_thunk.ecx i686.get_pc_thunk.edi i686.get_pc_thunk.edx \
248 i686.get_pc_thunk.esi \
249 aeabi_cdcmpeq aeabi_cdrcmple aeabi_cfcmpeq aeabi_cfrcmple aeabi_dcmpeq \
250 aeabi_dcmpge aeabi_dcmpgt aeabi_dcmple aeabi_dcmplt aeabi_drsub \
251 aeabi_fcmpeq \ aeabi_fcmpge aeabi_fcmpgt aeabi_fcmple aeabi_fcmplt \
252 aeabi_frsub aeabi_idivmod aeabi_uidivmod
254 FUNCTIONS_ARMV6M := $(COMMON_FUNCTIONS) $(ARM_FUNCTIONS)
255 FUNCTIONS_ARM_ALL := $(COMMON_FUNCTIONS) $(ARM_FUNCTIONS) $(THUMB2_FUNCTIONS)
256 FUNCTIONS_I386 := $(COMMON_FUNCTIONS) $(I386_FUNCTIONS)
257 FUNCTIONS_X86_64 := $(COMMON_FUNCTIONS)
259 FUNCTIONS_ARMV6M := \
260 $(filter-out $(MISSING_FUNCTIONS),$(FUNCTIONS_ARMV6M))
261 FUNCTIONS_ARM_ALL := \
262 $(filter-out $(MISSING_FUNCTIONS),$(FUNCTIONS_ARM_ALL))
263 FUNCTIONS_I386 := \
264 $(filter-out $(MISSING_FUNCTIONS),$(FUNCTIONS_I386))
265 FUNCTIONS_X86_64 := \
266 $(filter-out $(MISSING_FUNCTIONS),$(FUNCTIONS_X86_64))
268 FUNCTIONS.soft_static.armv6m := $(FUNCTIONS_ARMV6M)
269 FUNCTIONS.soft_pic.armv6m := $(FUNCTIONS_ARMV6M)
271 FUNCTIONS.soft_static.armv7m := $(FUNCTIONS_ARM_ALL)
272 FUNCTIONS.soft_pic.armv7m := $(FUNCTIONS_ARM_ALL)
274 FUNCTIONS.soft_static.armv7em := $(FUNCTIONS_ARM_ALL)
275 FUNCTIONS.hard_static.armv7em := $(FUNCTIONS_ARM_ALL)
276 FUNCTIONS.soft_pic.armv7em := $(FUNCTIONS_ARM_ALL)
277 FUNCTIONS.hard_pic.armv7em := $(FUNCTIONS_ARM_ALL)
279 FUNCTIONS.soft_static.armv7 := $(FUNCTIONS_ARM_ALL)
280 FUNCTIONS.hard_static.armv7 := $(FUNCTIONS_ARM_ALL)
281 FUNCTIONS.soft_pic.armv7 := $(FUNCTIONS_ARM_ALL)
282 FUNCTIONS.hard_pic.armv7 := $(FUNCTIONS_ARM_ALL)
284 FUNCTIONS.hard_static.i386 := $(FUNCTIONS_I386)
285 FUNCTIONS.hard_pic.i386 := $(FUNCTIONS_I386)
287 FUNCTIONS.hard_static.x86_64 := $(FUNCTIONS_X86_64)
288 FUNCTIONS.hard_pic.x86_64 := $(FUNCTIONS_X86_64)