Android.mk revision 139a106d12a5789561b3244bb34704eb618e4ffe
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
20# The following list contains platform-independent functionalities.
21#
22# Skip atomic.c since it needs to be built separately according to the docs.
23# Skip clear_cache.c since it redefines a system function on Android.
24libcompiler_rt_common_SRC_FILES := \
25  lib/absvdi2.c \
26  lib/absvsi2.c \
27  lib/absvti2.c \
28  lib/adddf3.c \
29  lib/addsf3.c \
30  lib/addvdi3.c \
31  lib/addvsi3.c \
32  lib/addvti3.c \
33  lib/apple_versioning.c \
34  lib/ashldi3.c \
35  lib/ashlti3.c \
36  lib/ashrdi3.c \
37  lib/ashrti3.c \
38  lib/clzdi2.c \
39  lib/clzsi2.c \
40  lib/clzti2.c \
41  lib/cmpdi2.c \
42  lib/cmpti2.c \
43  lib/comparedf2.c \
44  lib/comparesf2.c \
45  lib/ctzdi2.c \
46  lib/ctzsi2.c \
47  lib/ctzti2.c \
48  lib/divdc3.c \
49  lib/divdf3.c \
50  lib/divdi3.c \
51  lib/divmoddi4.c \
52  lib/divmodsi4.c \
53  lib/divsc3.c \
54  lib/divsf3.c \
55  lib/divsi3.c \
56  lib/divti3.c \
57  lib/divxc3.c \
58  lib/enable_execute_stack.c \
59  lib/eprintf.c \
60  lib/extendsfdf2.c \
61  lib/ffsdi2.c \
62  lib/ffsti2.c \
63  lib/fixdfdi.c \
64  lib/fixdfsi.c \
65  lib/fixdfti.c \
66  lib/fixsfdi.c \
67  lib/fixsfsi.c \
68  lib/fixsfti.c \
69  lib/fixunsdfdi.c \
70  lib/fixunsdfsi.c \
71  lib/fixunsdfti.c \
72  lib/fixunssfdi.c \
73  lib/fixunssfsi.c \
74  lib/fixunssfti.c \
75  lib/fixunsxfdi.c \
76  lib/fixunsxfsi.c \
77  lib/fixunsxfti.c \
78  lib/fixxfdi.c \
79  lib/fixxfti.c \
80  lib/floatdidf.c \
81  lib/floatdisf.c \
82  lib/floatdixf.c \
83  lib/floatsidf.c \
84  lib/floatsisf.c \
85  lib/floattidf.c \
86  lib/floattisf.c \
87  lib/floattixf.c \
88  lib/floatundidf.c \
89  lib/floatundisf.c \
90  lib/floatundixf.c \
91  lib/floatunsidf.c \
92  lib/floatunsisf.c \
93  lib/floatuntidf.c \
94  lib/floatuntisf.c \
95  lib/floatuntixf.c \
96  lib/gcc_personality_v0.c \
97  lib/int_util.c \
98  lib/lshrdi3.c \
99  lib/lshrti3.c \
100  lib/moddi3.c \
101  lib/modsi3.c \
102  lib/modti3.c \
103  lib/muldc3.c \
104  lib/muldf3.c \
105  lib/muldi3.c \
106  lib/mulosi4.c \
107  lib/muloti4.c \
108  lib/mulsc3.c \
109  lib/mulsf3.c \
110  lib/multi3.c \
111  lib/mulvdi3.c \
112  lib/mulvsi3.c \
113  lib/mulvti3.c \
114  lib/mulxc3.c \
115  lib/negdf2.c \
116  lib/negdi2.c \
117  lib/negsf2.c \
118  lib/negti2.c \
119  lib/negvdi2.c \
120  lib/negvsi2.c \
121  lib/negvti2.c \
122  lib/paritydi2.c \
123  lib/paritysi2.c \
124  lib/parityti2.c \
125  lib/popcountdi2.c \
126  lib/popcountsi2.c \
127  lib/popcountti2.c \
128  lib/powidf2.c \
129  lib/powisf2.c \
130  lib/powitf2.c \
131  lib/powixf2.c \
132  lib/subdf3.c \
133  lib/subsf3.c \
134  lib/subvdi3.c \
135  lib/subvsi3.c \
136  lib/subvti3.c \
137  lib/trampoline_setup.c \
138  lib/truncdfsf2.c \
139  lib/ucmpdi2.c \
140  lib/ucmpti2.c \
141  lib/udivdi3.c \
142  lib/udivmoddi4.c \
143  lib/udivmodsi4.c \
144  lib/udivmodti4.c \
145  lib/udivsi3.c \
146  lib/udivti3.c \
147  lib/umoddi3.c \
148  lib/umodsi3.c \
149  lib/umodti3.c
150
151# ARM-specific runtimes
152libcompiler_rt_arm_SRC_FILES := \
153  lib/arm/adddf3vfp.S \
154  lib/arm/addsf3vfp.S \
155  lib/arm/divdf3vfp.S \
156  lib/arm/divsf3vfp.S \
157  lib/arm/eqdf2vfp.S \
158  lib/arm/eqsf2vfp.S \
159  lib/arm/extendsfdf2vfp.S \
160  lib/arm/fixdfsivfp.S \
161  lib/arm/fixsfsivfp.S \
162  lib/arm/fixunsdfsivfp.S \
163  lib/arm/fixunssfsivfp.S \
164  lib/arm/floatsidfvfp.S \
165  lib/arm/floatsisfvfp.S \
166  lib/arm/floatunssidfvfp.S \
167  lib/arm/floatunssisfvfp.S \
168  lib/arm/gedf2vfp.S \
169  lib/arm/gesf2vfp.S \
170  lib/arm/gtdf2vfp.S \
171  lib/arm/gtsf2vfp.S \
172  lib/arm/ledf2vfp.S \
173  lib/arm/lesf2vfp.S \
174  lib/arm/ltdf2vfp.S \
175  lib/arm/ltsf2vfp.S \
176  lib/arm/muldf3vfp.S \
177  lib/arm/mulsf3vfp.S \
178  lib/arm/nedf2vfp.S \
179  lib/arm/negdf2vfp.S \
180  lib/arm/negsf2vfp.S \
181  lib/arm/nesf2vfp.S \
182  lib/arm/subdf3vfp.S \
183  lib/arm/subsf3vfp.S \
184  lib/arm/truncdfsf2vfp.S \
185  lib/arm/unorddf2vfp.S \
186  lib/arm/unordsf2vfp.S \
187  lib/arm/aeabi_ldivmod.S \
188  lib/arm/aeabi_uldivmod.S
189
190# MIPS-specific runtimes
191libcompiler_rt_mips_SRC_FILES := # nothing to add
192
193# X86-specific runtimes
194#
195# We don't support x86-64 right now
196libcompiler_rt_x86_SRC_FILES := \
197  lib/i386/ashldi3.S \
198  lib/i386/ashrdi3.S \
199  lib/i386/divdi3.S \
200  lib/i386/floatdidf.S \
201  lib/i386/floatdisf.S \
202  lib/i386/floatdixf.S \
203  lib/i386/floatundidf.S \
204  lib/i386/floatundisf.S \
205  lib/i386/floatundixf.S \
206  lib/i386/lshrdi3.S \
207  lib/i386/moddi3.S \
208  lib/i386/muldi3.S \
209  lib/i386/udivdi3.S \
210  lib/i386/umoddi3.S
211
212# The following list contains functions that are not available in libgcc.a, so
213# we potentially need them when using a Clang-built component (e.g., -ftrapv
214# with 64-bit integer multiplies. See http://llvm.org/bugs/show_bug.cgi?id=14469.)
215libcompiler_rt_extras_SRC_FILES := \
216  lib/mulodi4.c
217
218# $(1): arch
219define get-libcompiler-rt-source-files
220  $(if $(findstring $(1),arm),$(call get-libcompiler-rt-arm-source-files),
221      $(if $(findstring $(1),mips),$(call get-libcompiler-rt-mips-source-files),
222          $(if $(findstring $(1),x86),$(call get-libcompiler-rt-x86-source-files),
223  $(error Unsupported ARCH $(1)))))
224endef
225
226# $(1): source list
227# $(2): arch
228#
229# If lib/<arch>/X.S is included in the source list, we should filter out lib/X.c
230# 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
233  $(filter-out $(patsubst lib/$(2)/%.S,lib/%.c,$(filter %.S,$(1))),$(1))
234endef
235
236define get-libcompiler-rt-arm-source-files
237  $(call filter-libcompiler-rt-common-source-files,
238      $(libcompiler_rt_common_SRC_FILES)
239      $(libcompiler_rt_extras_SRC_FILES)
240      $(libcompiler_rt_arm_SRC_FILES),arm)
241endef
242
243define get-libcompiler-rt-mips-source-files
244  $(call filter-libcompiler-rt-common-source-files,
245      $(libcompiler_rt_common_SRC_FILES)
246      $(libcompiler_rt_extras_SRC_FILES)
247      $(libcompiler_rt_mips_SRC_FILES),mips)
248endef
249
250define get-libcompiler-rt-x86-source-files
251  $(call filter-libcompiler-rt-common-source-files,
252      $(libcompiler_rt_common_SRC_FILES)
253      $(libcompiler_rt_extras_SRC_FILES)
254      $(libcompiler_rt_x86_SRC_FILES),i386)
255endef
256
257# $(1): target or host
258# $(2): static or shared
259define build-libcompiler-rt
260  ifneq ($(1),target)
261    ifneq ($(1),host)
262      $$(error expected target or host for argument 1, received $(1))
263    endif
264  endif
265  ifneq ($(2),static)
266    ifneq ($(2),shared)
267      $$(error expected static or shared for argument 2, received $(2))
268    endif
269  endif
270
271  target_or_host := $(1)
272  static_or_shared := $(2)
273
274  arch :=
275  ifeq ($$(target_or_host),target)
276    arch := $(TARGET_ARCH)
277  else
278    arch := $(HOST_ARCH)
279  endif
280
281  include $(CLEAR_VARS)
282
283  LOCAL_MODULE := libcompiler-rt
284  LOCAL_MODULE_TAGS := optional
285
286  ifeq ($$(static_or_shared),static)
287    LOCAL_MODULE_CLASS := STATIC_LIBRARIES
288  else
289    LOCAL_MODULE_CLASS := SHARED_LIBRARIES
290  endif
291
292  # TODO: Fix -integrated-as
293  # LOCAL_CFLAGS := -integrated-as
294
295  # Add -D__ARM_EABI__ for ARM
296  ifeq ($$(arch),arm)
297    LOCAL_CFLAGS += -D__ARM_EABI__
298  endif
299
300  # Use Clang to compile libcompiler-rt
301  LOCAL_CLANG := true
302  LOCAL_SRC_FILES := $$(call get-libcompiler-rt-source-files,$$(arch))
303  LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
304
305  ifeq ($$(target_or_host),target)
306    ifeq ($$(static_or_shared),static)
307      include $(BUILD_STATIC_LIBRARY)
308    else
309      include $(BUILD_SHARED_LIBRARY)
310    endif
311  else
312    LOCAL_IS_HOST_MODULE := true
313    ifeq ($$(static_or_shared),static)
314      include $(BUILD_HOST_STATIC_LIBRARY)
315    else
316      include $(BUILD_HOST_SHARED_LIBRARY)
317    endif
318  endif
319endef
320
321#=====================================================================
322# Device Static Library: libcompiler-rt-extras
323#=====================================================================
324
325include $(CLEAR_VARS)
326
327LOCAL_MODULE := libcompiler-rt-extras
328LOCAL_MODULE_TAGS := optional
329LOCAL_MODULE_CLASS := STATIC_LIBRARIES
330LOCAL_CLANG := true
331LOCAL_SRC_FILES := $(libcompiler_rt_extras_SRC_FILES)
332LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
333
334include $(BUILD_STATIC_LIBRARY)
335
336#=====================================================================
337# Device Static Library: libcompiler-rt
338#=====================================================================
339$(eval $(call build-libcompiler-rt,target,static))
340
341# Build ASan
342include $(LOCAL_PATH)/lib/asan/Android.mk
343