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