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 OSX. These functions may not be in libSystem 48# so we should provide our own. 49Configs += osx 50UniversalArchs.osx := $(call CheckArches,i386 x86_64,osx) 51 52# Configuration for use with kernel/kexts. 53Configs += cc_kext 54UniversalArchs.cc_kext := $(call CheckArches,i386 x86_64,cc_kext) 55 56# Configurations which define the profiling support functions. 57Configs += profile_osx 58UniversalArchs.profile_osx := $(call CheckArches,i386 x86_64,profile_osx) 59 60# Configurations which define the ASAN support functions. 61Configs += asan_osx 62UniversalArchs.asan_osx := $(call CheckArches,i386 x86_64,asan_osx) 63 64Configs += asan_osx_dynamic 65UniversalArchs.asan_osx_dynamic := $(call CheckArches,i386 x86_64,asan_osx_dynamic) 66 67# If RC_SUPPORTED_ARCHS is defined, treat it as a list of the architectures we 68# are intended to support and limit what we try to build to that. 69# 70# We make sure to remove empty configs if we end up dropping all the requested 71# archs for a particular config. 72ifneq ($(RC_SUPPORTED_ARCHS),) 73$(foreach config,$(Configs),\ 74 $(call Set,UniversalArchs.$(config),\ 75 $(filter $(RC_SUPPORTED_ARCHS),$(UniversalArchs.$(config))))\ 76 $(if $(UniversalArchs.$(config)),,\ 77 $(call Set,Configs,$(filter-out $(config),$(Configs))))) 78endif 79 80### 81 82# Forcibly strip off any -arch, as that totally breaks our universal support. 83override CC := $(subst -arch ,-arch_,$(CC)) 84override CC := $(patsubst -arch_%,,$(CC)) 85 86CFLAGS := -Wall -Werror -O3 -fomit-frame-pointer 87 88# Always set deployment target arguments for every build, these libraries should 89# never depend on the environmental overrides. We simply set them to minimum 90# supported deployment target -- nothing in the compiler-rt libraries should 91# actually depend on the deployment target. 92OSX_DEPLOYMENT_ARGS := -mmacosx-version-min=10.4 93 94# Use our stub SDK as the sysroot to support more portable building. 95OSX_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin 96 97CFLAGS.eprintf := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS) 98CFLAGS.10.4 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS) 99# FIXME: We can't build ASAN with our stub SDK yet. 100CFLAGS.asan_osx := $(CFLAGS) -mmacosx-version-min=10.5 -fno-builtin 101CFLAGS.asan_osx_dynamic := \ 102 $(CFLAGS) -mmacosx-version-min=10.5 -fno-builtin \ 103 -DMAC_INTERPOSE_FUNCTIONS=1 104 105CFLAGS.osx.i386 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS) 106CFLAGS.osx.x86_64 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS) 107CFLAGS.cc_kext.i386 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS) 108CFLAGS.cc_kext.x86_64 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS) 109CFLAGS.profile_osx.i386 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS) 110CFLAGS.profile_osx.x86_64 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS) 111 112# Configure the asan_osx_dynamic library to be built shared. 113SHARED_LIBRARY.asan_osx_dynamic := 1 114LDFLAGS.asan_osx_dynamic := -framework Foundation -lstdc++ 115 116FUNCTIONS.eprintf := eprintf 117FUNCTIONS.10.4 := eprintf floatundidf floatundisf floatundixf 118 119FUNCTIONS.osx := mulosi4 mulodi4 muloti4 120 121FUNCTIONS.profile_osx := GCDAProfiling 122 123FUNCTIONS.asan_osx := $(AsanFunctions) $(InterceptionFunctions) \ 124 $(SanitizerCommonFunctions) 125FUNCTIONS.asan_osx_dynamic := $(AsanFunctions) $(InterceptionFunctions) \ 126 $(SanitizerCommonFunctions) \ 127 $(AsanDynamicFunctions) 128 129CCKEXT_COMMON_FUNCTIONS := \ 130 absvdi2 \ 131 absvsi2 \ 132 addvdi3 \ 133 addvsi3 \ 134 ashldi3 \ 135 ashrdi3 \ 136 bswapdi2 \ 137 bswapsi2 \ 138 clzdi2 \ 139 clzsi2 \ 140 cmpdi2 \ 141 ctzdi2 \ 142 ctzsi2 \ 143 divdc3 \ 144 divdi3 \ 145 divsc3 \ 146 divmodsi4 \ 147 udivmodsi4 \ 148 do_global_dtors \ 149 eprintf \ 150 ffsdi2 \ 151 fixdfdi \ 152 fixsfdi \ 153 fixunsdfdi \ 154 fixunsdfsi \ 155 fixunssfdi \ 156 fixunssfsi \ 157 floatdidf \ 158 floatdisf \ 159 floatundidf \ 160 floatundisf \ 161 gcc_bcmp \ 162 lshrdi3 \ 163 moddi3 \ 164 muldc3 \ 165 muldi3 \ 166 mulsc3 \ 167 mulvdi3 \ 168 mulvsi3 \ 169 negdi2 \ 170 negvdi2 \ 171 negvsi2 \ 172 paritydi2 \ 173 paritysi2 \ 174 popcountdi2 \ 175 popcountsi2 \ 176 powidf2 \ 177 powisf2 \ 178 subvdi3 \ 179 subvsi3 \ 180 ucmpdi2 \ 181 udiv_w_sdiv \ 182 udivdi3 \ 183 udivmoddi4 \ 184 umoddi3 185 186CCKEXT_ARM_FUNCTIONS := $(CCKEXT_COMMON_FUNCTIONS) \ 187 adddf3 \ 188 addsf3 \ 189 aeabi_cdcmpeq \ 190 aeabi_cdrcmple \ 191 aeabi_cfcmpeq \ 192 aeabi_cfrcmple \ 193 aeabi_dcmpeq \ 194 aeabi_dcmpge \ 195 aeabi_dcmpgt \ 196 aeabi_dcmple \ 197 aeabi_dcmplt \ 198 aeabi_drsub \ 199 aeabi_fcmpeq \ 200 aeabi_fcmpge \ 201 aeabi_fcmpgt \ 202 aeabi_fcmple \ 203 aeabi_fcmplt \ 204 aeabi_frsub \ 205 aeabi_idivmod \ 206 aeabi_uidivmod \ 207 cmpdf2 \ 208 cmpsf2 \ 209 div0 \ 210 divdf3 \ 211 divsf3 \ 212 divsi3 \ 213 extendsfdf2 \ 214 ffssi2 \ 215 fixdfsi \ 216 fixsfsi \ 217 floatsidf \ 218 floatsisf \ 219 floatunsidf \ 220 floatunsisf \ 221 comparedf2 \ 222 comparesf2 \ 223 modsi3 \ 224 muldf3 \ 225 mulsf3 \ 226 negdf2 \ 227 negsf2 \ 228 subdf3 \ 229 subsf3 \ 230 switch16 \ 231 switch32 \ 232 switch8 \ 233 switchu8 \ 234 truncdfsf2 \ 235 udivsi3 \ 236 umodsi3 \ 237 unorddf2 \ 238 unordsf2 239 240CCKEXT_X86_FUNCTIONS := $(CCKEXT_COMMON_FUNCTIONS) \ 241 divxc3 \ 242 fixunsxfdi \ 243 fixunsxfsi \ 244 fixxfdi \ 245 floatdixf \ 246 floatundixf \ 247 mulxc3 \ 248 powixf2 249 250FUNCTIONS.cc_kext.i386 := $(CCKEXT_X86_FUNCTIONS) \ 251 ffssi2 \ 252 i686.get_pc_thunk.eax \ 253 i686.get_pc_thunk.ebp \ 254 i686.get_pc_thunk.ebx \ 255 i686.get_pc_thunk.ecx \ 256 i686.get_pc_thunk.edi \ 257 i686.get_pc_thunk.edx \ 258 i686.get_pc_thunk.esi 259 260FUNCTIONS.cc_kext.x86_64 := $(CCKEXT_X86_FUNCTIONS) \ 261 absvti2 \ 262 addvti3 \ 263 ashlti3 \ 264 ashrti3 \ 265 clzti2 \ 266 cmpti2 \ 267 ctzti2 \ 268 divti3 \ 269 ffsti2 \ 270 fixdfti \ 271 fixsfti \ 272 fixunsdfti \ 273 fixunssfti \ 274 fixunsxfti \ 275 fixxfti \ 276 floattidf \ 277 floattisf \ 278 floattixf \ 279 floatuntidf \ 280 floatuntisf \ 281 floatuntixf \ 282 lshrti3 \ 283 modti3 \ 284 multi3 \ 285 mulvti3 \ 286 negti2 \ 287 negvti2 \ 288 parityti2 \ 289 popcountti2 \ 290 subvti3 \ 291 ucmpti2 \ 292 udivmodti4 \ 293 udivti3 \ 294 umodti3 295 296# FIXME: Currently, compiler-rt is missing implementations for a number of the 297# functions that need to go into libcc_kext.a. Filter them out for now. 298CCKEXT_MISSING_FUNCTIONS := \ 299 cmpdf2 cmpsf2 div0 \ 300 ffssi2 \ 301 udiv_w_sdiv unorddf2 unordsf2 bswapdi2 \ 302 bswapsi2 \ 303 gcc_bcmp \ 304 do_global_dtors \ 305 i686.get_pc_thunk.eax i686.get_pc_thunk.ebp i686.get_pc_thunk.ebx \ 306 i686.get_pc_thunk.ecx i686.get_pc_thunk.edi i686.get_pc_thunk.edx \ 307 i686.get_pc_thunk.esi \ 308 aeabi_cdcmpeq aeabi_cdrcmple aeabi_cfcmpeq aeabi_cfrcmple aeabi_dcmpeq \ 309 aeabi_dcmpge aeabi_dcmpgt aeabi_dcmple aeabi_dcmplt aeabi_drsub aeabi_fcmpeq \ 310 aeabi_fcmpge aeabi_fcmpgt aeabi_fcmple aeabi_fcmplt aeabi_frsub aeabi_idivmod \ 311 aeabi_uidivmod 312 313FUNCTIONS.cc_kext.i386 := \ 314 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.i386)) 315FUNCTIONS.cc_kext.x86_64 := \ 316 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.x86_64)) 317 318KERNEL_USE.cc_kext := 1 319 320VISIBILITY_HIDDEN := 1 321