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.
14 for arch in
$(1); do \
15 if
$(CC
) -arch
$$arch -c \
17 $(ProjSrcRoot
)/make
/platform
/clang_macho_embedded_test_input.c \
18 -o
/dev
/null
> /dev
/null
2> /dev
/null
; then \
19 result
="$$result$$arch "; \
22 "warning: clang_macho_embedded.mk: dropping arch '$$arch' from lib '$(2)'\n"; \
29 result
=`xcrun -find $(1) 2> /dev/null`; \
30 if
[ "$$?" != "0" ]; then result
=$(1); fi
; \
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
)
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
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
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
201 # ARM Assembly implementation which requires Thumb2 (i.e. won't work on v6M).
202 THUMB2_FUNCTIONS
:= \
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
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
:= \
242 udiv_w_sdiv unorddf2 unordsf2 bswapdi2 \
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
))
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
)