Android.mk revision 2d1fdb26e458c4ddc04155c1d421bced3ba90cd0
1#
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)
19
20ifeq (,$(TARGET_BUILD_APPS))
21
22# The following list contains platform-independent functionalities.
23#
24# Skip apple_versioning.c since it is unused.
25# Skip atomic.c since it needs to be built separately according to the docs.
26# Skip gcc_personality_v0.c since it depends on libunwind.
27libcompiler_rt_common_SRC_FILES := \
28  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 \
48  lib/builtins/ctzdi2.c \
49  lib/builtins/ctzsi2.c \
50  lib/builtins/ctzti2.c \
51  lib/builtins/divdc3.c \
52  lib/builtins/divdf3.c \
53  lib/builtins/divdi3.c \
54  lib/builtins/divmoddi4.c \
55  lib/builtins/divmodsi4.c \
56  lib/builtins/divsc3.c \
57  lib/builtins/divsf3.c \
58  lib/builtins/divsi3.c \
59  lib/builtins/divti3.c \
60  lib/builtins/divxc3.c \
61  lib/builtins/enable_execute_stack.c \
62  lib/builtins/eprintf.c \
63  lib/builtins/extendsfdf2.c \
64  lib/builtins/ffsdi2.c \
65  lib/builtins/ffsti2.c \
66  lib/builtins/fixdfdi.c \
67  lib/builtins/fixdfsi.c \
68  lib/builtins/fixdfti.c \
69  lib/builtins/fixsfdi.c \
70  lib/builtins/fixsfsi.c \
71  lib/builtins/fixsfti.c \
72  lib/builtins/fixunsdfdi.c \
73  lib/builtins/fixunsdfsi.c \
74  lib/builtins/fixunsdfti.c \
75  lib/builtins/fixunssfdi.c \
76  lib/builtins/fixunssfsi.c \
77  lib/builtins/fixunssfti.c \
78  lib/builtins/fixunsxfdi.c \
79  lib/builtins/fixunsxfsi.c \
80  lib/builtins/fixunsxfti.c \
81  lib/builtins/fixxfdi.c \
82  lib/builtins/fixxfti.c \
83  lib/builtins/floatdidf.c \
84  lib/builtins/floatdisf.c \
85  lib/builtins/floatdixf.c \
86  lib/builtins/floatsidf.c \
87  lib/builtins/floatsisf.c \
88  lib/builtins/floattidf.c \
89  lib/builtins/floattisf.c \
90  lib/builtins/floattixf.c \
91  lib/builtins/floatundidf.c \
92  lib/builtins/floatundisf.c \
93  lib/builtins/floatundixf.c \
94  lib/builtins/floatunsidf.c \
95  lib/builtins/floatunsisf.c \
96  lib/builtins/floatuntidf.c \
97  lib/builtins/floatuntisf.c \
98  lib/builtins/floatuntixf.c \
99  lib/builtins/int_util.c \
100  lib/builtins/lshrdi3.c \
101  lib/builtins/lshrti3.c \
102  lib/builtins/moddi3.c \
103  lib/builtins/modsi3.c \
104  lib/builtins/modti3.c \
105  lib/builtins/muldc3.c \
106  lib/builtins/muldf3.c \
107  lib/builtins/muldi3.c \
108  lib/builtins/mulodi4.c \
109  lib/builtins/mulosi4.c \
110  lib/builtins/muloti4.c \
111  lib/builtins/mulsc3.c \
112  lib/builtins/mulsf3.c \
113  lib/builtins/multi3.c \
114  lib/builtins/mulvdi3.c \
115  lib/builtins/mulvsi3.c \
116  lib/builtins/mulvti3.c \
117  lib/builtins/mulxc3.c \
118  lib/builtins/negdf2.c \
119  lib/builtins/negdi2.c \
120  lib/builtins/negsf2.c \
121  lib/builtins/negti2.c \
122  lib/builtins/negvdi2.c \
123  lib/builtins/negvsi2.c \
124  lib/builtins/negvti2.c \
125  lib/builtins/paritydi2.c \
126  lib/builtins/paritysi2.c \
127  lib/builtins/parityti2.c \
128  lib/builtins/popcountdi2.c \
129  lib/builtins/popcountsi2.c \
130  lib/builtins/popcountti2.c \
131  lib/builtins/powidf2.c \
132  lib/builtins/powisf2.c \
133  lib/builtins/powitf2.c \
134  lib/builtins/powixf2.c \
135  lib/builtins/subdf3.c \
136  lib/builtins/subsf3.c \
137  lib/builtins/subvdi3.c \
138  lib/builtins/subvsi3.c \
139  lib/builtins/subvti3.c \
140  lib/builtins/trampoline_setup.c \
141  lib/builtins/truncdfsf2.c \
142  lib/builtins/ucmpdi2.c \
143  lib/builtins/ucmpti2.c \
144  lib/builtins/udivdi3.c \
145  lib/builtins/udivmoddi4.c \
146  lib/builtins/udivmodsi4.c \
147  lib/builtins/udivmodti4.c \
148  lib/builtins/udivsi3.c \
149  lib/builtins/udivti3.c \
150  lib/builtins/umoddi3.c \
151  lib/builtins/umodsi3.c \
152  lib/builtins/umodti3.c
153
154# ARM-specific runtimes
155libcompiler_rt_arm_SRC_FILES := \
156  lib/builtins/arm/aeabi_dcmp.S \
157  lib/builtins/arm/aeabi_fcmp.S \
158  lib/builtins/arm/aeabi_idivmod.S \
159  lib/builtins/arm/aeabi_ldivmod.S \
160  lib/builtins/arm/aeabi_memcmp.S \
161  lib/builtins/arm/aeabi_memcpy.S \
162  lib/builtins/arm/aeabi_memmove.S \
163  lib/builtins/arm/aeabi_memset.S \
164  lib/builtins/arm/aeabi_uidivmod.S \
165  lib/builtins/arm/aeabi_uldivmod.S \
166  lib/builtins/arm/comparesf2.S \
167  lib/builtins/arm/divmodsi4.S \
168  lib/builtins/arm/divsi3.S \
169  lib/builtins/arm/modsi3.S \
170  lib/builtins/arm/udivmodsi4.S \
171  lib/builtins/arm/udivsi3.S \
172  lib/builtins/arm/umodsi3.S
173
174# ARM64-specific runtimes
175libcompiler_rt_arm64_SRC_FILES :=
176
177# MIPS-specific runtimes
178libcompiler_rt_mips_SRC_FILES := # nothing to add
179
180# X86-specific runtimes
181libcompiler_rt_x86_SRC_FILES := \
182  lib/builtins/i386/ashldi3.S \
183  lib/builtins/i386/ashrdi3.S \
184  lib/builtins/i386/divdi3.S \
185  lib/builtins/i386/floatdidf.S \
186  lib/builtins/i386/floatdisf.S \
187  lib/builtins/i386/floatdixf.S \
188  lib/builtins/i386/floatundidf.S \
189  lib/builtins/i386/floatundisf.S \
190  lib/builtins/i386/floatundixf.S \
191  lib/builtins/i386/lshrdi3.S \
192  lib/builtins/i386/moddi3.S \
193  lib/builtins/i386/muldi3.S \
194  lib/builtins/i386/udivdi3.S \
195  lib/builtins/i386/umoddi3.S
196
197# X86_64-specific runtimes
198libcompiler_rt_x86_64_SRC_FILES := \
199  lib/builtins/x86_64/floatundixf.S \
200  lib/builtins/x86_64/floatdisf.c \
201  lib/builtins/x86_64/floatdidf.c \
202  lib/builtins/x86_64/floatdixf.c \
203  lib/builtins/x86_64/floatundisf.S \
204  lib/builtins/x86_64/floatundidf.S
205
206# 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/builtins/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),
217             $(if $(findstring $(1),x86_64),$(call get-libcompiler-rt-x86_64-source-files),
218                 $(if $(findstring $(1),x32),$(call get-libcompiler-rt-x86-source-files),
219                    $(if $(findstring $(1),arm64),$(call get-libcompiler-rt-arm64-source-files),
220  $(error Unsupported ARCH $(1))))))))
221endef
222
223# $(1): source list
224# $(2): arch
225#
226# If lib/builtins/<arch>/X.[cS] is included in the source list, we should filter out lib/builtins/X.c
227# 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
230  $(filter-out $(patsubst lib/builtins/$(strip $(2))/%.S,lib/builtins/%.c,\
231                          $(filter lib/builtins/$(strip $(2))/%.S,$(1))) \
232               $(patsubst lib/builtins/$(strip $(2))/%.c,lib/builtins/%.c,\
233                          $(filter lib/builtins/$(strip $(2))/%.c,$(1))),$(1))
234endef
235
236define get-libcompiler-rt-arm-common-source-files
237  $(call filter-libcompiler-rt-common-source-files,
238      $(libcompiler_rt_common_SRC_FILES) \
239      $(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/builtins/,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/builtins/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))
259endef
260
261define 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
267define get-libcompiler-rt-mips-source-files
268  $(call filter-libcompiler-rt-common-source-files,
269      $(libcompiler_rt_common_SRC_FILES) \
270      $(libcompiler_rt_mips_SRC_FILES),mips)
271endef
272
273define get-libcompiler-rt-x86-source-files
274  $(call filter-libcompiler-rt-common-source-files,
275      $(libcompiler_rt_common_SRC_FILES) \
276      $(libcompiler_rt_x86_SRC_FILES),i386)
277endef
278
279define 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
285#=====================================================================
286# Device Static Library: libcompiler_rt-extras
287#=====================================================================
288
289include $(CLEAR_VARS)
290
291LOCAL_MODULE := libcompiler_rt-extras
292LOCAL_MODULE_TAGS := optional
293LOCAL_MODULE_CLASS := STATIC_LIBRARIES
294LOCAL_CLANG := true
295LOCAL_SRC_FILES := $(libcompiler_rt_extras_SRC_FILES)
296LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
297
298include $(BUILD_STATIC_LIBRARY)
299
300# Don't build compiler-rt without clang
301ifneq ($(WITHOUT_TARGET_CLANG), true)
302
303#=====================================================================
304# Device Static Library: libcompiler_rt
305#=====================================================================
306
307include $(CLEAR_VARS)
308
309ifeq ($(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)
318LOCAL_SRC_FILES_arm64 := $(call get-libcompiler-rt-source-files,arm64)
319LOCAL_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)
322LOCAL_MODULE_TARGET_ARCH := arm arm64 mips x86 x86_64
323LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
324
325include $(BUILD_STATIC_LIBRARY)
326
327#=====================================================================
328# 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#=====================================================================
342# 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#=====================================================================
353# Device Shared Library: libcompiler_rt
354#=====================================================================
355
356include $(CLEAR_VARS)
357
358LOCAL_MODULE := libcompiler_rt
359LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
360LOCAL_WHOLE_STATIC_LIBRARIES := libcompiler_rt
361LOCAL_MODULE_TARGET_ARCH := arm arm64 mips x86 x86_64
362
363include $(BUILD_SHARED_LIBRARY)
364
365# Build ASan
366include $(LOCAL_PATH)/lib/asan/Android.mk
367
368#=====================================================================
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
383endif
384
385endif # TARGET_BUILD_APPS only
386