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