aboutsummaryrefslogtreecommitdiff
path: root/Android.mk
blob: ac8a8ee79dfc8cd122c5e220f35e393d5396984d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
#
# Copyright (C) 2012 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#

LOCAL_PATH := $(call my-dir)


# The following list contains platform-independent functionalities.
#
# Skip apple_versioning.c since it is unused.
# Skip atomic.c since it needs to be built separately according to the docs.
libcompiler_rt_common_SRC_FILES := \
  lib/builtins/absvdi2.c \
  lib/builtins/absvsi2.c \
  lib/builtins/absvti2.c \
  lib/builtins/adddf3.c \
  lib/builtins/addsf3.c \
  lib/builtins/addtf3.c \
  lib/builtins/addvdi3.c \
  lib/builtins/addvsi3.c \
  lib/builtins/addvti3.c \
  lib/builtins/ashldi3.c \
  lib/builtins/ashlti3.c \
  lib/builtins/ashrdi3.c \
  lib/builtins/ashrti3.c \
  lib/builtins/clear_cache.c \
  lib/builtins/clzdi2.c \
  lib/builtins/clzsi2.c \
  lib/builtins/clzti2.c \
  lib/builtins/cmpdi2.c \
  lib/builtins/cmpti2.c \
  lib/builtins/comparedf2.c \
  lib/builtins/comparesf2.c \
  lib/builtins/comparetf2.c \
  lib/builtins/ctzdi2.c \
  lib/builtins/ctzsi2.c \
  lib/builtins/ctzti2.c \
  lib/builtins/divdc3.c \
  lib/builtins/divdf3.c \
  lib/builtins/divdi3.c \
  lib/builtins/divmoddi4.c \
  lib/builtins/divmodsi4.c \
  lib/builtins/divsc3.c \
  lib/builtins/divsf3.c \
  lib/builtins/divsi3.c \
  lib/builtins/divtf3.c \
  lib/builtins/divti3.c \
  lib/builtins/divxc3.c \
  lib/builtins/eprintf.c \
  lib/builtins/extenddftf2.c \
  lib/builtins/extendhfsf2.c \
  lib/builtins/extendsfdf2.c \
  lib/builtins/extendsftf2.c \
  lib/builtins/ffsdi2.c \
  lib/builtins/ffsti2.c \
  lib/builtins/fixdfdi.c \
  lib/builtins/fixdfsi.c \
  lib/builtins/fixdfti.c \
  lib/builtins/fixsfdi.c \
  lib/builtins/fixsfsi.c \
  lib/builtins/fixsfti.c \
  lib/builtins/fixtfdi.c \
  lib/builtins/fixtfsi.c \
  lib/builtins/fixtfti.c \
  lib/builtins/fixunsdfdi.c \
  lib/builtins/fixunsdfsi.c \
  lib/builtins/fixunsdfti.c \
  lib/builtins/fixunssfdi.c \
  lib/builtins/fixunssfsi.c \
  lib/builtins/fixunssfti.c \
  lib/builtins/fixunstfdi.c \
  lib/builtins/fixunstfsi.c \
  lib/builtins/fixunstfti.c \
  lib/builtins/fixunsxfdi.c \
  lib/builtins/fixunsxfsi.c \
  lib/builtins/fixunsxfti.c \
  lib/builtins/fixxfdi.c \
  lib/builtins/fixxfti.c \
  lib/builtins/floatdidf.c \
  lib/builtins/floatdisf.c \
  lib/builtins/floatdixf.c \
  lib/builtins/floatsidf.c \
  lib/builtins/floatsisf.c \
  lib/builtins/floatsitf.c \
  lib/builtins/floattidf.c \
  lib/builtins/floattisf.c \
  lib/builtins/floattixf.c \
  lib/builtins/floatundidf.c \
  lib/builtins/floatundisf.c \
  lib/builtins/floatundixf.c \
  lib/builtins/floatunsidf.c \
  lib/builtins/floatunsisf.c \
  lib/builtins/floatunsitf.c \
  lib/builtins/floatuntidf.c \
  lib/builtins/floatuntisf.c \
  lib/builtins/floatuntixf.c \
  lib/builtins/gcc_personality_v0.c \
  lib/builtins/int_util.c \
  lib/builtins/lshrdi3.c \
  lib/builtins/lshrti3.c \
  lib/builtins/moddi3.c \
  lib/builtins/modsi3.c \
  lib/builtins/modti3.c \
  lib/builtins/muldc3.c \
  lib/builtins/muldf3.c \
  lib/builtins/muldi3.c \
  lib/builtins/mulodi4.c \
  lib/builtins/mulosi4.c \
  lib/builtins/muloti4.c \
  lib/builtins/mulsc3.c \
  lib/builtins/mulsf3.c \
  lib/builtins/multf3.c \
  lib/builtins/multi3.c \
  lib/builtins/mulvdi3.c \
  lib/builtins/mulvsi3.c \
  lib/builtins/mulvti3.c \
  lib/builtins/mulxc3.c \
  lib/builtins/negdf2.c \
  lib/builtins/negdi2.c \
  lib/builtins/negsf2.c \
  lib/builtins/negti2.c \
  lib/builtins/negvdi2.c \
  lib/builtins/negvsi2.c \
  lib/builtins/negvti2.c \
  lib/builtins/paritydi2.c \
  lib/builtins/paritysi2.c \
  lib/builtins/parityti2.c \
  lib/builtins/popcountdi2.c \
  lib/builtins/popcountsi2.c \
  lib/builtins/popcountti2.c \
  lib/builtins/powidf2.c \
  lib/builtins/powisf2.c \
  lib/builtins/powitf2.c \
  lib/builtins/powixf2.c \
  lib/builtins/subdf3.c \
  lib/builtins/subsf3.c \
  lib/builtins/subtf3.c \
  lib/builtins/subvdi3.c \
  lib/builtins/subvsi3.c \
  lib/builtins/subvti3.c \
  lib/builtins/trampoline_setup.c \
  lib/builtins/truncdfhf2.c \
  lib/builtins/truncdfsf2.c \
  lib/builtins/truncsfhf2.c \
  lib/builtins/trunctfdf2.c \
  lib/builtins/trunctfsf2.c \
  lib/builtins/ucmpdi2.c \
  lib/builtins/ucmpti2.c \
  lib/builtins/udivdi3.c \
  lib/builtins/udivmoddi4.c \
  lib/builtins/udivmodsi4.c \
  lib/builtins/udivmodti4.c \
  lib/builtins/udivsi3.c \
  lib/builtins/udivti3.c \
  lib/builtins/umoddi3.c \
  lib/builtins/umodsi3.c \
  lib/builtins/umodti3.c

# Only build enable_execute_stack.c on non-Windows hosts.
ifneq ($(HOST_OS),windows)
libcompiler_rt_common_SRC_FILES += \
  lib/builtins/enable_execute_stack.c
endif

# ARM-specific runtimes
libcompiler_rt_arm_SRC_FILES := \
  lib/builtins/arm/aeabi_dcmp.S \
  lib/builtins/arm/aeabi_div0.c \
  lib/builtins/arm/aeabi_fcmp.S \
  lib/builtins/arm/aeabi_idivmod.S \
  lib/builtins/arm/aeabi_ldivmod.S \
  lib/builtins/arm/aeabi_memcmp.S \
  lib/builtins/arm/aeabi_memcpy.S \
  lib/builtins/arm/aeabi_memmove.S \
  lib/builtins/arm/aeabi_memset.S \
  lib/builtins/arm/aeabi_uidivmod.S \
  lib/builtins/arm/aeabi_uldivmod.S \
  lib/builtins/arm/comparesf2.S \
  lib/builtins/arm/divmodsi4.S \
  lib/builtins/arm/divsi3.S \
  lib/builtins/arm/modsi3.S \
  lib/builtins/arm/udivmodsi4.S \
  lib/builtins/arm/udivsi3.S \
  lib/builtins/arm/umodsi3.S

# ARM64-specific runtimes
libcompiler_rt_arm64_SRC_FILES :=

# MIPS-specific runtimes
libcompiler_rt_mips_SRC_FILES := # nothing to add
libcompiler_rt_mips64_SRC_FILES := # nothing to add

# X86-specific runtimes
libcompiler_rt_x86_SRC_FILES := \
  lib/builtins/i386/ashldi3.S \
  lib/builtins/i386/ashrdi3.S \
  lib/builtins/i386/divdi3.S \
  lib/builtins/i386/floatdidf.S \
  lib/builtins/i386/floatdisf.S \
  lib/builtins/i386/floatdixf.S \
  lib/builtins/i386/floatundidf.S \
  lib/builtins/i386/floatundisf.S \
  lib/builtins/i386/floatundixf.S \
  lib/builtins/i386/lshrdi3.S \
  lib/builtins/i386/moddi3.S \
  lib/builtins/i386/muldi3.S \
  lib/builtins/i386/udivdi3.S \
  lib/builtins/i386/umoddi3.S

# X86_64-specific runtimes
libcompiler_rt_x86_64_SRC_FILES := \
  lib/builtins/x86_64/floatundixf.S \
  lib/builtins/x86_64/floatdisf.c \
  lib/builtins/x86_64/floatdidf.c \
  lib/builtins/x86_64/floatdixf.c \
  lib/builtins/x86_64/floatundisf.S \
  lib/builtins/x86_64/floatundidf.S

# The following list contains functions that are not available in libgcc.a, so
# we potentially need them when using a Clang-built component (e.g., -ftrapv
# with 64-bit integer multiplies. See http://llvm.org/bugs/show_bug.cgi?id=14469.)
libcompiler_rt_extras_SRC_FILES := \
  lib/builtins/mulodi4.c

# $(1): arch
define get-libcompiler-rt-source-files
  $(if $(findstring $(1),arm),$(call get-libcompiler-rt-arm-source-files),
      $(if $(findstring $(1),mips),$(call get-libcompiler-rt-mips-source-files),
          $(if $(findstring $(1),x86),$(call get-libcompiler-rt-x86-source-files),
             $(if $(findstring $(1),x86_64),$(call get-libcompiler-rt-x86_64-source-files),
                 $(if $(findstring $(1),x32),$(call get-libcompiler-rt-x86-source-files),
                    $(if $(findstring $(1),arm64),$(call get-libcompiler-rt-arm64-source-files),
                       $(if $(findstring $(1),mips64),$(call get-libcompiler-rt-mips64-source-files),
  $(error Unsupported ARCH $(1)))))))))
endef

# $(1): source list
# $(2): arch
#
# If lib/builtins/<arch>/X.[cS] is included in the source list, we should filter out lib/builtins/X.c
# in the result source list (i.e., use the one optimized for the arch.) Otherwise
# there'll be multiple definitions for one symbol.
define filter-libcompiler-rt-common-source-files
  $(filter-out $(patsubst lib/builtins/$(strip $(2))/%.S,lib/builtins/%.c,\
                          $(filter lib/builtins/$(strip $(2))/%.S,$(1))) \
               $(patsubst lib/builtins/$(strip $(2))/%.c,lib/builtins/%.c,\
                          $(filter lib/builtins/$(strip $(2))/%.c,$(1))),$(1))
endef

define get-libcompiler-rt-arm-common-source-files
  $(call filter-libcompiler-rt-common-source-files,
      $(libcompiler_rt_common_SRC_FILES) \
      $(libcompiler_rt_arm_SRC_FILES), arm)
endef

# $(1): common runtime list
#
# Add ARM runtimes implemented in VFP
define add-libcompiler-rt-arm-vfp-source-files
  $(filter-out $(addprefix lib/builtins/,adddf3.c addsf3.c comparedf2.c comparesf2.c         \
                                         arm/comparesf2.S divdf3.c divsf3.c extendsfdf2.c    \
                                         fixdfsi.c fixsfsi.c fixunsdfsi.c fixunssfsi.c       \
                                         floatsidf.c floatsisf.c floatunsidf.c floatunsisf.c \
                                         muldf3.c mulsf3.c negdf2.c negsf2.c subdf3.c        \
                                         subsf3.c truncdfsf2.c),$(1)) lib/builtins/arm/vfp_alias.S
endef

define get-libcompiler-rt-arm-source-files
  $(if $(findstring $(ARCH_ARM_HAVE_VFP),true),
      $(call add-libcompiler-rt-arm-vfp-source-files,
          $(call get-libcompiler-rt-arm-common-source-files)),
      $(call get-libcompiler-rt-arm-common-source-files))
endef

define get-libcompiler-rt-arm64-source-files
  $(call filter-libcompiler-rt-common-source-files,
      $(libcompiler_rt_common_SRC_FILES) \
      $(libcompiler_rt_arm64_SRC_FILES),arm64)
endef

define get-libcompiler-rt-mips-source-files
  $(call filter-libcompiler-rt-common-source-files,
      $(libcompiler_rt_common_SRC_FILES) \
      $(libcompiler_rt_mips_SRC_FILES),mips)
endef

define get-libcompiler-rt-mips64-source-files
  $(call filter-libcompiler-rt-common-source-files,
      $(libcompiler_rt_common_SRC_FILES) \
      $(libcompiler_rt_mips64_SRC_FILES),mips64)
endef

define get-libcompiler-rt-x86-source-files
  $(call filter-libcompiler-rt-common-source-files,
      $(libcompiler_rt_common_SRC_FILES) \
      $(libcompiler_rt_x86_SRC_FILES),i386)
endef

define get-libcompiler-rt-x86_64-source-files
  $(call filter-libcompiler-rt-common-source-files,
      $(libcompiler_rt_common_SRC_FILES) \
      $(libcompiler_rt_x86_64_SRC_FILES),x86_64)
endef

#=====================================================================
# Device Static Library: libcompiler_rt-extras
#=====================================================================

include $(CLEAR_VARS)

LOCAL_MODULE := libcompiler_rt-extras
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_CLANG := true
LOCAL_SRC_FILES := $(libcompiler_rt_extras_SRC_FILES)
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_ADDRESS_SANITIZER := false
LOCAL_CXX_STL := none

include $(BUILD_STATIC_LIBRARY)

#=====================================================================
# Host Static Library: libcompiler_rt-extras
#=====================================================================

include $(CLEAR_VARS)

LOCAL_MODULE := libcompiler_rt-extras
LOCAL_CLANG := true
LOCAL_SRC_FILES := $(libcompiler_rt_extras_SRC_FILES)
LOCAL_ADDRESS_SANITIZER := false
LOCAL_MULTILIB := both
LOCAL_CXX_STL := none

include $(BUILD_HOST_STATIC_LIBRARY)

# Don't build compiler-rt without clang
ifneq ($(WITHOUT_TARGET_CLANG), true)

#=====================================================================
# Device Static Library: libcompiler_rt
#=====================================================================

include $(CLEAR_VARS)

LOCAL_MODULE := libcompiler_rt
LOCAL_CFLAGS_arm += -D__ARM_EABI__
LOCAL_CFLAGS_mips64 += -DCRT_HAS_128BIT -DCRT_LDBL_128BIT
LOCAL_ASFLAGS := -integrated-as
LOCAL_CLANG := true
LOCAL_SRC_FILES_arm := $(call get-libcompiler-rt-source-files,arm)
LOCAL_SRC_FILES_arm64 := $(call get-libcompiler-rt-source-files,arm64)
LOCAL_SRC_FILES_mips := $(call get-libcompiler-rt-source-files,mips)
LOCAL_SRC_FILES_mips64 := $(call get-libcompiler-rt-source-files,mips64)
LOCAL_SRC_FILES_x86 := $(call get-libcompiler-rt-source-files,x86)
LOCAL_SRC_FILES_x86_64 := $(call get-libcompiler-rt-source-files,x86_64)
LOCAL_SRC_FILES_x86_64 += lib/builtins/ppc/floatditf.c
LOCAL_MODULE_TARGET_ARCH := arm arm64 mips mips64 x86 x86_64
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_ADDRESS_SANITIZER := false
LOCAL_CXX_STL := none

include $(BUILD_STATIC_LIBRARY)

#=====================================================================
# Host Static Library: libcompiler_rt
#=====================================================================

include $(CLEAR_VARS)

LOCAL_MODULE := libcompiler_rt
LOCAL_ASFLAGS := -integrated-as
LOCAL_CLANG := true
LOCAL_SRC_FILES := $(call get-libcompiler-rt-source-files,x86_64)
LOCAL_ADDRESS_SANITIZER := false
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_MULTILIB := both
LOCAL_CXX_STL := none

include $(BUILD_HOST_STATIC_LIBRARY)

#=====================================================================
# Host Static Library: libprofile_rt
#=====================================================================

include $(CLEAR_VARS)

LOCAL_MODULE = libprofile_rt
LOCAL_SRC_FILES = lib/profile/GCDAProfiling.c
LOCAL_ADDRESS_SANITIZER := false
LOCAL_MULTILIB := both
LOCAL_CXX_STL := none

include $(BUILD_HOST_STATIC_LIBRARY)

#=====================================================================
# Device Static Library: libprofile_rt
#=====================================================================

include $(CLEAR_VARS)

LOCAL_MODULE = libprofile_rt
LOCAL_CLANG := true
LOCAL_SRC_FILES = lib/profile/GCDAProfiling.c
LOCAL_ADDRESS_SANITIZER := false
LOCAL_MULTILIB := both
LOCAL_CXX_STL := none

include $(BUILD_STATIC_LIBRARY)

#=====================================================================
# Device Shared Library: libcompiler_rt
#=====================================================================

include $(CLEAR_VARS)

LOCAL_MODULE := libcompiler_rt
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_WHOLE_STATIC_LIBRARIES := libcompiler_rt
LOCAL_SHARED_LIBRARIES := libdl
LOCAL_STATIC_LIBRARIES_arm := libunwind_llvm
LOCAL_STATIC_LIBRARIES_arm64 := libunwindbacktrace
LOCAL_STATIC_LIBRARIES_mips := libunwindbacktrace
LOCAL_STATIC_LIBRARIES_mips64 := libunwindbacktrace
LOCAL_STATIC_LIBRARIES_x86 := libunwindbacktrace
LOCAL_STATIC_LIBRARIES_x86_64 := libunwindbacktrace
LOCAL_MODULE_TARGET_ARCH := arm arm64 mips mips64 x86 x86_64
LOCAL_ADDRESS_SANITIZER := false
LOCAL_CXX_STL := none
LOCAL_NO_LIBGCC := true

include $(BUILD_SHARED_LIBRARY)

#=====================================================================
# Host Shared Library: libcompiler_rt
#=====================================================================

include $(CLEAR_VARS)

LOCAL_MODULE := libcompiler_rt
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_WHOLE_STATIC_LIBRARIES := libcompiler_rt
ifneq ($(HOST_OS),darwin)
LOCAL_STATIC_LIBRARIES := libunwindbacktrace
endif
LOCAL_CPPFLAGS := -nostdinc++
ifneq ($(HOST_OS),windows)
LOCAL_LDFLAGS := -nodefaultlibs
LOCAL_LDLIBS := -lpthread -lc -lm
endif
LOCAL_MULTILIB := both
LOCAL_ADDRESS_SANITIZER := false
LOCAL_CXX_STL := none
LOCAL_NO_LIBGCC := true

include $(BUILD_HOST_SHARED_LIBRARY)

# Build asan, lsan, etc.
include $(call all-makefiles-under,$(LOCAL_PATH)/lib)

endif