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 21# The following list contains platform-independent functionalities. 22# 23# Skip apple_versioning.c since it is unused. 24# Skip atomic.c since it needs to be built separately according to the docs. 25# Skip gcc_personality_v0.c since it depends on libunwind. 26libcompiler_rt_common_SRC_FILES := \ 27 lib/builtins/absvdi2.c \ 28 lib/builtins/absvsi2.c \ 29 lib/builtins/absvti2.c \ 30 lib/builtins/adddf3.c \ 31 lib/builtins/addsf3.c \ 32 lib/builtins/addtf3.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/comparetf2.c \ 49 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/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/multf3.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/subtf3.c \ 139 lib/builtins/subvdi3.c \ 140 lib/builtins/subvsi3.c \ 141 lib/builtins/subvti3.c \ 142 lib/builtins/trampoline_setup.c \ 143 lib/builtins/truncdfsf2.c \ 144 lib/builtins/ucmpdi2.c \ 145 lib/builtins/ucmpti2.c \ 146 lib/builtins/udivdi3.c \ 147 lib/builtins/udivmoddi4.c \ 148 lib/builtins/udivmodsi4.c \ 149 lib/builtins/udivmodti4.c \ 150 lib/builtins/udivsi3.c \ 151 lib/builtins/udivti3.c \ 152 lib/builtins/umoddi3.c \ 153 lib/builtins/umodsi3.c \ 154 lib/builtins/umodti3.c 155 156# Only build enable_execute_stack.c on non-Windows hosts. 157ifneq ($(HOST_OS),windows) 158libcompiler_rt_common_SRC_FILES += \ 159 lib/builtins/enable_execute_stack.c 160endif 161 162# ARM-specific runtimes 163libcompiler_rt_arm_SRC_FILES := \ 164 lib/builtins/arm/aeabi_dcmp.S \ 165 lib/builtins/arm/aeabi_fcmp.S \ 166 lib/builtins/arm/aeabi_idivmod.S \ 167 lib/builtins/arm/aeabi_ldivmod.S \ 168 lib/builtins/arm/aeabi_memcmp.S \ 169 lib/builtins/arm/aeabi_memcpy.S \ 170 lib/builtins/arm/aeabi_memmove.S \ 171 lib/builtins/arm/aeabi_memset.S \ 172 lib/builtins/arm/aeabi_uidivmod.S \ 173 lib/builtins/arm/aeabi_uldivmod.S \ 174 lib/builtins/arm/comparesf2.S \ 175 lib/builtins/arm/divmodsi4.S \ 176 lib/builtins/arm/divsi3.S \ 177 lib/builtins/arm/modsi3.S \ 178 lib/builtins/arm/udivmodsi4.S \ 179 lib/builtins/arm/udivsi3.S \ 180 lib/builtins/arm/umodsi3.S 181 182# ARM64-specific runtimes 183libcompiler_rt_arm64_SRC_FILES := 184 185# MIPS-specific runtimes 186libcompiler_rt_mips_SRC_FILES := # nothing to add 187libcompiler_rt_mips64_SRC_FILES := # nothing to add 188 189# X86-specific runtimes 190libcompiler_rt_x86_SRC_FILES := \ 191 lib/builtins/i386/ashldi3.S \ 192 lib/builtins/i386/ashrdi3.S \ 193 lib/builtins/i386/divdi3.S \ 194 lib/builtins/i386/floatdidf.S \ 195 lib/builtins/i386/floatdisf.S \ 196 lib/builtins/i386/floatdixf.S \ 197 lib/builtins/i386/floatundidf.S \ 198 lib/builtins/i386/floatundisf.S \ 199 lib/builtins/i386/floatundixf.S \ 200 lib/builtins/i386/lshrdi3.S \ 201 lib/builtins/i386/moddi3.S \ 202 lib/builtins/i386/muldi3.S \ 203 lib/builtins/i386/udivdi3.S \ 204 lib/builtins/i386/umoddi3.S 205 206# X86_64-specific runtimes 207libcompiler_rt_x86_64_SRC_FILES := \ 208 lib/builtins/x86_64/floatundixf.S \ 209 lib/builtins/x86_64/floatdisf.c \ 210 lib/builtins/x86_64/floatdidf.c \ 211 lib/builtins/x86_64/floatdixf.c \ 212 lib/builtins/x86_64/floatundisf.S \ 213 lib/builtins/x86_64/floatundidf.S 214 215# The following list contains functions that are not available in libgcc.a, so 216# we potentially need them when using a Clang-built component (e.g., -ftrapv 217# with 64-bit integer multiplies. See http://llvm.org/bugs/show_bug.cgi?id=14469.) 218libcompiler_rt_extras_SRC_FILES := \ 219 lib/builtins/mulodi4.c 220 221# $(1): arch 222define get-libcompiler-rt-source-files 223 $(if $(findstring $(1),arm),$(call get-libcompiler-rt-arm-source-files), 224 $(if $(findstring $(1),mips),$(call get-libcompiler-rt-mips-source-files), 225 $(if $(findstring $(1),x86),$(call get-libcompiler-rt-x86-source-files), 226 $(if $(findstring $(1),x86_64),$(call get-libcompiler-rt-x86_64-source-files), 227 $(if $(findstring $(1),x32),$(call get-libcompiler-rt-x86-source-files), 228 $(if $(findstring $(1),arm64),$(call get-libcompiler-rt-arm64-source-files), 229 $(if $(findstring $(1),mips64),$(call get-libcompiler-rt-mips64-source-files), 230 $(error Unsupported ARCH $(1))))))))) 231endef 232 233# $(1): source list 234# $(2): arch 235# 236# If lib/builtins/<arch>/X.[cS] is included in the source list, we should filter out lib/builtins/X.c 237# in the result source list (i.e., use the one optimized for the arch.) Otherwise 238# there'll be multiple definitions for one symbol. 239define filter-libcompiler-rt-common-source-files 240 $(filter-out $(patsubst lib/builtins/$(strip $(2))/%.S,lib/builtins/%.c,\ 241 $(filter lib/builtins/$(strip $(2))/%.S,$(1))) \ 242 $(patsubst lib/builtins/$(strip $(2))/%.c,lib/builtins/%.c,\ 243 $(filter lib/builtins/$(strip $(2))/%.c,$(1))),$(1)) 244endef 245 246define get-libcompiler-rt-arm-common-source-files 247 $(call filter-libcompiler-rt-common-source-files, 248 $(libcompiler_rt_common_SRC_FILES) \ 249 $(libcompiler_rt_arm_SRC_FILES), arm) 250endef 251 252# $(1): common runtime list 253# 254# Add ARM runtimes implemented in VFP 255define add-libcompiler-rt-arm-vfp-source-files 256 $(filter-out $(addprefix lib/builtins/,adddf3.c addsf3.c comparedf2.c comparesf2.c \ 257 arm/comparesf2.S divdf3.c divsf3.c extendsfdf2.c \ 258 fixdfsi.c fixsfsi.c fixunsdfsi.c fixunssfsi.c \ 259 floatsidf.c floatsisf.c floatunsidf.c floatunsisf.c \ 260 muldf3.c mulsf3.c negdf2.c negsf2.c subdf3.c \ 261 subsf3.c truncdfsf2.c),$(1)) lib/builtins/arm/vfp_alias.S 262endef 263 264define get-libcompiler-rt-arm-source-files 265 $(if $(findstring $(ARCH_ARM_HAVE_VFP),true), 266 $(call add-libcompiler-rt-arm-vfp-source-files, 267 $(call get-libcompiler-rt-arm-common-source-files)), 268 $(call get-libcompiler-rt-arm-common-source-files)) 269endef 270 271define get-libcompiler-rt-arm64-source-files 272 $(call filter-libcompiler-rt-common-source-files, 273 $(libcompiler_rt_common_SRC_FILES) \ 274 $(libcompiler_rt_arm64_SRC_FILES),arm64) 275endef 276 277define get-libcompiler-rt-mips-source-files 278 $(call filter-libcompiler-rt-common-source-files, 279 $(libcompiler_rt_common_SRC_FILES) \ 280 $(libcompiler_rt_mips_SRC_FILES),mips) 281endef 282 283define get-libcompiler-rt-mips64-source-files 284 $(call filter-libcompiler-rt-common-source-files, 285 $(libcompiler_rt_common_SRC_FILES) \ 286 $(libcompiler_rt_mips64_SRC_FILES),mips64) 287endef 288 289define get-libcompiler-rt-x86-source-files 290 $(call filter-libcompiler-rt-common-source-files, 291 $(libcompiler_rt_common_SRC_FILES) \ 292 $(libcompiler_rt_x86_SRC_FILES),i386) 293endef 294 295define get-libcompiler-rt-x86_64-source-files 296 $(call filter-libcompiler-rt-common-source-files, 297 $(libcompiler_rt_common_SRC_FILES) \ 298 $(libcompiler_rt_x86_64_SRC_FILES),x86_64) 299endef 300 301#===================================================================== 302# Device Static Library: libcompiler_rt-extras 303#===================================================================== 304 305include $(CLEAR_VARS) 306 307LOCAL_MODULE := libcompiler_rt-extras 308LOCAL_MODULE_TAGS := optional 309LOCAL_MODULE_CLASS := STATIC_LIBRARIES 310LOCAL_CLANG := true 311LOCAL_SRC_FILES := $(libcompiler_rt_extras_SRC_FILES) 312LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 313 314include $(BUILD_STATIC_LIBRARY) 315 316# Don't build compiler-rt without clang 317ifneq ($(WITHOUT_TARGET_CLANG), true) 318 319#===================================================================== 320# Device Static Library: libcompiler_rt 321#===================================================================== 322 323include $(CLEAR_VARS) 324 325LOCAL_MODULE := libcompiler_rt 326LOCAL_CFLAGS_arm += -D__ARM_EABI__ 327LOCAL_ASFLAGS := -integrated-as 328LOCAL_CLANG := true 329LOCAL_SRC_FILES_arm := $(call get-libcompiler-rt-source-files,arm) 330LOCAL_SRC_FILES_arm64 := $(call get-libcompiler-rt-source-files,arm64) 331LOCAL_SRC_FILES_mips := $(call get-libcompiler-rt-source-files,mips) 332LOCAL_SRC_FILES_mips64 := $(call get-libcompiler-rt-source-files,mips64) 333LOCAL_SRC_FILES_x86 := $(call get-libcompiler-rt-source-files,x86) 334LOCAL_SRC_FILES_x86_64 := $(call get-libcompiler-rt-source-files,x86_64) 335LOCAL_MODULE_TARGET_ARCH := arm arm64 mips mips64 x86 x86_64 336LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 337 338include $(BUILD_STATIC_LIBRARY) 339 340#===================================================================== 341# Host Static Library: libcompiler_rt 342#===================================================================== 343 344include $(CLEAR_VARS) 345 346LOCAL_MODULE := libcompiler_rt 347LOCAL_ASFLAGS := -integrated-as 348LOCAL_CLANG := true 349LOCAL_SRC_FILES := $(call get-libcompiler-rt-source-files,x86_64) 350LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 351LOCAL_MULTILIB := both 352 353include $(BUILD_HOST_STATIC_LIBRARY) 354 355#===================================================================== 356# Device Static Library: libprofile_rt 357#===================================================================== 358 359include $(CLEAR_VARS) 360 361LOCAL_MODULE = libprofile_rt 362LOCAL_SRC_FILES = lib/profile/GCDAProfiling.c 363 364include $(BUILD_STATIC_LIBRARY) 365 366#===================================================================== 367# Device Shared Library: libcompiler_rt 368#===================================================================== 369 370include $(CLEAR_VARS) 371 372LOCAL_MODULE := libcompiler_rt 373LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 374LOCAL_WHOLE_STATIC_LIBRARIES := libcompiler_rt 375LOCAL_MODULE_TARGET_ARCH := arm arm64 mips mips64 x86 x86_64 376 377include $(BUILD_SHARED_LIBRARY) 378 379# Build ASan 380include $(LOCAL_PATH)/lib/asan/Android.mk 381 382#===================================================================== 383# Host Shared Library: libcompiler_rt 384#===================================================================== 385 386include $(CLEAR_VARS) 387 388LOCAL_MODULE := libcompiler_rt 389LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 390LOCAL_WHOLE_STATIC_LIBRARIES := libcompiler_rt 391LOCAL_CPPFLAGS := -nostdinc++ 392ifneq ($(HOST_OS),windows) 393LOCAL_LDFLAGS := -nodefaultlibs 394LOCAL_LDLIBS := -lc -lm 395endif 396LOCAL_MULTILIB := both 397 398include $(BUILD_HOST_SHARED_LIBRARY) 399 400endif 401