blob: 2a0ce82e938670e55cad95c764c8dab2bebfec10 [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 := \
28 lib/absvdi2.c \
29 lib/absvsi2.c \
30 lib/absvti2.c \
31 lib/adddf3.c \
32 lib/addsf3.c \
33 lib/addvdi3.c \
34 lib/addvsi3.c \
35 lib/addvti3.c \
Shih-wei Liao139a1062013-01-26 11:29:30 -080036 lib/ashldi3.c \
37 lib/ashlti3.c \
38 lib/ashrdi3.c \
39 lib/ashrti3.c \
Narayan Kamath1a34dac2014-03-14 13:18:47 +000040 lib/clear_cache.c \
Shih-wei Liao139a1062013-01-26 11:29:30 -080041 lib/clzdi2.c \
42 lib/clzsi2.c \
43 lib/clzti2.c \
44 lib/cmpdi2.c \
45 lib/cmpti2.c \
46 lib/comparedf2.c \
47 lib/comparesf2.c \
48 lib/ctzdi2.c \
49 lib/ctzsi2.c \
50 lib/ctzti2.c \
51 lib/divdc3.c \
52 lib/divdf3.c \
53 lib/divdi3.c \
54 lib/divmoddi4.c \
55 lib/divmodsi4.c \
56 lib/divsc3.c \
57 lib/divsf3.c \
58 lib/divsi3.c \
59 lib/divti3.c \
60 lib/divxc3.c \
61 lib/enable_execute_stack.c \
62 lib/eprintf.c \
63 lib/extendsfdf2.c \
64 lib/ffsdi2.c \
65 lib/ffsti2.c \
66 lib/fixdfdi.c \
67 lib/fixdfsi.c \
68 lib/fixdfti.c \
69 lib/fixsfdi.c \
70 lib/fixsfsi.c \
71 lib/fixsfti.c \
72 lib/fixunsdfdi.c \
73 lib/fixunsdfsi.c \
74 lib/fixunsdfti.c \
75 lib/fixunssfdi.c \
76 lib/fixunssfsi.c \
77 lib/fixunssfti.c \
78 lib/fixunsxfdi.c \
79 lib/fixunsxfsi.c \
80 lib/fixunsxfti.c \
81 lib/fixxfdi.c \
82 lib/fixxfti.c \
83 lib/floatdidf.c \
84 lib/floatdisf.c \
85 lib/floatdixf.c \
86 lib/floatsidf.c \
87 lib/floatsisf.c \
88 lib/floattidf.c \
89 lib/floattisf.c \
90 lib/floattixf.c \
91 lib/floatundidf.c \
92 lib/floatundisf.c \
93 lib/floatundixf.c \
94 lib/floatunsidf.c \
95 lib/floatunsisf.c \
96 lib/floatuntidf.c \
97 lib/floatuntisf.c \
98 lib/floatuntixf.c \
Shih-wei Liao139a1062013-01-26 11:29:30 -080099 lib/int_util.c \
100 lib/lshrdi3.c \
101 lib/lshrti3.c \
102 lib/moddi3.c \
103 lib/modsi3.c \
104 lib/modti3.c \
105 lib/muldc3.c \
106 lib/muldf3.c \
107 lib/muldi3.c \
Shih-wei Liaof5c93a02013-01-26 23:02:34 -0800108 lib/mulodi4.c \
Shih-wei Liao139a1062013-01-26 11:29:30 -0800109 lib/mulosi4.c \
110 lib/muloti4.c \
111 lib/mulsc3.c \
112 lib/mulsf3.c \
113 lib/multi3.c \
114 lib/mulvdi3.c \
115 lib/mulvsi3.c \
116 lib/mulvti3.c \
117 lib/mulxc3.c \
118 lib/negdf2.c \
119 lib/negdi2.c \
120 lib/negsf2.c \
121 lib/negti2.c \
122 lib/negvdi2.c \
123 lib/negvsi2.c \
124 lib/negvti2.c \
125 lib/paritydi2.c \
126 lib/paritysi2.c \
127 lib/parityti2.c \
128 lib/popcountdi2.c \
129 lib/popcountsi2.c \
130 lib/popcountti2.c \
131 lib/powidf2.c \
132 lib/powisf2.c \
133 lib/powitf2.c \
134 lib/powixf2.c \
135 lib/subdf3.c \
136 lib/subsf3.c \
137 lib/subvdi3.c \
138 lib/subvsi3.c \
139 lib/subvti3.c \
140 lib/trampoline_setup.c \
141 lib/truncdfsf2.c \
142 lib/ucmpdi2.c \
143 lib/ucmpti2.c \
144 lib/udivdi3.c \
145 lib/udivmoddi4.c \
146 lib/udivmodsi4.c \
147 lib/udivmodti4.c \
148 lib/udivsi3.c \
149 lib/udivti3.c \
150 lib/umoddi3.c \
151 lib/umodsi3.c \
152 lib/umodti3.c
153
154# ARM-specific runtimes
155libcompiler_rt_arm_SRC_FILES := \
Shih-wei Liaoe1c8a832013-02-07 07:33:11 -0800156 lib/arm/aeabi_dcmp.S \
157 lib/arm/aeabi_fcmp.S \
Shih-wei Liaofe42f082013-01-26 23:26:12 -0800158 lib/arm/aeabi_idivmod.S \
159 lib/arm/aeabi_ldivmod.S \
160 lib/arm/aeabi_memcmp.S \
161 lib/arm/aeabi_memcpy.S \
162 lib/arm/aeabi_memmove.S \
163 lib/arm/aeabi_memset.S \
164 lib/arm/aeabi_uidivmod.S \
Shih-wei Liaoece62642013-02-07 07:49:51 -0800165 lib/arm/aeabi_uldivmod.S \
Shih-wei Liao6fd582c2013-01-27 00:41:48 -0800166 lib/arm/comparesf2.S \
Shih-wei Liao6fd582c2013-01-27 00:41:48 -0800167 lib/arm/divmodsi4.S \
Shih-wei Liao6fd582c2013-01-27 00:41:48 -0800168 lib/arm/divsi3.S \
Shih-wei Liao6fd582c2013-01-27 00:41:48 -0800169 lib/arm/modsi3.S \
Shih-wei Liao6fd582c2013-01-27 00:41:48 -0800170 lib/arm/udivmodsi4.S \
171 lib/arm/udivsi3.S \
Shih-wei Liaoece62642013-02-07 07:49:51 -0800172 lib/arm/umodsi3.S
Shih-wei Liao139a1062013-01-26 11:29:30 -0800173
Tim Murray6731c552014-03-10 11:10:47 -0700174# ARM64-specific runtimes
175libcompiler_rt_arm64_SRC_FILES :=
176
Shih-wei Liao139a1062013-01-26 11:29:30 -0800177# MIPS-specific runtimes
178libcompiler_rt_mips_SRC_FILES := # nothing to add
179
180# X86-specific runtimes
Shih-wei Liao139a1062013-01-26 11:29:30 -0800181libcompiler_rt_x86_SRC_FILES := \
182 lib/i386/ashldi3.S \
183 lib/i386/ashrdi3.S \
184 lib/i386/divdi3.S \
185 lib/i386/floatdidf.S \
186 lib/i386/floatdisf.S \
187 lib/i386/floatdixf.S \
188 lib/i386/floatundidf.S \
189 lib/i386/floatundisf.S \
190 lib/i386/floatundixf.S \
191 lib/i386/lshrdi3.S \
192 lib/i386/moddi3.S \
193 lib/i386/muldi3.S \
194 lib/i386/udivdi3.S \
195 lib/i386/umoddi3.S
196
Alexey Volkov99395062014-01-17 17:44:56 +0400197# X86_64-specific runtimes
198libcompiler_rt_x86_64_SRC_FILES := \
199 lib/x86_64/floatundixf.S \
200 lib/x86_64/floatdisf.c \
201 lib/x86_64/floatdidf.c \
202 lib/x86_64/floatdixf.c \
203 lib/x86_64/floatundisf.S \
204 lib/x86_64/floatundidf.S
205
Shih-wei Liao139a1062013-01-26 11:29:30 -0800206# The following list contains functions that are not available in libgcc.a, so
207# we potentially need them when using a Clang-built component (e.g., -ftrapv
208# with 64-bit integer multiplies. See http://llvm.org/bugs/show_bug.cgi?id=14469.)
209libcompiler_rt_extras_SRC_FILES := \
210 lib/mulodi4.c
211
212# $(1): arch
213define get-libcompiler-rt-source-files
214 $(if $(findstring $(1),arm),$(call get-libcompiler-rt-arm-source-files),
215 $(if $(findstring $(1),mips),$(call get-libcompiler-rt-mips-source-files),
216 $(if $(findstring $(1),x86),$(call get-libcompiler-rt-x86-source-files),
Alexey Volkov99395062014-01-17 17:44:56 +0400217 $(if $(findstring $(1),x86_64),$(call get-libcompiler-rt-x86_64-source-files),
Pavel Chupin5534fc32013-07-25 20:31:56 +0400218 $(if $(findstring $(1),x32),$(call get-libcompiler-rt-x86-source-files),
Tim Murray6731c552014-03-10 11:10:47 -0700219 $(if $(findstring $(1),arm64),$(call get-libcompiler-rt-arm64-source-files),
220 $(error Unsupported ARCH $(1))))))))
Shih-wei Liao139a1062013-01-26 11:29:30 -0800221endef
222
223# $(1): source list
224# $(2): arch
225#
Alexey Volkov99395062014-01-17 17:44:56 +0400226# If lib/<arch>/X.[cS] is included in the source list, we should filter out lib/X.c
Shih-wei Liao139a1062013-01-26 11:29:30 -0800227# in the result source list (i.e., use the one optimized for the arch.) Otherwise
228# there'll be multiple definitions for one symbol.
229define filter-libcompiler-rt-common-source-files
Alexey Volkov99395062014-01-17 17:44:56 +0400230 $(filter-out $(patsubst lib/$(strip $(2))/%.S,lib/%.c,\
231 $(filter lib/$(strip $(2))/%.S,$(1))) \
232 $(patsubst lib/$(strip $(2))/%.c,lib/%.c,\
233 $(filter lib/$(strip $(2))/%.c,$(1))),$(1))
Shih-wei Liao139a1062013-01-26 11:29:30 -0800234endef
235
Shih-wei Liaoece62642013-02-07 07:49:51 -0800236define get-libcompiler-rt-arm-common-source-files
Shih-wei Liao139a1062013-01-26 11:29:30 -0800237 $(call filter-libcompiler-rt-common-source-files,
Shih-wei Liaoc8f55192013-02-07 22:00:08 -0800238 $(libcompiler_rt_common_SRC_FILES) \
Shih-wei Liaoece62642013-02-07 07:49:51 -0800239 $(libcompiler_rt_arm_SRC_FILES), arm)
240endef
241
242# $(1): common runtime list
243#
244# Add ARM runtimes implemented in VFP
245define add-libcompiler-rt-arm-vfp-source-files
246 $(filter-out $(addprefix lib/,adddf3.c addsf3.c comparedf2.c comparesf2.c \
247 arm/comparesf2.S divdf3.c divsf3.c extendsfdf2.c \
248 fixdfsi.c fixsfsi.c fixunsdfsi.c fixunssfsi.c \
249 floatsidf.c floatsisf.c floatunsidf.c floatunsisf.c \
250 muldf3.c mulsf3.c negdf2.c negsf2.c subdf3.c \
251 subsf3.c truncdfsf2.c),$(1)) lib/arm/vfp_alias.S
252endef
253
254define get-libcompiler-rt-arm-source-files
255 $(if $(findstring $(ARCH_ARM_HAVE_VFP),true),
256 $(call add-libcompiler-rt-arm-vfp-source-files,
257 $(call get-libcompiler-rt-arm-common-source-files)),
258 $(call get-libcompiler-rt-arm-common-source-files))
Shih-wei Liao139a1062013-01-26 11:29:30 -0800259endef
260
Tim Murray6731c552014-03-10 11:10:47 -0700261define get-libcompiler-rt-arm64-source-files
262 $(call filter-libcompiler-rt-common-source-files,
263 $(libcompiler_rt_common_SRC_FILES) \
264 $(libcompiler_rt_arm64_SRC_FILES),arm64)
265endef
266
Shih-wei Liao139a1062013-01-26 11:29:30 -0800267define get-libcompiler-rt-mips-source-files
268 $(call filter-libcompiler-rt-common-source-files,
Shih-wei Liaoc8f55192013-02-07 22:00:08 -0800269 $(libcompiler_rt_common_SRC_FILES) \
Shih-wei Liao139a1062013-01-26 11:29:30 -0800270 $(libcompiler_rt_mips_SRC_FILES),mips)
271endef
272
273define get-libcompiler-rt-x86-source-files
274 $(call filter-libcompiler-rt-common-source-files,
Shih-wei Liaoc8f55192013-02-07 22:00:08 -0800275 $(libcompiler_rt_common_SRC_FILES) \
Shih-wei Liao139a1062013-01-26 11:29:30 -0800276 $(libcompiler_rt_x86_SRC_FILES),i386)
277endef
278
Alexey Volkov99395062014-01-17 17:44:56 +0400279define get-libcompiler-rt-x86_64-source-files
280 $(call filter-libcompiler-rt-common-source-files,
281 $(libcompiler_rt_common_SRC_FILES) \
282 $(libcompiler_rt_x86_64_SRC_FILES),x86_64)
283endef
284
Evgeniy Stepanovdc3865b2012-03-13 15:38:23 +0400285#=====================================================================
Shih-wei Liao7f489a32013-02-07 03:34:40 -0800286# Device Static Library: libcompiler_rt-extras
Evgeniy Stepanovdc3865b2012-03-13 15:38:23 +0400287#=====================================================================
288
Evgeniy Stepanovdc3865b2012-03-13 15:38:23 +0400289include $(CLEAR_VARS)
290
Shih-wei Liao7f489a32013-02-07 03:34:40 -0800291LOCAL_MODULE := libcompiler_rt-extras
Evgeniy Stepanovdc3865b2012-03-13 15:38:23 +0400292LOCAL_MODULE_TAGS := optional
293LOCAL_MODULE_CLASS := STATIC_LIBRARIES
294LOCAL_CLANG := true
Shih-wei Liao139a1062013-01-26 11:29:30 -0800295LOCAL_SRC_FILES := $(libcompiler_rt_extras_SRC_FILES)
Stephen Hines97ac43c2013-01-18 17:46:14 -0800296LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Evgeniy Stepanovdc3865b2012-03-13 15:38:23 +0400297
Evgeniy Stepanovdc3865b2012-03-13 15:38:23 +0400298include $(BUILD_STATIC_LIBRARY)
299
Colin Cross47ca89c2014-03-14 20:12:30 -0700300# Don't build compiler-rt without clang
301ifneq ($(WITHOUT_TARGET_CLANG), true)
302
Shih-wei Liao139a1062013-01-26 11:29:30 -0800303#=====================================================================
Shih-wei Liao7f489a32013-02-07 03:34:40 -0800304# Device Static Library: libcompiler_rt
Shih-wei Liao139a1062013-01-26 11:29:30 -0800305#=====================================================================
Colin Cross75d873d2014-02-04 16:24:23 -0800306
307include $(CLEAR_VARS)
308
Colin Cross75d873d2014-02-04 16:24:23 -0800309ifeq ($(TARGET_ARCH),mips64)
310$(warning TODOMips64: Enable compiler-rt build)
311endif
312
313LOCAL_MODULE := libcompiler_rt
314LOCAL_CFLAGS_arm += -D__ARM_EABI__
315LOCAL_ASFLAGS := -integrated-as
316LOCAL_CLANG := true
317LOCAL_SRC_FILES_arm := $(call get-libcompiler-rt-source-files,arm)
Tim Murray6731c552014-03-10 11:10:47 -0700318LOCAL_SRC_FILES_arm64 := $(call get-libcompiler-rt-source-files,arm64)
Colin Cross75d873d2014-02-04 16:24:23 -0800319LOCAL_SRC_FILES_mips := $(call get-libcompiler-rt-source-files,mips)
320LOCAL_SRC_FILES_x86 := $(call get-libcompiler-rt-source-files,x86)
321LOCAL_SRC_FILES_x86_64 := $(call get-libcompiler-rt-source-files,x86_64)
Tim Murray6731c552014-03-10 11:10:47 -0700322LOCAL_MODULE_TARGET_ARCH := arm arm64 mips x86 x86_64
Colin Cross75d873d2014-02-04 16:24:23 -0800323LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
324
325include $(BUILD_STATIC_LIBRARY)
326
Shih-wei Liaofba76912013-01-27 00:56:26 -0800327#=====================================================================
Dan Albert95b6e9a2014-05-01 17:40:29 -0700328# Host Static Library: libcompiler_rt
329#=====================================================================
330
331include $(CLEAR_VARS)
332
333LOCAL_MODULE := libcompiler_rt
334LOCAL_ASFLAGS := -integrated-as
335LOCAL_CLANG := true
336LOCAL_SRC_FILES := $(call get-libcompiler-rt-source-files,x86_64)
337LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
338
339include $(BUILD_HOST_STATIC_LIBRARY)
340
341#=====================================================================
Dmitriy Ivanovba9a7b32014-03-10 18:00:09 -0700342# Device Static Library: libprofile_rt
343#=====================================================================
344
345include $(CLEAR_VARS)
346
347LOCAL_MODULE = libprofile_rt
348LOCAL_SRC_FILES = lib/profile/GCDAProfiling.c
349
350include $(BUILD_STATIC_LIBRARY)
351
352#=====================================================================
Shih-wei Liaofba76912013-01-27 00:56:26 -0800353# Device Shared Library: libcompiler_rt
354#=====================================================================
Serban Constantinescue3c30bf2013-10-20 15:36:30 +0100355
Colin Cross75d873d2014-02-04 16:24:23 -0800356include $(CLEAR_VARS)
357
358LOCAL_MODULE := libcompiler_rt
359LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
360LOCAL_WHOLE_STATIC_LIBRARIES := libcompiler_rt
Tim Murray6731c552014-03-10 11:10:47 -0700361LOCAL_MODULE_TARGET_ARCH := arm arm64 mips x86 x86_64
Colin Cross75d873d2014-02-04 16:24:23 -0800362
363include $(BUILD_SHARED_LIBRARY)
Shih-wei Liaofba76912013-01-27 00:56:26 -0800364
Shih-wei Liao139a1062013-01-26 11:29:30 -0800365# Build ASan
366include $(LOCAL_PATH)/lib/asan/Android.mk
Tim Murray4b4f5572014-03-14 17:46:31 -0700367
Dan Albert95b6e9a2014-05-01 17:40:29 -0700368#=====================================================================
369# Host Shared Library: libcompiler_rt
370#=====================================================================
371
372include $(CLEAR_VARS)
373
374LOCAL_MODULE := libcompiler_rt
375LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
376LOCAL_WHOLE_STATIC_LIBRARIES := libcompiler_rt
377LOCAL_CPPFLAGS := -nostdinc++
378LOCAL_LDFLAGS := -nodefaultlibs
379LOCAL_LDLIBS := -lc -lm
380
381include $(BUILD_HOST_SHARED_LIBRARY)
382
Colin Cross47ca89c2014-03-14 20:12:30 -0700383endif
Stephen Hines30694612014-05-14 00:00:32 -0700384
385endif # TARGET_BUILD_APPS only