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 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_darwin_test_input.c \
18 -isysroot
$(ProjSrcRoot
)/SDKs
/darwin \
19 -o
/dev
/null
> /dev
/null
2> /dev
/null
; then \
20 result
="$$result$$arch "; \
23 "warning: clang_darwin.mk: dropping arch '$$arch' from lib '$(2)'\n"; \
35 # Configuration solely for providing access to an eprintf symbol, which may
36 # still be referenced from Darwin system headers. This symbol is only ever
39 UniversalArchs.eprintf
:= $(call CheckArches
,i386
,eprintf
)
41 # Configuration for targetting 10.4. We need a few functions missing from
42 # libgcc_s.10.4.dylib. We only build x86 slices since clang doesn't really
43 # support targetting PowerPC.
45 UniversalArchs
.10.4 := $(call CheckArches
,i386 x86_64
,10.4)
47 # Configuration for targetting iOS for a couple of functions that didn't
48 # make it into libSystem.
50 UniversalArchs.ios
:= $(call CheckArches
,i386 x86_64 armv7
,ios
)
52 # Configuration for targetting OSX. These functions may not be in libSystem
53 # so we should provide our own.
55 UniversalArchs.osx
:= $(call CheckArches
,i386 x86_64
,osx
)
57 # Configuration for use with kernel/kexts.
59 UniversalArchs.cc_kext
:= $(call CheckArches
,armv7 i386 x86_64
,cc_kext
)
61 # Configuration for use with kernel/kexts for iOS 5.0 and earlier (which used
62 # a different code generation strategy).
63 Configs
+= cc_kext_ios5
64 UniversalArchs.cc_kext_ios5
:= $(call CheckArches
,x86_64 armv7
,cc_kext_ios5
)
66 # Configurations which define the profiling support functions.
67 Configs
+= profile_osx
68 UniversalArchs.profile_osx
:= $(call CheckArches
,i386 x86_64
,profile_osx
)
69 Configs
+= profile_ios
70 UniversalArchs.profile_ios
:= $(call CheckArches
,i386 x86_64 armv7
,profile_ios
)
72 # Configurations which define the ASAN support functions.
74 UniversalArchs.asan_osx
:= $(call CheckArches
,i386 x86_64
,asan_osx
)
76 Configs
+= asan_osx_dynamic
77 UniversalArchs.asan_osx_dynamic
:= $(call CheckArches
,i386 x86_64
,asan_osx_dynamic
)
80 UniversalArchs.ubsan_osx
:= $(call CheckArches
,i386 x86_64
,ubsan_osx
)
82 # Darwin 10.6 has a bug in cctools that makes it unable to use ranlib on our ARM
83 # object files. If we are on that platform, strip out all ARM archs. We still
84 # build the libraries themselves so that Clang can find them where it expects
85 # them, even though they might not have an expected slice.
86 ifneq ($(shell which sw_vers
),)
87 ifneq ($(shell sw_vers
-productVersion | grep
10.6),)
88 UniversalArchs.ios
:= $(filter-out armv7
, $(UniversalArchs.ios
))
89 UniversalArchs.cc_kext
:= $(filter-out armv7
, $(UniversalArchs.cc_kext
))
90 UniversalArchs.cc_kext_ios5
:= $(filter-out armv7
, $(UniversalArchs.cc_kext_ios5
))
91 UniversalArchs.profile_ios
:= $(filter-out armv7
, $(UniversalArchs.profile_ios
))
95 # If RC_SUPPORTED_ARCHS is defined, treat it as a list of the architectures we
96 # are intended to support and limit what we try to build to that.
98 # We make sure to remove empty configs if we end up dropping all the requested
99 # archs for a particular config.
100 ifneq ($(RC_SUPPORTED_ARCHS
),)
101 $(foreach config
,$(Configs
),\
102 $(call Set
,UniversalArchs.
$(config
),\
103 $(filter $(RC_SUPPORTED_ARCHS
),$(UniversalArchs.
$(config
))))\
104 $(if
$(UniversalArchs.
$(config
)),,\
105 $(call Set
,Configs
,$(filter-out $(config
),$(Configs
)))))
110 # Forcibly strip off any -arch, as that totally breaks our universal support.
111 override CC
:= $(subst -arch
,-arch_
,$(CC
))
112 override CC
:= $(patsubst -arch_
%,,$(CC
))
114 CFLAGS
:= -Wall
-Werror
-O3
-fomit-frame-pointer
116 # Always set deployment target arguments for every build, these libraries should
117 # never depend on the environmental overrides. We simply set them to minimum
118 # supported deployment target -- nothing in the compiler-rt libraries should
119 # actually depend on the deployment target.
120 OSX_DEPLOYMENT_ARGS
:= -mmacosx-version-min
=10.4
121 IOS_DEPLOYMENT_ARGS
:= -miphoneos-version-min
=1.0
122 IOS6_DEPLOYMENT_ARGS
:= -miphoneos-version-min
=6.0
123 IOSSIM_DEPLOYMENT_ARGS
:= -miphoneos-version-min
=1.0
125 # Use our stub SDK as the sysroot to support more portable building.
126 OSX_DEPLOYMENT_ARGS
+= -isysroot
$(ProjSrcRoot
)/SDKs
/darwin
127 IOS_DEPLOYMENT_ARGS
+= -isysroot
$(ProjSrcRoot
)/SDKs
/darwin
128 IOS6_DEPLOYMENT_ARGS
+= -isysroot
$(ProjSrcRoot
)/SDKs
/darwin
129 IOSSIM_DEPLOYMENT_ARGS
+= -isysroot
$(ProjSrcRoot
)/SDKs
/darwin
131 CFLAGS.eprintf
:= $(CFLAGS
) $(OSX_DEPLOYMENT_ARGS
)
132 CFLAGS
.10.4 := $(CFLAGS
) $(OSX_DEPLOYMENT_ARGS
)
133 # FIXME: We can't build ASAN with our stub SDK yet.
134 CFLAGS.asan_osx
:= $(CFLAGS
) -mmacosx-version-min
=10.5 -fno-builtin \
135 -DASAN_FLEXIBLE_MAPPING_AND_OFFSET
=1
136 CFLAGS.asan_osx_dynamic
:= \
137 $(CFLAGS
) -mmacosx-version-min
=10.5 -fno-builtin \
138 -DMAC_INTERPOSE_FUNCTIONS
=1 \
139 -DASAN_FLEXIBLE_MAPPING_AND_OFFSET
=1
141 CFLAGS.ubsan_osx
:= $(CFLAGS
) -mmacosx-version-min
=10.5 -fno-builtin
143 CFLAGS.ios.i386
:= $(CFLAGS
) $(IOSSIM_DEPLOYMENT_ARGS
)
144 CFLAGS.ios.x86_64
:= $(CFLAGS
) $(IOSSIM_DEPLOYMENT_ARGS
)
145 CFLAGS.ios.armv7
:= $(CFLAGS
) $(IOS_DEPLOYMENT_ARGS
)
146 CFLAGS.ios.armv7f
:= $(CFLAGS
) $(IOS_DEPLOYMENT_ARGS
)
147 CFLAGS.ios.armv7k
:= $(CFLAGS
) $(IOS_DEPLOYMENT_ARGS
)
148 CFLAGS.ios.armv7s
:= $(CFLAGS
) $(IOS_DEPLOYMENT_ARGS
)
149 CFLAGS.osx.i386
:= $(CFLAGS
) $(OSX_DEPLOYMENT_ARGS
)
150 CFLAGS.osx.x86_64
:= $(CFLAGS
) $(OSX_DEPLOYMENT_ARGS
)
151 CFLAGS.cc_kext.i386
:= $(CFLAGS
) $(OSX_DEPLOYMENT_ARGS
)
152 CFLAGS.cc_kext.x86_64
:= $(CFLAGS
) $(OSX_DEPLOYMENT_ARGS
)
153 CFLAGS.cc_kext.armv7
:= $(CFLAGS
) $(IOS6_DEPLOYMENT_ARGS
)
154 CFLAGS.cc_kext.armv7f
:= $(CFLAGS
) $(IOS6_DEPLOYMENT_ARGS
)
155 CFLAGS.cc_kext.armv7k
:= $(CFLAGS
) $(IOS6_DEPLOYMENT_ARGS
)
156 CFLAGS.cc_kext.armv7s
:= $(CFLAGS
) $(IOS6_DEPLOYMENT_ARGS
)
157 CFLAGS.cc_kext_ios5.armv7
:= $(CFLAGS
) $(IOS_DEPLOYMENT_ARGS
)
158 CFLAGS.cc_kext_ios5.armv7f
:= $(CFLAGS
) $(IOS_DEPLOYMENT_ARGS
)
159 CFLAGS.cc_kext_ios5.armv7k
:= $(CFLAGS
) $(IOS_DEPLOYMENT_ARGS
)
160 CFLAGS.cc_kext_ios5.armv7s
:= $(CFLAGS
) $(IOS_DEPLOYMENT_ARGS
)
161 CFLAGS.profile_osx.i386
:= $(CFLAGS
) $(OSX_DEPLOYMENT_ARGS
)
162 CFLAGS.profile_osx.x86_64
:= $(CFLAGS
) $(OSX_DEPLOYMENT_ARGS
)
163 CFLAGS.profile_ios.i386
:= $(CFLAGS
) $(IOSSIM_DEPLOYMENT_ARGS
)
164 CFLAGS.profile_ios.x86_64
:= $(CFLAGS
) $(IOSSIM_DEPLOYMENT_ARGS
)
165 CFLAGS.profile_ios.armv7
:= $(CFLAGS
) $(IOS_DEPLOYMENT_ARGS
)
166 CFLAGS.profile_ios.armv7f
:= $(CFLAGS
) $(IOS_DEPLOYMENT_ARGS
)
167 CFLAGS.profile_ios.armv7k
:= $(CFLAGS
) $(IOS_DEPLOYMENT_ARGS
)
168 CFLAGS.profile_ios.armv7s
:= $(CFLAGS
) $(IOS_DEPLOYMENT_ARGS
)
170 # Configure the asan_osx_dynamic library to be built shared.
171 SHARED_LIBRARY.asan_osx_dynamic
:= 1
172 LDFLAGS.asan_osx_dynamic
:= -framework Foundation
-lstdc
++ -undefined dynamic_lookup
174 FUNCTIONS.eprintf
:= eprintf
175 FUNCTIONS
.10.4 := eprintf floatundidf floatundisf floatundixf
177 FUNCTIONS.ios
:= divmodsi4 udivmodsi4 mulosi4 mulodi4 muloti4
178 # On x86, the divmod functions reference divsi.
179 FUNCTIONS.ios.i386
:= $(FUNCTIONS.ios
) \
181 FUNCTIONS.ios.x86_64
:= $(FUNCTIONS.ios
) \
184 FUNCTIONS.osx
:= mulosi4 mulodi4 muloti4
186 FUNCTIONS.profile_osx
:= GCDAProfiling
187 FUNCTIONS.profile_ios
:= GCDAProfiling
189 FUNCTIONS.asan_osx
:= $(AsanFunctions
) $(InterceptionFunctions
) \
190 $(SanitizerCommonFunctions
)
191 FUNCTIONS.asan_osx_dynamic
:= $(AsanFunctions
) $(InterceptionFunctions
) \
192 $(SanitizerCommonFunctions
) \
193 $(AsanDynamicFunctions
)
195 FUNCTIONS.ubsan_osx
:= $(UbsanFunctions
) $(SanitizerCommonFunctions
)
197 CCKEXT_COMMON_FUNCTIONS
:= \
254 CCKEXT_ARM_FUNCTIONS
:= $(CCKEXT_COMMON_FUNCTIONS
) \
308 CCKEXT_ARMVFP_FUNCTIONS
:= $(CCKEXT_ARM_FUNCTIONS
) \
342 FUNCTIONS.cc_kext.armv7
:= $(CCKEXT_ARMVFP_FUNCTIONS
)
343 FUNCTIONS.cc_kext.armv7f
:= $(CCKEXT_ARMVFP_FUNCTIONS
)
344 FUNCTIONS.cc_kext.armv7k
:= $(CCKEXT_ARMVFP_FUNCTIONS
)
345 FUNCTIONS.cc_kext.armv7s
:= $(CCKEXT_ARMVFP_FUNCTIONS
)
346 FUNCTIONS.cc_kext_ios5.armv7
:= $(CCKEXT_ARMVFP_FUNCTIONS
)
347 FUNCTIONS.cc_kext_ios5.armv7f
:= $(CCKEXT_ARMVFP_FUNCTIONS
)
348 FUNCTIONS.cc_kext_ios5.armv7k
:= $(CCKEXT_ARMVFP_FUNCTIONS
)
349 FUNCTIONS.cc_kext_ios5.armv7s
:= $(CCKEXT_ARMVFP_FUNCTIONS
)
351 CCKEXT_X86_FUNCTIONS
:= $(CCKEXT_COMMON_FUNCTIONS
) \
361 FUNCTIONS.cc_kext.i386
:= $(CCKEXT_X86_FUNCTIONS
) \
363 i686.get_pc_thunk.eax \
364 i686.get_pc_thunk.ebp \
365 i686.get_pc_thunk.ebx \
366 i686.get_pc_thunk.ecx \
367 i686.get_pc_thunk.edi \
368 i686.get_pc_thunk.edx \
369 i686.get_pc_thunk.esi
371 FUNCTIONS.cc_kext.x86_64
:= $(CCKEXT_X86_FUNCTIONS
) \
407 # FIXME: Currently, compiler-rt is missing implementations for a number of the
408 # functions that need to go into libcc_kext.a. Filter them out for now.
409 CCKEXT_MISSING_FUNCTIONS
:= \
412 udiv_w_sdiv unorddf2 unordsf2 bswapdi2 \
416 i686.get_pc_thunk.eax i686.get_pc_thunk.ebp i686.get_pc_thunk.ebx \
417 i686.get_pc_thunk.ecx i686.get_pc_thunk.edi i686.get_pc_thunk.edx \
418 i686.get_pc_thunk.esi \
419 aeabi_cdcmpeq aeabi_cdrcmple aeabi_cfcmpeq aeabi_cfrcmple aeabi_dcmpeq \
420 aeabi_dcmpge aeabi_dcmpgt aeabi_dcmple aeabi_dcmplt aeabi_drsub aeabi_fcmpeq \
421 aeabi_fcmpge aeabi_fcmpgt aeabi_fcmple aeabi_fcmplt aeabi_frsub aeabi_idivmod \
424 FUNCTIONS.cc_kext.armv7
:= \
425 $(filter-out $(CCKEXT_MISSING_FUNCTIONS
),$(FUNCTIONS.cc_kext.armv7
))
426 FUNCTIONS.cc_kext.armv7f
:= \
427 $(filter-out $(CCKEXT_MISSING_FUNCTIONS
),$(FUNCTIONS.cc_kext.armv7f
))
428 FUNCTIONS.cc_kext.armv7k
:= \
429 $(filter-out $(CCKEXT_MISSING_FUNCTIONS
),$(FUNCTIONS.cc_kext.armv7k
))
430 FUNCTIONS.cc_kext.armv7s
:= \
431 $(filter-out $(CCKEXT_MISSING_FUNCTIONS
),$(FUNCTIONS.cc_kext.armv7s
))
432 FUNCTIONS.cc_kext_ios5.armv7
:= \
433 $(filter-out $(CCKEXT_MISSING_FUNCTIONS
),$(FUNCTIONS.cc_kext_ios5.armv7
))
434 FUNCTIONS.cc_kext_ios5.armv7f
:= \
435 $(filter-out $(CCKEXT_MISSING_FUNCTIONS
),$(FUNCTIONS.cc_kext_ios5.armv7f
))
436 FUNCTIONS.cc_kext_ios5.armv7k
:= \
437 $(filter-out $(CCKEXT_MISSING_FUNCTIONS
),$(FUNCTIONS.cc_kext_ios5.armv7k
))
438 FUNCTIONS.cc_kext_ios5.armv7s
:= \
439 $(filter-out $(CCKEXT_MISSING_FUNCTIONS
),$(FUNCTIONS.cc_kext_ios5.armv7s
))
440 FUNCTIONS.cc_kext.i386
:= \
441 $(filter-out $(CCKEXT_MISSING_FUNCTIONS
),$(FUNCTIONS.cc_kext.i386
))
442 FUNCTIONS.cc_kext.x86_64
:= \
443 $(filter-out $(CCKEXT_MISSING_FUNCTIONS
),$(FUNCTIONS.cc_kext.x86_64
))
445 KERNEL_USE.cc_kext
:= 1
446 KERNEL_USE.cc_kext_ios5
:= 1
448 VISIBILITY_HIDDEN
:= 1
450 SHARED_LIBRARY_SUFFIX
:= dylib