clang_darwin.mk revision 1d38069f4842973df02525c7bf77a5cbed3b03aa
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 -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 30CC := clang 31 32Configs := 33UniversalArchs := 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. 38Configs += eprintf 39UniversalArchs.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. 44Configs += 10.4 45UniversalArchs.10.4 := $(call CheckArches,i386 x86_64,10.4) 46 47# Configuration for targetting iOS for a couple of functions that didn't 48# make it into libSystem. 49Configs += ios 50UniversalArchs.ios := $(call CheckArches,i386 x86_64 armv7,ios) 51 52# Configuration for targetting OSX. These functions may not be in libSystem 53# so we should provide our own. 54Configs += osx 55UniversalArchs.osx := $(call CheckArches,i386 x86_64,osx) 56 57# Configuration for use with kernel/kexts. 58Configs += cc_kext 59UniversalArchs.cc_kext := $(call CheckArches,armv7 i386 x86_64,cc_kext) 60 61# Configuration for use with kernel/kexts for iOS 5.0 and earlier (which used 62# a different code generation strategy). 63Configs += cc_kext_ios5 64UniversalArchs.cc_kext_ios5 := $(call CheckArches,x86_64 armv7,cc_kext_ios5) 65 66# Configurations which define the profiling support functions. 67Configs += profile_osx 68UniversalArchs.profile_osx := $(call CheckArches,i386 x86_64,profile_osx) 69Configs += profile_ios 70UniversalArchs.profile_ios := $(call CheckArches,i386 x86_64 armv7,profile_ios) 71 72# Configurations which define the ASAN support functions. 73Configs += asan_osx 74UniversalArchs.asan_osx := $(call CheckArches,i386 x86_64,asan_osx) 75 76Configs += asan_osx_dynamic 77UniversalArchs.asan_osx_dynamic := $(call CheckArches,i386 x86_64,asan_osx_dynamic) 78 79Configs += ubsan_osx 80UniversalArchs.ubsan_osx := $(call CheckArches,i386 x86_64,ubsan_osx) 81 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. 86ifneq ($(shell which sw_vers),) 87ifneq ($(shell sw_vers -productVersion | grep 10.6),) 88UniversalArchs.ios := $(filter-out armv7, $(UniversalArchs.ios)) 89UniversalArchs.cc_kext := $(filter-out armv7, $(UniversalArchs.cc_kext)) 90UniversalArchs.cc_kext_ios5 := $(filter-out armv7, $(UniversalArchs.cc_kext_ios5)) 91UniversalArchs.profile_ios := $(filter-out armv7, $(UniversalArchs.profile_ios)) 92endif 93endif 94 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. 97# 98# We make sure to remove empty configs if we end up dropping all the requested 99# archs for a particular config. 100ifneq ($(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))))) 106endif 107 108### 109 110# Forcibly strip off any -arch, as that totally breaks our universal support. 111override CC := $(subst -arch ,-arch_,$(CC)) 112override CC := $(patsubst -arch_%,,$(CC)) 113 114CFLAGS := -Wall -Werror -O3 -fomit-frame-pointer 115 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. 120OSX_DEPLOYMENT_ARGS := -mmacosx-version-min=10.4 121IOS_DEPLOYMENT_ARGS := -mios-version-min=1.0 122IOS6_DEPLOYMENT_ARGS := -mios-version-min=6.0 123IOSSIM_DEPLOYMENT_ARGS := -mios-simulator-version-min=1.0 124 125# Use our stub SDK as the sysroot to support more portable building. 126OSX_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin 127IOS_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin 128IOS6_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin 129IOSSIM_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin 130 131CFLAGS.eprintf := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS) 132CFLAGS.10.4 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS) 133# FIXME: We can't build ASAN with our stub SDK yet. 134CFLAGS.asan_osx := $(CFLAGS) -mmacosx-version-min=10.5 -fno-builtin \ 135 -fno-rtti -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=1 136CFLAGS.asan_osx_dynamic := \ 137 $(CFLAGS) -mmacosx-version-min=10.5 -fno-builtin \ 138 -DMAC_INTERPOSE_FUNCTIONS=1 \ 139 -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=1 140 141CFLAGS.ubsan_osx := $(CFLAGS) -mmacosx-version-min=10.5 -fno-builtin 142 143CFLAGS.ios.i386 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS) 144CFLAGS.ios.x86_64 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS) 145CFLAGS.ios.armv7 := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS) 146CFLAGS.ios.armv7f := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS) 147CFLAGS.ios.armv7k := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS) 148CFLAGS.ios.armv7s := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS) 149CFLAGS.osx.i386 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS) 150CFLAGS.osx.x86_64 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS) 151CFLAGS.cc_kext.i386 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS) 152CFLAGS.cc_kext.x86_64 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS) 153CFLAGS.cc_kext.armv7 := $(CFLAGS) $(IOS6_DEPLOYMENT_ARGS) 154CFLAGS.cc_kext.armv7f := $(CFLAGS) $(IOS6_DEPLOYMENT_ARGS) 155CFLAGS.cc_kext.armv7k := $(CFLAGS) $(IOS6_DEPLOYMENT_ARGS) 156CFLAGS.cc_kext.armv7s := $(CFLAGS) $(IOS6_DEPLOYMENT_ARGS) 157CFLAGS.cc_kext_ios5.armv7 := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS) 158CFLAGS.cc_kext_ios5.armv7f := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS) 159CFLAGS.cc_kext_ios5.armv7k := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS) 160CFLAGS.cc_kext_ios5.armv7s := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS) 161CFLAGS.profile_osx.i386 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS) 162CFLAGS.profile_osx.x86_64 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS) 163CFLAGS.profile_ios.i386 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS) 164CFLAGS.profile_ios.x86_64 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS) 165CFLAGS.profile_ios.armv7 := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS) 166CFLAGS.profile_ios.armv7f := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS) 167CFLAGS.profile_ios.armv7k := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS) 168CFLAGS.profile_ios.armv7s := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS) 169 170# Configure the asan_osx_dynamic library to be built shared. 171SHARED_LIBRARY.asan_osx_dynamic := 1 172LDFLAGS.asan_osx_dynamic := -framework Foundation -lstdc++ -undefined dynamic_lookup 173 174FUNCTIONS.eprintf := eprintf 175FUNCTIONS.10.4 := eprintf floatundidf floatundisf floatundixf 176 177FUNCTIONS.ios := divmodsi4 udivmodsi4 mulosi4 mulodi4 muloti4 178# On x86, the divmod functions reference divsi. 179FUNCTIONS.ios.i386 := $(FUNCTIONS.ios) \ 180 divsi3 udivsi3 181FUNCTIONS.ios.x86_64 := $(FUNCTIONS.ios) \ 182 divsi3 udivsi3 183 184FUNCTIONS.osx := mulosi4 mulodi4 muloti4 185 186FUNCTIONS.profile_osx := GCDAProfiling 187FUNCTIONS.profile_ios := GCDAProfiling 188 189FUNCTIONS.asan_osx := $(AsanFunctions) $(InterceptionFunctions) \ 190 $(SanitizerCommonFunctions) 191FUNCTIONS.asan_osx_dynamic := $(AsanFunctions) $(InterceptionFunctions) \ 192 $(SanitizerCommonFunctions) \ 193 $(AsanDynamicFunctions) 194 195FUNCTIONS.ubsan_osx := $(UbsanFunctions) $(UbsanCXXFunctions) \ 196 $(SanitizerCommonFunctions) 197 198CCKEXT_COMMON_FUNCTIONS := \ 199 absvdi2 \ 200 absvsi2 \ 201 addvdi3 \ 202 addvsi3 \ 203 ashldi3 \ 204 ashrdi3 \ 205 bswapdi2 \ 206 bswapsi2 \ 207 clzdi2 \ 208 clzsi2 \ 209 cmpdi2 \ 210 ctzdi2 \ 211 ctzsi2 \ 212 divdc3 \ 213 divdi3 \ 214 divsc3 \ 215 divmodsi4 \ 216 udivmodsi4 \ 217 do_global_dtors \ 218 eprintf \ 219 ffsdi2 \ 220 fixdfdi \ 221 fixsfdi \ 222 fixunsdfdi \ 223 fixunsdfsi \ 224 fixunssfdi \ 225 fixunssfsi \ 226 floatdidf \ 227 floatdisf \ 228 floatundidf \ 229 floatundisf \ 230 gcc_bcmp \ 231 lshrdi3 \ 232 moddi3 \ 233 muldc3 \ 234 muldi3 \ 235 mulsc3 \ 236 mulvdi3 \ 237 mulvsi3 \ 238 negdi2 \ 239 negvdi2 \ 240 negvsi2 \ 241 paritydi2 \ 242 paritysi2 \ 243 popcountdi2 \ 244 popcountsi2 \ 245 powidf2 \ 246 powisf2 \ 247 subvdi3 \ 248 subvsi3 \ 249 ucmpdi2 \ 250 udiv_w_sdiv \ 251 udivdi3 \ 252 udivmoddi4 \ 253 umoddi3 254 255CCKEXT_ARM_FUNCTIONS := $(CCKEXT_COMMON_FUNCTIONS) \ 256 adddf3 \ 257 addsf3 \ 258 aeabi_cdcmpeq \ 259 aeabi_cdrcmple \ 260 aeabi_cfcmpeq \ 261 aeabi_cfrcmple \ 262 aeabi_dcmpeq \ 263 aeabi_dcmpge \ 264 aeabi_dcmpgt \ 265 aeabi_dcmple \ 266 aeabi_dcmplt \ 267 aeabi_drsub \ 268 aeabi_fcmpeq \ 269 aeabi_fcmpge \ 270 aeabi_fcmpgt \ 271 aeabi_fcmple \ 272 aeabi_fcmplt \ 273 aeabi_frsub \ 274 aeabi_idivmod \ 275 aeabi_uidivmod \ 276 cmpdf2 \ 277 cmpsf2 \ 278 div0 \ 279 divdf3 \ 280 divsf3 \ 281 divsi3 \ 282 extendsfdf2 \ 283 ffssi2 \ 284 fixdfsi \ 285 fixsfsi \ 286 floatsidf \ 287 floatsisf \ 288 floatunsidf \ 289 floatunsisf \ 290 comparedf2 \ 291 comparesf2 \ 292 modsi3 \ 293 muldf3 \ 294 mulsf3 \ 295 negdf2 \ 296 negsf2 \ 297 subdf3 \ 298 subsf3 \ 299 switch16 \ 300 switch32 \ 301 switch8 \ 302 switchu8 \ 303 truncdfsf2 \ 304 udivsi3 \ 305 umodsi3 \ 306 unorddf2 \ 307 unordsf2 308 309CCKEXT_ARMVFP_FUNCTIONS := $(CCKEXT_ARM_FUNCTIONS) \ 310 adddf3vfp \ 311 addsf3vfp \ 312 divdf3vfp \ 313 divsf3vfp \ 314 eqdf2vfp \ 315 eqsf2vfp \ 316 extendsfdf2vfp \ 317 fixdfsivfp \ 318 fixsfsivfp \ 319 fixunsdfsivfp \ 320 fixunssfsivfp \ 321 floatsidfvfp \ 322 floatsisfvfp \ 323 floatunssidfvfp \ 324 floatunssisfvfp \ 325 gedf2vfp \ 326 gesf2vfp \ 327 gtdf2vfp \ 328 gtsf2vfp \ 329 ledf2vfp \ 330 lesf2vfp \ 331 ltdf2vfp \ 332 ltsf2vfp \ 333 muldf3vfp \ 334 mulsf3vfp \ 335 nedf2vfp \ 336 nesf2vfp \ 337 subdf3vfp \ 338 subsf3vfp \ 339 truncdfsf2vfp \ 340 unorddf2vfp \ 341 unordsf2vfp 342 343FUNCTIONS.cc_kext.armv7 := $(CCKEXT_ARMVFP_FUNCTIONS) 344FUNCTIONS.cc_kext.armv7f := $(CCKEXT_ARMVFP_FUNCTIONS) 345FUNCTIONS.cc_kext.armv7k := $(CCKEXT_ARMVFP_FUNCTIONS) 346FUNCTIONS.cc_kext.armv7s := $(CCKEXT_ARMVFP_FUNCTIONS) 347FUNCTIONS.cc_kext_ios5.armv7 := $(CCKEXT_ARMVFP_FUNCTIONS) 348FUNCTIONS.cc_kext_ios5.armv7f := $(CCKEXT_ARMVFP_FUNCTIONS) 349FUNCTIONS.cc_kext_ios5.armv7k := $(CCKEXT_ARMVFP_FUNCTIONS) 350FUNCTIONS.cc_kext_ios5.armv7s := $(CCKEXT_ARMVFP_FUNCTIONS) 351 352CCKEXT_X86_FUNCTIONS := $(CCKEXT_COMMON_FUNCTIONS) \ 353 divxc3 \ 354 fixunsxfdi \ 355 fixunsxfsi \ 356 fixxfdi \ 357 floatdixf \ 358 floatundixf \ 359 mulxc3 \ 360 powixf2 361 362FUNCTIONS.cc_kext.i386 := $(CCKEXT_X86_FUNCTIONS) \ 363 ffssi2 \ 364 i686.get_pc_thunk.eax \ 365 i686.get_pc_thunk.ebp \ 366 i686.get_pc_thunk.ebx \ 367 i686.get_pc_thunk.ecx \ 368 i686.get_pc_thunk.edi \ 369 i686.get_pc_thunk.edx \ 370 i686.get_pc_thunk.esi 371 372FUNCTIONS.cc_kext.x86_64 := $(CCKEXT_X86_FUNCTIONS) \ 373 absvti2 \ 374 addvti3 \ 375 ashlti3 \ 376 ashrti3 \ 377 clzti2 \ 378 cmpti2 \ 379 ctzti2 \ 380 divti3 \ 381 ffsti2 \ 382 fixdfti \ 383 fixsfti \ 384 fixunsdfti \ 385 fixunssfti \ 386 fixunsxfti \ 387 fixxfti \ 388 floattidf \ 389 floattisf \ 390 floattixf \ 391 floatuntidf \ 392 floatuntisf \ 393 floatuntixf \ 394 lshrti3 \ 395 modti3 \ 396 multi3 \ 397 mulvti3 \ 398 negti2 \ 399 negvti2 \ 400 parityti2 \ 401 popcountti2 \ 402 subvti3 \ 403 ucmpti2 \ 404 udivmodti4 \ 405 udivti3 \ 406 umodti3 407 408# FIXME: Currently, compiler-rt is missing implementations for a number of the 409# functions that need to go into libcc_kext.a. Filter them out for now. 410CCKEXT_MISSING_FUNCTIONS := \ 411 cmpdf2 cmpsf2 div0 \ 412 ffssi2 \ 413 udiv_w_sdiv unorddf2 unordsf2 bswapdi2 \ 414 bswapsi2 \ 415 gcc_bcmp \ 416 do_global_dtors \ 417 i686.get_pc_thunk.eax i686.get_pc_thunk.ebp i686.get_pc_thunk.ebx \ 418 i686.get_pc_thunk.ecx i686.get_pc_thunk.edi i686.get_pc_thunk.edx \ 419 i686.get_pc_thunk.esi \ 420 aeabi_cdcmpeq aeabi_cdrcmple aeabi_cfcmpeq aeabi_cfrcmple aeabi_dcmpeq \ 421 aeabi_dcmpge aeabi_dcmpgt aeabi_dcmple aeabi_dcmplt aeabi_drsub aeabi_fcmpeq \ 422 aeabi_fcmpge aeabi_fcmpgt aeabi_fcmple aeabi_fcmplt aeabi_frsub aeabi_idivmod \ 423 aeabi_uidivmod 424 425FUNCTIONS.cc_kext.armv7 := \ 426 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.armv7)) 427FUNCTIONS.cc_kext.armv7f := \ 428 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.armv7f)) 429FUNCTIONS.cc_kext.armv7k := \ 430 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.armv7k)) 431FUNCTIONS.cc_kext.armv7s := \ 432 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.armv7s)) 433FUNCTIONS.cc_kext_ios5.armv7 := \ 434 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext_ios5.armv7)) 435FUNCTIONS.cc_kext_ios5.armv7f := \ 436 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext_ios5.armv7f)) 437FUNCTIONS.cc_kext_ios5.armv7k := \ 438 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext_ios5.armv7k)) 439FUNCTIONS.cc_kext_ios5.armv7s := \ 440 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext_ios5.armv7s)) 441FUNCTIONS.cc_kext.i386 := \ 442 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.i386)) 443FUNCTIONS.cc_kext.x86_64 := \ 444 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.x86_64)) 445 446KERNEL_USE.cc_kext := 1 447KERNEL_USE.cc_kext_ios5 := 1 448 449VISIBILITY_HIDDEN := 1 450 451SHARED_LIBRARY_SUFFIX := dylib 452