]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/make/platform/clang_darwin.mk
Imported Upstream version 1.5.0+dfsg1
[rustc.git] / src / compiler-rt / make / platform / clang_darwin.mk
CommitLineData
1a4d82fc
JJ
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 if $(LD) -v 2>&1 | grep "configured to support" \
21 | tr ' ' '\n' | grep "^$$arch$$" >/dev/null 2>/dev/null; then \
22 result="$$result$$arch "; \
23 else \
24 printf 1>&2 \
25 "warning: clang_darwin.mk: dropping arch '$$arch' from lib '$(2)'"; \
26 printf 1>&2 " (ld does not support it)\n"; \
27 fi; \
28 else \
29 printf 1>&2 \
30 "warning: clang_darwin.mk: dropping arch '$$arch' from lib '$(2)'"; \
31 printf 1>&2 " (clang does not support it)\n"; \
32 fi; \
33 done; \
34 echo $$result)
35
36XCRun = \
37 $(shell \
38 result=`xcrun -find $(1) 2> /dev/null`; \
39 if [ "$$?" != "0" ]; then result=$(1); fi; \
40 echo $$result)
41XCRunSdkPath = \
42 $(shell \
43 result=`xcrun --sdk $(1) --show-sdk-path 2> /dev/null`; \
44 if [ "$$?" != "0" ]; then result=""; fi; \
45 echo $$result)
46###
47
48CC := $(call XCRun,clang)
49LD := $(shell $(CC) -print-prog-name=ld)
50AR := $(call XCRun,ar)
51RANLIB := $(call XCRun,ranlib)
52STRIP := $(call XCRun,strip)
53LIPO := $(call XCRun,lipo)
54DSYMUTIL := $(call XCRun,dsymutil)
55
56Configs :=
57UniversalArchs :=
58
59# Configuration solely for providing access to an eprintf symbol, which may
60# still be referenced from Darwin system headers. This symbol is only ever
61# needed on i386.
62Configs += eprintf
63UniversalArchs.eprintf := $(call CheckArches,i386,eprintf)
64
65# Configuration for targetting 10.4. We need a few functions missing from
66# libgcc_s.10.4.dylib. We only build x86 slices since clang doesn't really
67# support targetting PowerPC.
68Configs += 10.4
69UniversalArchs.10.4 := $(call CheckArches,i386 x86_64,10.4)
70
71# Configuration for targetting iOS for a couple of functions that didn't
72# make it into libSystem.
73Configs += ios
74UniversalArchs.ios := $(call CheckArches,i386 x86_64 x86_64h armv7,ios)
75
76# Configuration for targetting OSX. These functions may not be in libSystem
77# so we should provide our own.
78Configs += osx
79UniversalArchs.osx := $(call CheckArches,i386 x86_64 x86_64h,osx)
80
81# Configuration for use with kernel/kexts.
82Configs += cc_kext
83UniversalArchs.cc_kext := $(call CheckArches,armv7 i386 x86_64 x86_64h,cc_kext)
84
85# Configuration for use with kernel/kexts for iOS 5.0 and earlier (which used
86# a different code generation strategy).
87Configs += cc_kext_ios5
88UniversalArchs.cc_kext_ios5 := $(call CheckArches,x86_64 x86_64h armv7,cc_kext_ios5)
89
90# Configurations which define the profiling support functions.
91Configs += profile_osx
92UniversalArchs.profile_osx := $(call CheckArches,i386 x86_64 x86_64h,profile_osx)
93Configs += profile_ios
94UniversalArchs.profile_ios := $(call CheckArches,i386 x86_64 x86_64h armv7,profile_ios)
95
96# Configurations which define the ASAN support functions.
97Configs += asan_osx_dynamic
98UniversalArchs.asan_osx_dynamic := $(call CheckArches,i386 x86_64 x86_64h,asan_osx_dynamic)
99
100IOSSIM_SDK_PATH := $(call XCRunSdkPath,iphonesimulator)
101ifneq ($(IOSSIM_SDK_PATH),)
102Configs += asan_iossim_dynamic
103UniversalArchs.asan_iossim_dynamic := $(call CheckArches,i386 x86_64 x86_64h,asan_iossim_dynamic)
104endif
105
106Configs += ubsan_osx
107UniversalArchs.ubsan_osx := $(call CheckArches,i386 x86_64 x86_64h,ubsan_osx)
108
109# Darwin 10.6 has a bug in cctools that makes it unable to use ranlib on our ARM
110# object files. If we are on that platform, strip out all ARM archs. We still
111# build the libraries themselves so that Clang can find them where it expects
112# them, even though they might not have an expected slice.
113ifneq ($(shell test -x /usr/bin/sw_vers && sw_vers -productVersion | grep 10.6),)
114UniversalArchs.ios := $(filter-out armv7, $(UniversalArchs.ios))
115UniversalArchs.cc_kext := $(filter-out armv7, $(UniversalArchs.cc_kext))
116UniversalArchs.cc_kext_ios5 := $(filter-out armv7, $(UniversalArchs.cc_kext_ios5))
117UniversalArchs.profile_ios := $(filter-out armv7, $(UniversalArchs.profile_ios))
118endif
119
120# If RC_SUPPORTED_ARCHS is defined, treat it as a list of the architectures we
121# are intended to support and limit what we try to build to that.
122#
123# We make sure to remove empty configs if we end up dropping all the requested
124# archs for a particular config.
125ifneq ($(RC_SUPPORTED_ARCHS),)
126$(foreach config,$(Configs),\
127 $(call Set,UniversalArchs.$(config),\
128 $(filter $(RC_SUPPORTED_ARCHS),$(UniversalArchs.$(config))))\
129 $(if $(UniversalArchs.$(config)),,\
130 $(call Set,Configs,$(filter-out $(config),$(Configs)))))
131endif
132
133###
134
135# Forcibly strip off any -arch, as that totally breaks our universal support.
136override CC := $(subst -arch ,-arch_,$(CC))
137override CC := $(patsubst -arch_%,,$(CC))
138
139CFLAGS := -fPIC -Wall -Werror -O3 -fomit-frame-pointer
140
141# Always set deployment target arguments for every build, these libraries should
142# never depend on the environmental overrides. We simply set them to minimum
143# supported deployment target -- nothing in the compiler-rt libraries should
144# actually depend on the deployment target.
145OSX_DEPLOYMENT_ARGS := -mmacosx-version-min=10.4
146IOS_DEPLOYMENT_ARGS := -mios-version-min=1.0
147IOS6_DEPLOYMENT_ARGS := -mios-version-min=6.0
148IOSSIM_DEPLOYMENT_ARGS := -mios-simulator-version-min=1.0
149
150# Use our stub SDK as the sysroot to support more portable building.
151OSX_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin
152IOS_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin
153IOS6_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin
154IOSSIM_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin
155
156CFLAGS.eprintf := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
157CFLAGS.10.4 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
158# FIXME: We can't build ASAN with our stub SDK yet.
159CFLAGS.asan_osx_dynamic := \
160 $(CFLAGS) -mmacosx-version-min=10.6 -fno-builtin \
161 -gline-tables-only \
162 -DMAC_INTERPOSE_FUNCTIONS=1
163
164CFLAGS.asan_iossim_dynamic := \
165 $(CFLAGS) -mios-simulator-version-min=7.0 \
166 -isysroot $(IOSSIM_SDK_PATH) \
167 -fno-builtin \
168 -gline-tables-only \
169 -DMAC_INTERPOSE_FUNCTIONS=1
170
171CFLAGS.ubsan_osx := $(CFLAGS) -mmacosx-version-min=10.6 -fno-builtin
172
173CFLAGS.ios.i386 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
174CFLAGS.ios.x86_64 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
175CFLAGS.ios.x86_64h := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
176CFLAGS.ios.armv7 := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
177CFLAGS.ios.armv7k := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
178CFLAGS.ios.armv7s := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
179CFLAGS.osx.i386 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
180CFLAGS.osx.x86_64 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
181CFLAGS.osx.x86_64h := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
182CFLAGS.cc_kext.i386 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
183CFLAGS.cc_kext.x86_64 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
184CFLAGS.cc_kext.x86_64h := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
185CFLAGS.cc_kext.armv7 := $(CFLAGS) $(IOS6_DEPLOYMENT_ARGS)
186CFLAGS.cc_kext.armv7k := $(CFLAGS) $(IOS6_DEPLOYMENT_ARGS)
187CFLAGS.cc_kext.armv7s := $(CFLAGS) $(IOS6_DEPLOYMENT_ARGS)
188CFLAGS.cc_kext_ios5.armv7 := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
189CFLAGS.cc_kext_ios5.armv7k := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
190CFLAGS.cc_kext_ios5.armv7s := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
191CFLAGS.profile_osx.i386 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
192CFLAGS.profile_osx.x86_64 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
193CFLAGS.profile_osx.x86_64h := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
194CFLAGS.profile_ios.i386 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
195CFLAGS.profile_ios.x86_64 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
196CFLAGS.profile_ios.x86_64h := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
197CFLAGS.profile_ios.armv7 := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
198CFLAGS.profile_ios.armv7k := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
199CFLAGS.profile_ios.armv7s := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
200
201# Configure the asan_osx_dynamic library to be built shared.
202SHARED_LIBRARY.asan_osx_dynamic := 1
203LDFLAGS.asan_osx_dynamic := -lstdc++ -undefined dynamic_lookup
204
205# Configure the asan_iossim_dynamic library to be built shared.
206SHARED_LIBRARY.asan_iossim_dynamic := 1
207# configure+make uses Clang, so we're using isysroot instead of --sysroot
208# or -Wl,-syslibroot.
209LDFLAGS.asan_iossim_dynamic := -undefined dynamic_lookup \
210 -Wl,-ios_simulator_version_min,7.0.0 \
211 -mios-simulator-version-min=7.0 -isysroot $(IOSSIM_SDK_PATH)
212
213FUNCTIONS.eprintf := eprintf
214FUNCTIONS.10.4 := eprintf floatundidf floatundisf floatundixf
215
216FUNCTIONS.ios := divmodsi4 udivmodsi4 mulosi4 mulodi4 muloti4
217# On x86, the divmod functions reference divsi.
218FUNCTIONS.ios.i386 := $(FUNCTIONS.ios) \
219 divsi3 udivsi3
220FUNCTIONS.ios.x86_64 := $(FUNCTIONS.ios.i386)
221FUNCTIONS.ios.x86_64h := $(FUNCTIONS.ios.x86_64)
222
223FUNCTIONS.osx := mulosi4 mulodi4 muloti4
224
225FUNCTIONS.profile_osx := GCDAProfiling InstrProfiling InstrProfilingBuffer \
226 InstrProfilingFile InstrProfilingPlatformDarwin \
227 InstrProfilingRuntime
228FUNCTIONS.profile_ios := $(FUNCTIONS.profile_osx)
229
230FUNCTIONS.asan_osx_dynamic := $(AsanFunctions) $(InterceptionFunctions) \
231 $(SanitizerCommonFunctions) \
232 $(AsanDynamicFunctions)
233
234FUNCTIONS.asan_iossim_dynamic := $(AsanFunctions) $(InterceptionFunctions) \
235 $(SanitizerCommonFunctions) \
236 $(AsanDynamicFunctions)
237
238FUNCTIONS.ubsan_osx := $(UbsanFunctions) $(UbsanCXXFunctions) \
239 $(SanitizerCommonFunctions)
240
241CCKEXT_COMMON_FUNCTIONS := \
242 absvdi2 \
243 absvsi2 \
244 addvdi3 \
245 addvsi3 \
246 ashldi3 \
247 ashrdi3 \
248 bswapdi2 \
249 bswapsi2 \
250 clzdi2 \
251 clzsi2 \
252 cmpdi2 \
253 ctzdi2 \
254 ctzsi2 \
255 divdc3 \
256 divdi3 \
257 divsc3 \
258 divmodsi4 \
259 udivmodsi4 \
260 do_global_dtors \
261 eprintf \
262 ffsdi2 \
263 fixdfdi \
264 fixsfdi \
265 fixunsdfdi \
266 fixunsdfsi \
267 fixunssfdi \
268 fixunssfsi \
269 floatdidf \
270 floatdisf \
271 floatundidf \
272 floatundisf \
273 gcc_bcmp \
274 lshrdi3 \
275 moddi3 \
276 muldc3 \
277 muldi3 \
278 mulsc3 \
279 mulvdi3 \
280 mulvsi3 \
281 negdi2 \
282 negvdi2 \
283 negvsi2 \
284 paritydi2 \
285 paritysi2 \
286 popcountdi2 \
287 popcountsi2 \
288 powidf2 \
289 powisf2 \
290 subvdi3 \
291 subvsi3 \
292 ucmpdi2 \
293 udiv_w_sdiv \
294 udivdi3 \
295 udivmoddi4 \
296 umoddi3
297
298CCKEXT_ARM_FUNCTIONS := $(CCKEXT_COMMON_FUNCTIONS) \
299 adddf3 \
300 addsf3 \
301 aeabi_cdcmpeq \
302 aeabi_cdrcmple \
303 aeabi_cfcmpeq \
304 aeabi_cfrcmple \
305 aeabi_dcmpeq \
306 aeabi_dcmpge \
307 aeabi_dcmpgt \
308 aeabi_dcmple \
309 aeabi_dcmplt \
310 aeabi_drsub \
311 aeabi_fcmpeq \
312 aeabi_fcmpge \
313 aeabi_fcmpgt \
314 aeabi_fcmple \
315 aeabi_fcmplt \
316 aeabi_frsub \
317 aeabi_idivmod \
318 aeabi_uidivmod \
319 cmpdf2 \
320 cmpsf2 \
321 div0 \
322 divdf3 \
323 divsf3 \
324 divsi3 \
325 extendsfdf2 \
326 ffssi2 \
327 fixdfsi \
328 fixsfsi \
329 floatsidf \
330 floatsisf \
331 floatunsidf \
332 floatunsisf \
333 comparedf2 \
334 comparesf2 \
335 modsi3 \
336 muldf3 \
337 mulsf3 \
338 negdf2 \
339 negsf2 \
340 subdf3 \
341 subsf3 \
342 switch16 \
343 switch32 \
344 switch8 \
345 switchu8 \
346 truncdfsf2 \
347 udivsi3 \
348 umodsi3 \
349 unorddf2 \
350 unordsf2
351
352CCKEXT_ARMVFP_FUNCTIONS := $(CCKEXT_ARM_FUNCTIONS) \
353 adddf3vfp \
354 addsf3vfp \
355 divdf3vfp \
356 divsf3vfp \
357 eqdf2vfp \
358 eqsf2vfp \
359 extendsfdf2vfp \
360 fixdfsivfp \
361 fixsfsivfp \
362 fixunsdfsivfp \
363 fixunssfsivfp \
364 floatsidfvfp \
365 floatsisfvfp \
366 floatunssidfvfp \
367 floatunssisfvfp \
368 gedf2vfp \
369 gesf2vfp \
370 gtdf2vfp \
371 gtsf2vfp \
372 ledf2vfp \
373 lesf2vfp \
374 ltdf2vfp \
375 ltsf2vfp \
376 muldf3vfp \
377 mulsf3vfp \
378 nedf2vfp \
379 nesf2vfp \
380 subdf3vfp \
381 subsf3vfp \
382 truncdfsf2vfp \
383 unorddf2vfp \
384 unordsf2vfp
385
386FUNCTIONS.cc_kext.armv7 := $(CCKEXT_ARMVFP_FUNCTIONS)
387FUNCTIONS.cc_kext.armv7k := $(CCKEXT_ARMVFP_FUNCTIONS)
388FUNCTIONS.cc_kext.armv7s := $(CCKEXT_ARMVFP_FUNCTIONS)
389FUNCTIONS.cc_kext_ios5.armv7 := $(CCKEXT_ARMVFP_FUNCTIONS)
390FUNCTIONS.cc_kext_ios5.armv7k := $(CCKEXT_ARMVFP_FUNCTIONS)
391FUNCTIONS.cc_kext_ios5.armv7s := $(CCKEXT_ARMVFP_FUNCTIONS)
392
393CCKEXT_X86_FUNCTIONS := $(CCKEXT_COMMON_FUNCTIONS) \
394 divxc3 \
395 fixunsxfdi \
396 fixunsxfsi \
397 fixxfdi \
398 floatdixf \
399 floatundixf \
400 mulxc3 \
401 powixf2
402
403FUNCTIONS.cc_kext.i386 := $(CCKEXT_X86_FUNCTIONS) \
404 ffssi2 \
405 i686.get_pc_thunk.eax \
406 i686.get_pc_thunk.ebp \
407 i686.get_pc_thunk.ebx \
408 i686.get_pc_thunk.ecx \
409 i686.get_pc_thunk.edi \
410 i686.get_pc_thunk.edx \
411 i686.get_pc_thunk.esi
412
413FUNCTIONS.cc_kext.x86_64 := $(CCKEXT_X86_FUNCTIONS) \
414 absvti2 \
415 addvti3 \
416 ashlti3 \
417 ashrti3 \
418 clzti2 \
419 cmpti2 \
420 ctzti2 \
421 divti3 \
422 ffsti2 \
423 fixdfti \
424 fixsfti \
425 fixunsdfti \
426 fixunssfti \
427 fixunsxfti \
428 fixxfti \
429 floattidf \
430 floattisf \
431 floattixf \
432 floatuntidf \
433 floatuntisf \
434 floatuntixf \
435 lshrti3 \
436 modti3 \
437 multi3 \
438 mulvti3 \
439 negti2 \
440 negvti2 \
441 parityti2 \
442 popcountti2 \
443 subvti3 \
444 ucmpti2 \
445 udivmodti4 \
446 udivti3 \
447 umodti3
448
449FUNCTIONS.cc_kext.x86_64h := $(FUNCTIONS.cc_kext.x86_64)
450
451# FIXME: Currently, compiler-rt is missing implementations for a number of the
452# functions that need to go into libcc_kext.a. Filter them out for now.
453CCKEXT_MISSING_FUNCTIONS := \
454 cmpdf2 cmpsf2 div0 \
455 ffssi2 \
456 udiv_w_sdiv unorddf2 unordsf2 bswapdi2 \
457 bswapsi2 \
458 gcc_bcmp \
459 do_global_dtors \
460 i686.get_pc_thunk.eax i686.get_pc_thunk.ebp i686.get_pc_thunk.ebx \
461 i686.get_pc_thunk.ecx i686.get_pc_thunk.edi i686.get_pc_thunk.edx \
462 i686.get_pc_thunk.esi \
463 aeabi_cdcmpeq aeabi_cdrcmple aeabi_cfcmpeq aeabi_cfrcmple aeabi_dcmpeq \
464 aeabi_dcmpge aeabi_dcmpgt aeabi_dcmple aeabi_dcmplt aeabi_drsub aeabi_fcmpeq \
465 aeabi_fcmpge aeabi_fcmpgt aeabi_fcmple aeabi_fcmplt aeabi_frsub aeabi_idivmod \
466 aeabi_uidivmod
467
468FUNCTIONS.cc_kext.armv7 := \
469 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.armv7))
470FUNCTIONS.cc_kext.armv7k := \
471 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.armv7k))
472FUNCTIONS.cc_kext.armv7s := \
473 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.armv7s))
474FUNCTIONS.cc_kext_ios5.armv7 := \
475 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext_ios5.armv7))
476FUNCTIONS.cc_kext_ios5.armv7k := \
477 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext_ios5.armv7k))
478FUNCTIONS.cc_kext_ios5.armv7s := \
479 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext_ios5.armv7s))
480FUNCTIONS.cc_kext.i386 := \
481 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.i386))
482FUNCTIONS.cc_kext.x86_64 := \
483 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.x86_64))
484FUNCTIONS.cc_kext.x86_64h := \
485 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.x86_64h))
486
487KERNEL_USE.cc_kext := 1
488KERNEL_USE.cc_kext_ios5 := 1
489
490VISIBILITY_HIDDEN := 1
491
492SHARED_LIBRARY_SUFFIX := dylib