blob: f8bbde79feb4e5a6f10b18a842112eb7f42e6b94 [file] [log] [blame]
Evgeniy Stepanovdc3865b2012-03-13 15:38:23 +04001#
2# Copyright (C) 2012 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16#
17
18LOCAL_PATH := $(call my-dir)
Shih-wei Liao139a1062013-01-26 11:29:30 -080019
Stephen Hines30694612014-05-14 00:00:32 -070020ifeq (,$(TARGET_BUILD_APPS))
21
Shih-wei Liao139a1062013-01-26 11:29:30 -080022# The following list contains platform-independent functionalities.
23#
Shih-wei Liaocec07262013-01-26 22:12:04 -080024# Skip apple_versioning.c since it is unused.
Shih-wei Liao139a1062013-01-26 11:29:30 -080025# Skip atomic.c since it needs to be built separately according to the docs.
Shih-wei Liao4d402312013-01-26 23:20:02 -080026# Skip gcc_personality_v0.c since it depends on libunwind.
Shih-wei Liao139a1062013-01-26 11:29:30 -080027libcompiler_rt_common_SRC_FILES := \
Stephen Hines2d1fdb22014-05-28 23:58:16 -070028 lib/builtins/absvdi2.c \
29 lib/builtins/absvsi2.c \
30 lib/builtins/absvti2.c \
31 lib/builtins/adddf3.c \
32 lib/builtins/addsf3.c \
33 lib/builtins/addvdi3.c \
34 lib/builtins/addvsi3.c \
35 lib/builtins/addvti3.c \
36 lib/builtins/ashldi3.c \
37 lib/builtins/ashlti3.c \
38 lib/builtins/ashrdi3.c \
39 lib/builtins/ashrti3.c \
40 lib/builtins/clear_cache.c \
41 lib/builtins/clzdi2.c \
42 lib/builtins/clzsi2.c \
43 lib/builtins/clzti2.c \
44 lib/builtins/cmpdi2.c \
45 lib/builtins/cmpti2.c \
46 lib/builtins/comparedf2.c \
47 lib/builtins/comparesf2.c \
Dan Albert5148f962014-06-18 19:32:53 -070048 lib/builtins/comparetf2.c \
Stephen Hines2d1fdb22014-05-28 23:58:16 -070049 lib/builtins/ctzdi2.c \
50 lib/builtins/ctzsi2.c \
51 lib/builtins/ctzti2.c \
52 lib/builtins/divdc3.c \
53 lib/builtins/divdf3.c \
54 lib/builtins/divdi3.c \
55 lib/builtins/divmoddi4.c \
56 lib/builtins/divmodsi4.c \
57 lib/builtins/divsc3.c \
58 lib/builtins/divsf3.c \
59 lib/builtins/divsi3.c \
60 lib/builtins/divti3.c \
61 lib/builtins/divxc3.c \
62 lib/builtins/enable_execute_stack.c \
63 lib/builtins/eprintf.c \
64 lib/builtins/extendsfdf2.c \
65 lib/builtins/ffsdi2.c \
66 lib/builtins/ffsti2.c \
67 lib/builtins/fixdfdi.c \
68 lib/builtins/fixdfsi.c \
69 lib/builtins/fixdfti.c \
70 lib/builtins/fixsfdi.c \
71 lib/builtins/fixsfsi.c \
72 lib/builtins/fixsfti.c \
73 lib/builtins/fixunsdfdi.c \
74 lib/builtins/fixunsdfsi.c \
75 lib/builtins/fixunsdfti.c \
76 lib/builtins/fixunssfdi.c \
77 lib/builtins/fixunssfsi.c \
78 lib/builtins/fixunssfti.c \
79 lib/builtins/fixunsxfdi.c \
80 lib/builtins/fixunsxfsi.c \
81 lib/builtins/fixunsxfti.c \
82 lib/builtins/fixxfdi.c \
83 lib/builtins/fixxfti.c \
84 lib/builtins/floatdidf.c \
85 lib/builtins/floatdisf.c \
86 lib/builtins/floatdixf.c \
87 lib/builtins/floatsidf.c \
88 lib/builtins/floatsisf.c \
89 lib/builtins/floattidf.c \
90 lib/builtins/floattisf.c \
91 lib/builtins/floattixf.c \
92 lib/builtins/floatundidf.c \
93 lib/builtins/floatundisf.c \
94 lib/builtins/floatundixf.c \
95 lib/builtins/floatunsidf.c \
96 lib/builtins/floatunsisf.c \
97 lib/builtins/floatuntidf.c \
98 lib/builtins/floatuntisf.c \
99 lib/builtins/floatuntixf.c \
100 lib/builtins/int_util.c \
101 lib/builtins/lshrdi3.c \
102 lib/builtins/lshrti3.c \
103 lib/builtins/moddi3.c \
104 lib/builtins/modsi3.c \
105 lib/builtins/modti3.c \
106 lib/builtins/muldc3.c \
107 lib/builtins/muldf3.c \
108 lib/builtins/muldi3.c \
109 lib/builtins/mulodi4.c \
110 lib/builtins/mulosi4.c \
111 lib/builtins/muloti4.c \
112 lib/builtins/mulsc3.c \
113 lib/builtins/mulsf3.c \
114 lib/builtins/multi3.c \
115 lib/builtins/mulvdi3.c \
116 lib/builtins/mulvsi3.c \
117 lib/builtins/mulvti3.c \
118 lib/builtins/mulxc3.c \
119 lib/builtins/negdf2.c \
120 lib/builtins/negdi2.c \
121 lib/builtins/negsf2.c \
122 lib/builtins/negti2.c \
123 lib/builtins/negvdi2.c \
124 lib/builtins/negvsi2.c \
125 lib/builtins/negvti2.c \
126 lib/builtins/paritydi2.c \
127 lib/builtins/paritysi2.c \
128 lib/builtins/parityti2.c \
129 lib/builtins/popcountdi2.c \
130 lib/builtins/popcountsi2.c \
131 lib/builtins/popcountti2.c \
132 lib/builtins/powidf2.c \
133 lib/builtins/powisf2.c \
134 lib/builtins/powitf2.c \
135 lib/builtins/powixf2.c \
136 lib/builtins/subdf3.c \
137 lib/builtins/subsf3.c \
138 lib/builtins/subvdi3.c \
139 lib/builtins/subvsi3.c \
140 lib/builtins/subvti3.c \
141 lib/builtins/trampoline_setup.c \
142 lib/builtins/truncdfsf2.c \
143 lib/builtins/ucmpdi2.c \
144 lib/builtins/ucmpti2.c \
145 lib/builtins/udivdi3.c \
146 lib/builtins/udivmoddi4.c \
147 lib/builtins/udivmodsi4.c \
148 lib/builtins/udivmodti4.c \
149 lib/builtins/udivsi3.c \
150 lib/builtins/udivti3.c \
151 lib/builtins/umoddi3.c \
152 lib/builtins/umodsi3.c \
153 lib/builtins/umodti3.c
Shih-wei Liao139a1062013-01-26 11:29:30 -0800154
155# ARM-specific runtimes
156libcompiler_rt_arm_SRC_FILES := \
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700157 lib/builtins/arm/aeabi_dcmp.S \
158 lib/builtins/arm/aeabi_fcmp.S \
159 lib/builtins/arm/aeabi_idivmod.S \
160 lib/builtins/arm/aeabi_ldivmod.S \
161 lib/builtins/arm/aeabi_memcmp.S \
162 lib/builtins/arm/aeabi_memcpy.S \
163 lib/builtins/arm/aeabi_memmove.S \
164 lib/builtins/arm/aeabi_memset.S \
165 lib/builtins/arm/aeabi_uidivmod.S \
166 lib/builtins/arm/aeabi_uldivmod.S \
167 lib/builtins/arm/comparesf2.S \
168 lib/builtins/arm/divmodsi4.S \
169 lib/builtins/arm/divsi3.S \
170 lib/builtins/arm/modsi3.S \
171 lib/builtins/arm/udivmodsi4.S \
172 lib/builtins/arm/udivsi3.S \
173 lib/builtins/arm/umodsi3.S
Shih-wei Liao139a1062013-01-26 11:29:30 -0800174
Tim Murray6731c552014-03-10 11:10:47 -0700175# ARM64-specific runtimes
176libcompiler_rt_arm64_SRC_FILES :=
177
Shih-wei Liao139a1062013-01-26 11:29:30 -0800178# MIPS-specific runtimes
179libcompiler_rt_mips_SRC_FILES := # nothing to add
Duane Sand5b87b3d2014-05-20 11:06:29 -0700180libcompiler_rt_mips64_SRC_FILES := # nothing to add
Shih-wei Liao139a1062013-01-26 11:29:30 -0800181
182# X86-specific runtimes
Shih-wei Liao139a1062013-01-26 11:29:30 -0800183libcompiler_rt_x86_SRC_FILES := \
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700184 lib/builtins/i386/ashldi3.S \
185 lib/builtins/i386/ashrdi3.S \
186 lib/builtins/i386/divdi3.S \
187 lib/builtins/i386/floatdidf.S \
188 lib/builtins/i386/floatdisf.S \
189 lib/builtins/i386/floatdixf.S \
190 lib/builtins/i386/floatundidf.S \
191 lib/builtins/i386/floatundisf.S \
192 lib/builtins/i386/floatundixf.S \
193 lib/builtins/i386/lshrdi3.S \
194 lib/builtins/i386/moddi3.S \
195 lib/builtins/i386/muldi3.S \
196 lib/builtins/i386/udivdi3.S \
197 lib/builtins/i386/umoddi3.S
Shih-wei Liao139a1062013-01-26 11:29:30 -0800198
Alexey Volkov99395062014-01-17 17:44:56 +0400199# X86_64-specific runtimes
200libcompiler_rt_x86_64_SRC_FILES := \
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700201 lib/builtins/x86_64/floatundixf.S \
202 lib/builtins/x86_64/floatdisf.c \
203 lib/builtins/x86_64/floatdidf.c \
204 lib/builtins/x86_64/floatdixf.c \
205 lib/builtins/x86_64/floatundisf.S \
206 lib/builtins/x86_64/floatundidf.S
Alexey Volkov99395062014-01-17 17:44:56 +0400207
Shih-wei Liao139a1062013-01-26 11:29:30 -0800208# The following list contains functions that are not available in libgcc.a, so
209# we potentially need them when using a Clang-built component (e.g., -ftrapv
210# with 64-bit integer multiplies. See http://llvm.org/bugs/show_bug.cgi?id=14469.)
211libcompiler_rt_extras_SRC_FILES := \
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700212 lib/builtins/mulodi4.c
Shih-wei Liao139a1062013-01-26 11:29:30 -0800213
214# $(1): arch
215define get-libcompiler-rt-source-files
216 $(if $(findstring $(1),arm),$(call get-libcompiler-rt-arm-source-files),
217 $(if $(findstring $(1),mips),$(call get-libcompiler-rt-mips-source-files),
218 $(if $(findstring $(1),x86),$(call get-libcompiler-rt-x86-source-files),
Alexey Volkov99395062014-01-17 17:44:56 +0400219 $(if $(findstring $(1),x86_64),$(call get-libcompiler-rt-x86_64-source-files),
Pavel Chupin5534fc32013-07-25 20:31:56 +0400220 $(if $(findstring $(1),x32),$(call get-libcompiler-rt-x86-source-files),
Tim Murray6731c552014-03-10 11:10:47 -0700221 $(if $(findstring $(1),arm64),$(call get-libcompiler-rt-arm64-source-files),
Duane Sand5b87b3d2014-05-20 11:06:29 -0700222 $(if $(findstring $(1),mips64),$(call get-libcompiler-rt-mips64-source-files),
223 $(error Unsupported ARCH $(1)))))))))
Shih-wei Liao139a1062013-01-26 11:29:30 -0800224endef
225
226# $(1): source list
227# $(2): arch
228#
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700229# If lib/builtins/<arch>/X.[cS] is included in the source list, we should filter out lib/builtins/X.c
Shih-wei Liao139a1062013-01-26 11:29:30 -0800230# in the result source list (i.e., use the one optimized for the arch.) Otherwise
231# there'll be multiple definitions for one symbol.
232define filter-libcompiler-rt-common-source-files
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700233 $(filter-out $(patsubst lib/builtins/$(strip $(2))/%.S,lib/builtins/%.c,\
234 $(filter lib/builtins/$(strip $(2))/%.S,$(1))) \
235 $(patsubst lib/builtins/$(strip $(2))/%.c,lib/builtins/%.c,\
236 $(filter lib/builtins/$(strip $(2))/%.c,$(1))),$(1))
Shih-wei Liao139a1062013-01-26 11:29:30 -0800237endef
238
Shih-wei Liaoece62642013-02-07 07:49:51 -0800239define get-libcompiler-rt-arm-common-source-files
Shih-wei Liao139a1062013-01-26 11:29:30 -0800240 $(call filter-libcompiler-rt-common-source-files,
Shih-wei Liaoc8f55192013-02-07 22:00:08 -0800241 $(libcompiler_rt_common_SRC_FILES) \
Shih-wei Liaoece62642013-02-07 07:49:51 -0800242 $(libcompiler_rt_arm_SRC_FILES), arm)
243endef
244
245# $(1): common runtime list
246#
247# Add ARM runtimes implemented in VFP
248define add-libcompiler-rt-arm-vfp-source-files
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700249 $(filter-out $(addprefix lib/builtins/,adddf3.c addsf3.c comparedf2.c comparesf2.c \
250 arm/comparesf2.S divdf3.c divsf3.c extendsfdf2.c \
251 fixdfsi.c fixsfsi.c fixunsdfsi.c fixunssfsi.c \
252 floatsidf.c floatsisf.c floatunsidf.c floatunsisf.c \
253 muldf3.c mulsf3.c negdf2.c negsf2.c subdf3.c \
254 subsf3.c truncdfsf2.c),$(1)) lib/builtins/arm/vfp_alias.S
Shih-wei Liaoece62642013-02-07 07:49:51 -0800255endef
256
257define get-libcompiler-rt-arm-source-files
258 $(if $(findstring $(ARCH_ARM_HAVE_VFP),true),
259 $(call add-libcompiler-rt-arm-vfp-source-files,
260 $(call get-libcompiler-rt-arm-common-source-files)),
261 $(call get-libcompiler-rt-arm-common-source-files))
Shih-wei Liao139a1062013-01-26 11:29:30 -0800262endef
263
Tim Murray6731c552014-03-10 11:10:47 -0700264define get-libcompiler-rt-arm64-source-files
265 $(call filter-libcompiler-rt-common-source-files,
266 $(libcompiler_rt_common_SRC_FILES) \
267 $(libcompiler_rt_arm64_SRC_FILES),arm64)
268endef
269
Shih-wei Liao139a1062013-01-26 11:29:30 -0800270define get-libcompiler-rt-mips-source-files
271 $(call filter-libcompiler-rt-common-source-files,
Shih-wei Liaoc8f55192013-02-07 22:00:08 -0800272 $(libcompiler_rt_common_SRC_FILES) \
Shih-wei Liao139a1062013-01-26 11:29:30 -0800273 $(libcompiler_rt_mips_SRC_FILES),mips)
274endef
275
Duane Sand5b87b3d2014-05-20 11:06:29 -0700276define get-libcompiler-rt-mips64-source-files
277 $(call filter-libcompiler-rt-common-source-files,
278 $(libcompiler_rt_common_SRC_FILES) \
279 $(libcompiler_rt_mips64_SRC_FILES),mips64)
280endef
281
Shih-wei Liao139a1062013-01-26 11:29:30 -0800282define get-libcompiler-rt-x86-source-files
283 $(call filter-libcompiler-rt-common-source-files,
Shih-wei Liaoc8f55192013-02-07 22:00:08 -0800284 $(libcompiler_rt_common_SRC_FILES) \
Shih-wei Liao139a1062013-01-26 11:29:30 -0800285 $(libcompiler_rt_x86_SRC_FILES),i386)
286endef
287
Alexey Volkov99395062014-01-17 17:44:56 +0400288define get-libcompiler-rt-x86_64-source-files
289 $(call filter-libcompiler-rt-common-source-files,
290 $(libcompiler_rt_common_SRC_FILES) \
291 $(libcompiler_rt_x86_64_SRC_FILES),x86_64)
292endef
293
Evgeniy Stepanovdc3865b2012-03-13 15:38:23 +0400294#=====================================================================
Shih-wei Liao7f489a32013-02-07 03:34:40 -0800295# Device Static Library: libcompiler_rt-extras
Evgeniy Stepanovdc3865b2012-03-13 15:38:23 +0400296#=====================================================================
297
Evgeniy Stepanovdc3865b2012-03-13 15:38:23 +0400298include $(CLEAR_VARS)
299
Shih-wei Liao7f489a32013-02-07 03:34:40 -0800300LOCAL_MODULE := libcompiler_rt-extras
Evgeniy Stepanovdc3865b2012-03-13 15:38:23 +0400301LOCAL_MODULE_TAGS := optional
302LOCAL_MODULE_CLASS := STATIC_LIBRARIES
303LOCAL_CLANG := true
Shih-wei Liao139a1062013-01-26 11:29:30 -0800304LOCAL_SRC_FILES := $(libcompiler_rt_extras_SRC_FILES)
Stephen Hines97ac43c2013-01-18 17:46:14 -0800305LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Evgeniy Stepanovdc3865b2012-03-13 15:38:23 +0400306
Evgeniy Stepanovdc3865b2012-03-13 15:38:23 +0400307include $(BUILD_STATIC_LIBRARY)
308
Colin Cross47ca89c2014-03-14 20:12:30 -0700309# Don't build compiler-rt without clang
310ifneq ($(WITHOUT_TARGET_CLANG), true)
311
Shih-wei Liao139a1062013-01-26 11:29:30 -0800312#=====================================================================
Shih-wei Liao7f489a32013-02-07 03:34:40 -0800313# Device Static Library: libcompiler_rt
Shih-wei Liao139a1062013-01-26 11:29:30 -0800314#=====================================================================
Colin Cross75d873d2014-02-04 16:24:23 -0800315
316include $(CLEAR_VARS)
317
Colin Cross75d873d2014-02-04 16:24:23 -0800318LOCAL_MODULE := libcompiler_rt
319LOCAL_CFLAGS_arm += -D__ARM_EABI__
320LOCAL_ASFLAGS := -integrated-as
321LOCAL_CLANG := true
322LOCAL_SRC_FILES_arm := $(call get-libcompiler-rt-source-files,arm)
Tim Murray6731c552014-03-10 11:10:47 -0700323LOCAL_SRC_FILES_arm64 := $(call get-libcompiler-rt-source-files,arm64)
Colin Cross75d873d2014-02-04 16:24:23 -0800324LOCAL_SRC_FILES_mips := $(call get-libcompiler-rt-source-files,mips)
Duane Sand5b87b3d2014-05-20 11:06:29 -0700325LOCAL_SRC_FILES_mips64 := $(call get-libcompiler-rt-source-files,mips64)
Colin Cross75d873d2014-02-04 16:24:23 -0800326LOCAL_SRC_FILES_x86 := $(call get-libcompiler-rt-source-files,x86)
327LOCAL_SRC_FILES_x86_64 := $(call get-libcompiler-rt-source-files,x86_64)
Duane Sand5b87b3d2014-05-20 11:06:29 -0700328LOCAL_MODULE_TARGET_ARCH := arm arm64 mips mips64 x86 x86_64
Colin Cross75d873d2014-02-04 16:24:23 -0800329LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
330
331include $(BUILD_STATIC_LIBRARY)
332
Shih-wei Liaofba76912013-01-27 00:56:26 -0800333#=====================================================================
Dan Albert95b6e9a2014-05-01 17:40:29 -0700334# Host Static Library: libcompiler_rt
335#=====================================================================
336
337include $(CLEAR_VARS)
338
339LOCAL_MODULE := libcompiler_rt
340LOCAL_ASFLAGS := -integrated-as
341LOCAL_CLANG := true
342LOCAL_SRC_FILES := $(call get-libcompiler-rt-source-files,x86_64)
343LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Ian Rogersa217f3e2014-06-05 11:44:01 -0700344LOCAL_MULTILIB := both
Dan Albert95b6e9a2014-05-01 17:40:29 -0700345
346include $(BUILD_HOST_STATIC_LIBRARY)
347
348#=====================================================================
Dmitriy Ivanovba9a7b32014-03-10 18:00:09 -0700349# Device Static Library: libprofile_rt
350#=====================================================================
351
352include $(CLEAR_VARS)
353
354LOCAL_MODULE = libprofile_rt
355LOCAL_SRC_FILES = lib/profile/GCDAProfiling.c
356
357include $(BUILD_STATIC_LIBRARY)
358
359#=====================================================================
Shih-wei Liaofba76912013-01-27 00:56:26 -0800360# Device Shared Library: libcompiler_rt
361#=====================================================================
Serban Constantinescue3c30bf2013-10-20 15:36:30 +0100362
Colin Cross75d873d2014-02-04 16:24:23 -0800363include $(CLEAR_VARS)
364
365LOCAL_MODULE := libcompiler_rt
366LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
367LOCAL_WHOLE_STATIC_LIBRARIES := libcompiler_rt
Duane Sand5b87b3d2014-05-20 11:06:29 -0700368LOCAL_MODULE_TARGET_ARCH := arm arm64 mips mips64 x86 x86_64
Colin Cross75d873d2014-02-04 16:24:23 -0800369
370include $(BUILD_SHARED_LIBRARY)
Shih-wei Liaofba76912013-01-27 00:56:26 -0800371
Shih-wei Liao139a1062013-01-26 11:29:30 -0800372# Build ASan
373include $(LOCAL_PATH)/lib/asan/Android.mk
Tim Murray4b4f5572014-03-14 17:46:31 -0700374
Dan Albert95b6e9a2014-05-01 17:40:29 -0700375#=====================================================================
376# Host Shared Library: libcompiler_rt
377#=====================================================================
378
379include $(CLEAR_VARS)
380
381LOCAL_MODULE := libcompiler_rt
382LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
383LOCAL_WHOLE_STATIC_LIBRARIES := libcompiler_rt
384LOCAL_CPPFLAGS := -nostdinc++
385LOCAL_LDFLAGS := -nodefaultlibs
386LOCAL_LDLIBS := -lc -lm
Ian Rogersa217f3e2014-06-05 11:44:01 -0700387LOCAL_MULTILIB := both
Dan Albert95b6e9a2014-05-01 17:40:29 -0700388
389include $(BUILD_HOST_SHARED_LIBRARY)
390
Colin Cross47ca89c2014-03-14 20:12:30 -0700391endif
Stephen Hines30694612014-05-14 00:00:32 -0700392
393endif # TARGET_BUILD_APPS only