Home | History | Annotate | Download | only in platform
      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.
      6 
      7 Description := Static runtime libraries for clang/Darwin.
      8 
      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_darwin_test_input.c \
     18 	  -isysroot $(ProjSrcRoot)/SDKs/darwin \
     19 	  -o /dev/null > /dev/null 2> /dev/null; then \
     20         result="$$result$$arch "; \
     21       else \
     22 	printf 1>&2 \
     23 	  "warning: clang_darwin.mk: dropping arch '$$arch' from lib '$(2)'\n"; \
     24       fi; \
     25     done; \
     26     echo $$result)
     27 
     28 ###
     29 
     30 CC := clang
     31 
     32 Configs :=
     33 UniversalArchs :=
     34 
     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
     37 # needed on i386.
     38 Configs += eprintf
     39 UniversalArchs.eprintf := $(call CheckArches,i386,eprintf)
     40 
     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.
     44 Configs += 10.4
     45 UniversalArchs.10.4 := $(call CheckArches,i386 x86_64,10.4)
     46 
     47 # Configuration for targetting iOS, for some ARMv6 functions, which must be
     48 # in the same linkage unit, and for a couple of other functions that didn't
     49 # make it into libSystem.
     50 Configs += ios
     51 UniversalArchs.ios := $(call CheckArches,i386 x86_64 armv6 armv7,ios)
     52 
     53 # Configuration for targetting OSX. These functions may not be in libSystem
     54 # so we should provide our own.
     55 Configs += osx
     56 UniversalArchs.osx := $(call CheckArches,i386 x86_64,osx)
     57 
     58 # Configuration for use with kernel/kexts.
     59 Configs += cc_kext
     60 UniversalArchs.cc_kext := $(call CheckArches,armv6 armv7 i386 x86_64,cc_kext)
     61 
     62 # Configurations which define the profiling support functions.
     63 Configs += profile_osx
     64 UniversalArchs.profile_osx := $(call CheckArches,i386 x86_64,profile_osx)
     65 Configs += profile_ios
     66 UniversalArchs.profile_ios := $(call CheckArches,i386 x86_64 armv6 armv7,profile_ios)
     67 
     68 # Configurations which define the ASAN support functions.
     69 Configs += asan_osx
     70 UniversalArchs.asan_osx := $(call CheckArches,i386 x86_64,asan_osx)
     71 
     72 # If RC_SUPPORTED_ARCHS is defined, treat it as a list of the architectures we
     73 # are intended to support and limit what we try to build to that.
     74 #
     75 # We make sure to remove empty configs if we end up dropping all the requested
     76 # archs for a particular config.
     77 ifneq ($(RC_SUPPORTED_ARCHS),)
     78 $(foreach config,$(Configs),\
     79   $(call Set,UniversalArchs.$(config),\
     80 	$(filter $(RC_SUPPORTED_ARCHS),$(UniversalArchs.$(config))))\
     81   $(if $(UniversalArchs.$(config)),,\
     82 	$(call Set,Configs,$(filter-out $(config),$(Configs)))))
     83 endif
     84 
     85 ###
     86 
     87 # Forcibly strip off any -arch, as that totally breaks our universal support.
     88 override CC := $(subst -arch ,-arch_,$(CC))
     89 override CC := $(patsubst -arch_%,,$(CC))
     90 
     91 CFLAGS := -Wall -Werror -O3 -fomit-frame-pointer
     92 
     93 # Always set deployment target arguments for every build, these libraries should
     94 # never depend on the environmental overrides. We simply set them to minimum
     95 # supported deployment target -- nothing in the compiler-rt libraries should
     96 # actually depend on the deployment target.
     97 OSX_DEPLOYMENT_ARGS := -mmacosx-version-min=10.4
     98 IOS_DEPLOYMENT_ARGS := -miphoneos-version-min=1.0
     99 IOSSIM_DEPLOYMENT_ARGS := -miphoneos-version-min=1.0
    100 
    101 # Use our stub SDK as the sysroot to support more portable building.
    102 OSX_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin
    103 IOS_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin
    104 IOSSIM_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin
    105 
    106 CFLAGS.eprintf		:= $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
    107 CFLAGS.10.4		:= $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
    108 # FIXME: We can't build ASAN with our stub SDK yet.
    109 CFLAGS.asan_osx         := $(CFLAGS) -mmacosx-version-min=10.5
    110 
    111 CFLAGS.ios.i386		:= $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
    112 CFLAGS.ios.x86_64	:= $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
    113 CFLAGS.ios.armv6	:= $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
    114 CFLAGS.ios.armv7	:= $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
    115 CFLAGS.osx.i386		:= $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
    116 CFLAGS.osx.x86_64	:= $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
    117 CFLAGS.cc_kext.i386	:= $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
    118 CFLAGS.cc_kext.x86_64	:= $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
    119 CFLAGS.cc_kext.armv6	:= $(CFLAGS) $(IOS_DEPLOYMENT_ARGS) -mthumb
    120 CFLAGS.cc_kext.armv7	:= $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
    121 CFLAGS.profile_osx.i386   := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
    122 CFLAGS.profile_osx.x86_64 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
    123 CFLAGS.profile_ios.i386   := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
    124 CFLAGS.profile_ios.x86_64 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
    125 CFLAGS.profile_ios.armv6  := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
    126 CFLAGS.profile_ios.armv7  := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
    127 
    128 FUNCTIONS.eprintf := eprintf
    129 FUNCTIONS.10.4 := eprintf floatundidf floatundisf floatundixf
    130 
    131 FUNCTIONS.ios	    := divmodsi4 udivmodsi4 mulosi4 mulodi4 muloti4
    132 # On x86, the divmod functions reference divsi.
    133 FUNCTIONS.ios.i386   := $(FUNCTIONS.ios) \
    134                         divsi3 udivsi3
    135 FUNCTIONS.ios.x86_64 := $(FUNCTIONS.ios) \
    136                         divsi3 udivsi3
    137 FUNCTIONS.ios.armv6 := $(FUNCTIONS.ios) \
    138                        sync_synchronize \
    139                        switch16 switch32 switch8 switchu8 \
    140                        save_vfp_d8_d15_regs restore_vfp_d8_d15_regs
    141 
    142 FUNCTIONS.osx	:= mulosi4 mulodi4 muloti4
    143 
    144 FUNCTIONS.profile_osx := GCDAProfiling
    145 FUNCTIONS.profile_ios := GCDAProfiling
    146 
    147 FUNCTIONS.asan_osx := $(AsanFunctions)
    148 
    149 CCKEXT_COMMON_FUNCTIONS := \
    150 	absvdi2 \
    151 	absvsi2 \
    152 	addvdi3 \
    153 	addvsi3 \
    154 	ashldi3 \
    155 	ashrdi3 \
    156 	bswapdi2 \
    157 	bswapsi2 \
    158 	clzdi2 \
    159 	clzsi2 \
    160 	cmpdi2 \
    161 	ctzdi2 \
    162 	ctzsi2 \
    163 	divdc3 \
    164 	divdi3 \
    165 	divsc3 \
    166 	divmodsi4 \
    167 	udivmodsi4 \
    168 	do_global_dtors \
    169 	eprintf \
    170 	ffsdi2 \
    171 	fixdfdi \
    172 	fixsfdi \
    173 	fixunsdfdi \
    174 	fixunsdfsi \
    175 	fixunssfdi \
    176 	fixunssfsi \
    177 	floatdidf \
    178 	floatdisf \
    179 	floatundidf \
    180 	floatundisf \
    181 	gcc_bcmp \
    182 	lshrdi3 \
    183 	moddi3 \
    184 	muldc3 \
    185 	muldi3 \
    186 	mulsc3 \
    187 	mulvdi3 \
    188 	mulvsi3 \
    189 	negdi2 \
    190 	negvdi2 \
    191 	negvsi2 \
    192 	paritydi2 \
    193 	paritysi2 \
    194 	popcountdi2 \
    195 	popcountsi2 \
    196 	powidf2 \
    197 	powisf2 \
    198 	subvdi3 \
    199 	subvsi3 \
    200 	ucmpdi2 \
    201 	udiv_w_sdiv \
    202 	udivdi3 \
    203 	udivmoddi4 \
    204 	umoddi3
    205 
    206 CCKEXT_ARM_FUNCTIONS := $(CCKEXT_COMMON_FUNCTIONS) \
    207 	adddf3 \
    208 	addsf3 \
    209 	aeabi_cdcmpeq \
    210 	aeabi_cdrcmple \
    211 	aeabi_cfcmpeq \
    212 	aeabi_cfrcmple \
    213 	aeabi_dcmpeq \
    214 	aeabi_dcmpge \
    215 	aeabi_dcmpgt \
    216 	aeabi_dcmple \
    217 	aeabi_dcmplt \
    218 	aeabi_drsub \
    219 	aeabi_fcmpeq \
    220 	aeabi_fcmpge \
    221 	aeabi_fcmpgt \
    222 	aeabi_fcmple \
    223 	aeabi_fcmplt \
    224 	aeabi_frsub \
    225 	aeabi_idivmod \
    226 	aeabi_uidivmod \
    227 	cmpdf2 \
    228 	cmpsf2 \
    229 	div0 \
    230 	divdf3 \
    231 	divsf3 \
    232 	divsi3 \
    233 	extendsfdf2 \
    234 	ffssi2 \
    235 	fixdfsi \
    236 	fixsfsi \
    237 	floatsidf \
    238 	floatsisf \
    239 	floatunsidf \
    240 	floatunsisf \
    241 	comparedf2 \
    242 	comparesf2 \
    243 	modsi3 \
    244 	muldf3 \
    245 	mulsf3 \
    246 	negdf2 \
    247 	negsf2 \
    248 	subdf3 \
    249 	subsf3 \
    250 	switch16 \
    251 	switch32 \
    252 	switch8 \
    253 	switchu8 \
    254 	truncdfsf2 \
    255 	udivsi3 \
    256 	umodsi3 \
    257 	unorddf2 \
    258 	unordsf2
    259 
    260 CCKEXT_ARMVFP_FUNCTIONS := $(CCKEXT_ARM_FUNCTIONS) \
    261 	adddf3vfp \
    262 	addsf3vfp \
    263 	divdf3vfp \
    264 	divsf3vfp \
    265 	eqdf2vfp \
    266 	eqsf2vfp \
    267 	extendsfdf2vfp \
    268 	fixdfsivfp \
    269 	fixsfsivfp \
    270 	fixunsdfsivfp \
    271 	fixunssfsivfp \
    272 	floatsidfvfp \
    273 	floatsisfvfp \
    274 	floatunssidfvfp \
    275 	floatunssisfvfp \
    276 	gedf2vfp \
    277 	gesf2vfp \
    278 	gtdf2vfp \
    279 	gtsf2vfp \
    280 	ledf2vfp \
    281 	lesf2vfp \
    282 	ltdf2vfp \
    283 	ltsf2vfp \
    284 	muldf3vfp \
    285 	mulsf3vfp \
    286 	nedf2vfp \
    287 	nesf2vfp \
    288 	subdf3vfp \
    289 	subsf3vfp \
    290 	truncdfsf2vfp \
    291 	unorddf2vfp \
    292 	unordsf2vfp
    293 
    294 FUNCTIONS.cc_kext.armv6 := $(CCKEXT_ARMVFP_FUNCTIONS)
    295 FUNCTIONS.cc_kext.armv7 := $(CCKEXT_ARMVFP_FUNCTIONS)
    296 
    297 CCKEXT_X86_FUNCTIONS := $(CCKEXT_COMMON_FUNCTIONS) \
    298 	divxc3 \
    299 	fixunsxfdi \
    300 	fixunsxfsi \
    301 	fixxfdi \
    302 	floatdixf \
    303 	floatundixf \
    304 	mulxc3 \
    305 	powixf2
    306 
    307 FUNCTIONS.cc_kext.i386 := $(CCKEXT_X86_FUNCTIONS) \
    308 	ffssi2 \
    309 	i686.get_pc_thunk.eax \
    310 	i686.get_pc_thunk.ebp \
    311 	i686.get_pc_thunk.ebx \
    312 	i686.get_pc_thunk.ecx \
    313 	i686.get_pc_thunk.edi \
    314 	i686.get_pc_thunk.edx \
    315 	i686.get_pc_thunk.esi
    316 
    317 FUNCTIONS.cc_kext.x86_64 := $(CCKEXT_X86_FUNCTIONS) \
    318 	absvti2 \
    319 	addvti3 \
    320 	ashlti3 \
    321 	ashrti3 \
    322 	clzti2 \
    323 	cmpti2 \
    324 	ctzti2 \
    325 	divti3 \
    326 	ffsti2 \
    327 	fixdfti \
    328 	fixsfti \
    329 	fixunsdfti \
    330 	fixunssfti \
    331 	fixunsxfti \
    332 	fixxfti \
    333 	floattidf \
    334 	floattisf \
    335 	floattixf \
    336 	floatuntidf \
    337 	floatuntisf \
    338 	floatuntixf \
    339 	lshrti3 \
    340 	modti3 \
    341 	multi3 \
    342 	mulvti3 \
    343 	negti2 \
    344 	negvti2 \
    345 	parityti2 \
    346 	popcountti2 \
    347 	subvti3 \
    348 	ucmpti2 \
    349 	udivmodti4 \
    350 	udivti3 \
    351 	umodti3
    352 
    353 # FIXME: Currently, compiler-rt is missing implementations for a number of the
    354 # functions that need to go into libcc_kext.a. Filter them out for now.
    355 CCKEXT_MISSING_FUNCTIONS := \
    356 	cmpdf2 cmpsf2 div0 \
    357 	ffssi2 \
    358 	udiv_w_sdiv unorddf2 unordsf2 bswapdi2 \
    359 	bswapsi2 \
    360 	gcc_bcmp \
    361 	do_global_dtors \
    362 	i686.get_pc_thunk.eax i686.get_pc_thunk.ebp i686.get_pc_thunk.ebx \
    363 	i686.get_pc_thunk.ecx i686.get_pc_thunk.edi i686.get_pc_thunk.edx \
    364 	i686.get_pc_thunk.esi \
    365 	aeabi_cdcmpeq aeabi_cdrcmple aeabi_cfcmpeq aeabi_cfrcmple aeabi_dcmpeq \
    366 	aeabi_dcmpge aeabi_dcmpgt aeabi_dcmple aeabi_dcmplt aeabi_drsub aeabi_fcmpeq \
    367 	aeabi_fcmpge aeabi_fcmpgt aeabi_fcmple aeabi_fcmplt aeabi_frsub aeabi_idivmod \
    368 	aeabi_uidivmod
    369 
    370 FUNCTIONS.cc_kext.armv6 := \
    371 	$(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.armv6))
    372 FUNCTIONS.cc_kext.armv7 := \
    373 	$(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.armv7))
    374 FUNCTIONS.cc_kext.i386 := \
    375 	$(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.i386))
    376 FUNCTIONS.cc_kext.x86_64 := \
    377 	$(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.x86_64))
    378 
    379 KERNEL_USE.cc_kext := 1
    380 
    381 VISIBILITY_HIDDEN := 1
    382