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.
14 for arch in
$(1); do \
15 if
$(CC
) -arch
$$arch -c \
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 "; \
25 "warning: clang_darwin.mk: dropping arch '$$arch' from lib '$(2)'"; \
26 printf
1>&2 " (ld does not support it)\n"; \
30 "warning: clang_darwin.mk: dropping arch '$$arch' from lib '$(2)'"; \
31 printf
1>&2 " (clang does not support it)\n"; \
38 result
=`xcrun -find $(1) 2> /dev/null`; \
39 if
[ "$$?" != "0" ]; then result
=$(1); fi
; \
43 result
=`xcrun --sdk $(1) --show-sdk-path 2> /dev/null`; \
44 if
[ "$$?" != "0" ]; then result
=""; fi
; \
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
)
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
63 UniversalArchs.eprintf
:= $(call CheckArches
,i386
,eprintf
)
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.
69 UniversalArchs
.10.4 := $(call CheckArches
,i386 x86_64
,10.4)
71 # Configuration for targetting iOS for a couple of functions that didn't
72 # make it into libSystem.
74 UniversalArchs.ios
:= $(call CheckArches
,i386 x86_64 x86_64h armv7
,ios
)
76 # Configuration for targetting OSX. These functions may not be in libSystem
77 # so we should provide our own.
79 UniversalArchs.osx
:= $(call CheckArches
,i386 x86_64 x86_64h
,osx
)
81 # Configuration for use with kernel/kexts.
83 UniversalArchs.cc_kext
:= $(call CheckArches
,armv7 i386 x86_64 x86_64h
,cc_kext
)
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
)
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
)
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
)
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
)
107 UniversalArchs.ubsan_osx
:= $(call CheckArches
,i386 x86_64 x86_64h
,ubsan_osx
)
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
))
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.
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
)))))
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
))
139 CFLAGS
:= -fPIC
-Wall
-Werror
-O3
-fomit-frame-pointer
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
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
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 \
162 -DMAC_INTERPOSE_FUNCTIONS
=1
164 CFLAGS.asan_iossim_dynamic
:= \
165 $(CFLAGS
) -mios-simulator-version-min
=7.0 \
166 -isysroot
$(IOSSIM_SDK_PATH
) \
169 -DMAC_INTERPOSE_FUNCTIONS
=1
171 CFLAGS.ubsan_osx
:= $(CFLAGS
) -mmacosx-version-min
=10.6 -fno-builtin
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
)
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
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
)
213 FUNCTIONS.eprintf
:= eprintf
214 FUNCTIONS
.10.4 := eprintf floatundidf floatundisf floatundixf
216 FUNCTIONS.ios
:= divmodsi4 udivmodsi4 mulosi4 mulodi4 muloti4
217 # On x86, the divmod functions reference divsi.
218 FUNCTIONS.ios.i386
:= $(FUNCTIONS.ios
) \
220 FUNCTIONS.ios.x86_64
:= $(FUNCTIONS.ios.i386
)
221 FUNCTIONS.ios.x86_64h
:= $(FUNCTIONS.ios.x86_64
)
223 FUNCTIONS.osx
:= mulosi4 mulodi4 muloti4
225 FUNCTIONS.profile_osx
:= GCDAProfiling InstrProfiling InstrProfilingBuffer \
226 InstrProfilingFile InstrProfilingPlatformDarwin \
227 InstrProfilingRuntime
228 FUNCTIONS.profile_ios
:= $(FUNCTIONS.profile_osx
)
230 FUNCTIONS.asan_osx_dynamic
:= $(AsanFunctions
) $(InterceptionFunctions
) \
231 $(SanitizerCommonFunctions
) \
232 $(AsanDynamicFunctions
)
234 FUNCTIONS.asan_iossim_dynamic
:= $(AsanFunctions
) $(InterceptionFunctions
) \
235 $(SanitizerCommonFunctions
) \
236 $(AsanDynamicFunctions
)
238 FUNCTIONS.ubsan_osx
:= $(UbsanFunctions
) $(UbsanCXXFunctions
) \
239 $(SanitizerCommonFunctions
)
241 CCKEXT_COMMON_FUNCTIONS
:= \
298 CCKEXT_ARM_FUNCTIONS
:= $(CCKEXT_COMMON_FUNCTIONS
) \
352 CCKEXT_ARMVFP_FUNCTIONS
:= $(CCKEXT_ARM_FUNCTIONS
) \
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
)
393 CCKEXT_X86_FUNCTIONS
:= $(CCKEXT_COMMON_FUNCTIONS
) \
403 FUNCTIONS.cc_kext.i386
:= $(CCKEXT_X86_FUNCTIONS
) \
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
413 FUNCTIONS.cc_kext.x86_64
:= $(CCKEXT_X86_FUNCTIONS
) \
449 FUNCTIONS.cc_kext.x86_64h
:= $(FUNCTIONS.cc_kext.x86_64
)
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
:= \
456 udiv_w_sdiv unorddf2 unordsf2 bswapdi2 \
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 \
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
))
487 KERNEL_USE.cc_kext
:= 1
488 KERNEL_USE.cc_kext_ios5
:= 1
490 VISIBILITY_HIDDEN
:= 1
492 SHARED_LIBRARY_SUFFIX
:= dylib