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