]> git.proxmox.com Git - rustc.git/blob - 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
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
7 Description := 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.
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 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
36 XCRun = \
37 $(shell \
38 result=`xcrun -find $(1) 2> /dev/null`; \
39 if [ "$$?" != "0" ]; then result=$(1); fi; \
40 echo $$result)
41 XCRunSdkPath = \
42 $(shell \
43 result=`xcrun --sdk $(1) --show-sdk-path 2> /dev/null`; \
44 if [ "$$?" != "0" ]; then result=""; fi; \
45 echo $$result)
46 ###
47
48 CC := $(call XCRun,clang)
49 LD := $(shell $(CC) -print-prog-name=ld)
50 AR := $(call XCRun,ar)
51 RANLIB := $(call XCRun,ranlib)
52 STRIP := $(call XCRun,strip)
53 LIPO := $(call XCRun,lipo)
54 DSYMUTIL := $(call XCRun,dsymutil)
55
56 Configs :=
57 UniversalArchs :=
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.
62 Configs += eprintf
63 UniversalArchs.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.
68 Configs += 10.4
69 UniversalArchs.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.
73 Configs += ios
74 UniversalArchs.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.
78 Configs += osx
79 UniversalArchs.osx := $(call CheckArches,i386 x86_64 x86_64h,osx)
80
81 # Configuration for use with kernel/kexts.
82 Configs += cc_kext
83 UniversalArchs.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).
87 Configs += cc_kext_ios5
88 UniversalArchs.cc_kext_ios5 := $(call CheckArches,x86_64 x86_64h armv7,cc_kext_ios5)
89
90 # Configurations which define the profiling support functions.
91 Configs += profile_osx
92 UniversalArchs.profile_osx := $(call CheckArches,i386 x86_64 x86_64h,profile_osx)
93 Configs += profile_ios
94 UniversalArchs.profile_ios := $(call CheckArches,i386 x86_64 x86_64h armv7,profile_ios)
95
96 # Configurations which define the ASAN support functions.
97 Configs += asan_osx_dynamic
98 UniversalArchs.asan_osx_dynamic := $(call CheckArches,i386 x86_64 x86_64h,asan_osx_dynamic)
99
100 IOSSIM_SDK_PATH := $(call XCRunSdkPath,iphonesimulator)
101 ifneq ($(IOSSIM_SDK_PATH),)
102 Configs += asan_iossim_dynamic
103 UniversalArchs.asan_iossim_dynamic := $(call CheckArches,i386 x86_64 x86_64h,asan_iossim_dynamic)
104 endif
105
106 Configs += ubsan_osx
107 UniversalArchs.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.
113 ifneq ($(shell test -x /usr/bin/sw_vers && sw_vers -productVersion | grep 10.6),)
114 UniversalArchs.ios := $(filter-out armv7, $(UniversalArchs.ios))
115 UniversalArchs.cc_kext := $(filter-out armv7, $(UniversalArchs.cc_kext))
116 UniversalArchs.cc_kext_ios5 := $(filter-out armv7, $(UniversalArchs.cc_kext_ios5))
117 UniversalArchs.profile_ios := $(filter-out armv7, $(UniversalArchs.profile_ios))
118 endif
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.
125 ifneq ($(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)))))
131 endif
132
133 ###
134
135 # Forcibly strip off any -arch, as that totally breaks our universal support.
136 override CC := $(subst -arch ,-arch_,$(CC))
137 override CC := $(patsubst -arch_%,,$(CC))
138
139 CFLAGS := -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.
145 OSX_DEPLOYMENT_ARGS := -mmacosx-version-min=10.4
146 IOS_DEPLOYMENT_ARGS := -mios-version-min=1.0
147 IOS6_DEPLOYMENT_ARGS := -mios-version-min=6.0
148 IOSSIM_DEPLOYMENT_ARGS := -mios-simulator-version-min=1.0
149
150 # Use our stub SDK as the sysroot to support more portable building.
151 OSX_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin
152 IOS_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin
153 IOS6_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin
154 IOSSIM_DEPLOYMENT_ARGS += -isysroot $(ProjSrcRoot)/SDKs/darwin
155
156 CFLAGS.eprintf := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
157 CFLAGS.10.4 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
158 # FIXME: We can't build ASAN with our stub SDK yet.
159 CFLAGS.asan_osx_dynamic := \
160 $(CFLAGS) -mmacosx-version-min=10.6 -fno-builtin \
161 -gline-tables-only \
162 -DMAC_INTERPOSE_FUNCTIONS=1
163
164 CFLAGS.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
171 CFLAGS.ubsan_osx := $(CFLAGS) -mmacosx-version-min=10.6 -fno-builtin
172
173 CFLAGS.ios.i386 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
174 CFLAGS.ios.x86_64 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
175 CFLAGS.ios.x86_64h := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
176 CFLAGS.ios.armv7 := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
177 CFLAGS.ios.armv7k := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
178 CFLAGS.ios.armv7s := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
179 CFLAGS.osx.i386 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
180 CFLAGS.osx.x86_64 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
181 CFLAGS.osx.x86_64h := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
182 CFLAGS.cc_kext.i386 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
183 CFLAGS.cc_kext.x86_64 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
184 CFLAGS.cc_kext.x86_64h := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
185 CFLAGS.cc_kext.armv7 := $(CFLAGS) $(IOS6_DEPLOYMENT_ARGS)
186 CFLAGS.cc_kext.armv7k := $(CFLAGS) $(IOS6_DEPLOYMENT_ARGS)
187 CFLAGS.cc_kext.armv7s := $(CFLAGS) $(IOS6_DEPLOYMENT_ARGS)
188 CFLAGS.cc_kext_ios5.armv7 := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
189 CFLAGS.cc_kext_ios5.armv7k := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
190 CFLAGS.cc_kext_ios5.armv7s := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
191 CFLAGS.profile_osx.i386 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
192 CFLAGS.profile_osx.x86_64 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
193 CFLAGS.profile_osx.x86_64h := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
194 CFLAGS.profile_ios.i386 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
195 CFLAGS.profile_ios.x86_64 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
196 CFLAGS.profile_ios.x86_64h := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
197 CFLAGS.profile_ios.armv7 := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
198 CFLAGS.profile_ios.armv7k := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
199 CFLAGS.profile_ios.armv7s := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
200
201 # Configure the asan_osx_dynamic library to be built shared.
202 SHARED_LIBRARY.asan_osx_dynamic := 1
203 LDFLAGS.asan_osx_dynamic := -lstdc++ -undefined dynamic_lookup
204
205 # Configure the asan_iossim_dynamic library to be built shared.
206 SHARED_LIBRARY.asan_iossim_dynamic := 1
207 # configure+make uses Clang, so we're using isysroot instead of --sysroot
208 # or -Wl,-syslibroot.
209 LDFLAGS.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
213 FUNCTIONS.eprintf := eprintf
214 FUNCTIONS.10.4 := eprintf floatundidf floatundisf floatundixf
215
216 FUNCTIONS.ios := divmodsi4 udivmodsi4 mulosi4 mulodi4 muloti4
217 # On x86, the divmod functions reference divsi.
218 FUNCTIONS.ios.i386 := $(FUNCTIONS.ios) \
219 divsi3 udivsi3
220 FUNCTIONS.ios.x86_64 := $(FUNCTIONS.ios.i386)
221 FUNCTIONS.ios.x86_64h := $(FUNCTIONS.ios.x86_64)
222
223 FUNCTIONS.osx := mulosi4 mulodi4 muloti4
224
225 FUNCTIONS.profile_osx := GCDAProfiling InstrProfiling InstrProfilingBuffer \
226 InstrProfilingFile InstrProfilingPlatformDarwin \
227 InstrProfilingRuntime
228 FUNCTIONS.profile_ios := $(FUNCTIONS.profile_osx)
229
230 FUNCTIONS.asan_osx_dynamic := $(AsanFunctions) $(InterceptionFunctions) \
231 $(SanitizerCommonFunctions) \
232 $(AsanDynamicFunctions)
233
234 FUNCTIONS.asan_iossim_dynamic := $(AsanFunctions) $(InterceptionFunctions) \
235 $(SanitizerCommonFunctions) \
236 $(AsanDynamicFunctions)
237
238 FUNCTIONS.ubsan_osx := $(UbsanFunctions) $(UbsanCXXFunctions) \
239 $(SanitizerCommonFunctions)
240
241 CCKEXT_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
298 CCKEXT_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
352 CCKEXT_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
386 FUNCTIONS.cc_kext.armv7 := $(CCKEXT_ARMVFP_FUNCTIONS)
387 FUNCTIONS.cc_kext.armv7k := $(CCKEXT_ARMVFP_FUNCTIONS)
388 FUNCTIONS.cc_kext.armv7s := $(CCKEXT_ARMVFP_FUNCTIONS)
389 FUNCTIONS.cc_kext_ios5.armv7 := $(CCKEXT_ARMVFP_FUNCTIONS)
390 FUNCTIONS.cc_kext_ios5.armv7k := $(CCKEXT_ARMVFP_FUNCTIONS)
391 FUNCTIONS.cc_kext_ios5.armv7s := $(CCKEXT_ARMVFP_FUNCTIONS)
392
393 CCKEXT_X86_FUNCTIONS := $(CCKEXT_COMMON_FUNCTIONS) \
394 divxc3 \
395 fixunsxfdi \
396 fixunsxfsi \
397 fixxfdi \
398 floatdixf \
399 floatundixf \
400 mulxc3 \
401 powixf2
402
403 FUNCTIONS.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
413 FUNCTIONS.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
449 FUNCTIONS.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.
453 CCKEXT_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
468 FUNCTIONS.cc_kext.armv7 := \
469 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.armv7))
470 FUNCTIONS.cc_kext.armv7k := \
471 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.armv7k))
472 FUNCTIONS.cc_kext.armv7s := \
473 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.armv7s))
474 FUNCTIONS.cc_kext_ios5.armv7 := \
475 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext_ios5.armv7))
476 FUNCTIONS.cc_kext_ios5.armv7k := \
477 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext_ios5.armv7k))
478 FUNCTIONS.cc_kext_ios5.armv7s := \
479 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext_ios5.armv7s))
480 FUNCTIONS.cc_kext.i386 := \
481 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.i386))
482 FUNCTIONS.cc_kext.x86_64 := \
483 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.x86_64))
484 FUNCTIONS.cc_kext.x86_64h := \
485 $(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.x86_64h))
486
487 KERNEL_USE.cc_kext := 1
488 KERNEL_USE.cc_kext_ios5 := 1
489
490 VISIBILITY_HIDDEN := 1
491
492 SHARED_LIBRARY_SUFFIX := dylib