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. 25libcompiler_rt_common_SRC_FILES := \ 26 lib/builtins/absvdi2.c \ 27 lib/builtins/absvsi2.c \ 28 lib/builtins/absvti2.c \ 29 lib/builtins/adddf3.c \ 30 lib/builtins/addsf3.c \ 31 lib/builtins/addtf3.c \ 32 lib/builtins/addvdi3.c \ 33 lib/builtins/addvsi3.c \ 34 lib/builtins/addvti3.c \ 35 lib/builtins/ashldi3.c \ 36 lib/builtins/ashlti3.c \ 37 lib/builtins/ashrdi3.c \ 38 lib/builtins/ashrti3.c \ 39 lib/builtins/clear_cache.c \ 40 lib/builtins/clzdi2.c \ 41 lib/builtins/clzsi2.c \ 42 lib/builtins/clzti2.c \ 43 lib/builtins/cmpdi2.c \ 44 lib/builtins/cmpti2.c \ 45 lib/builtins/comparedf2.c \ 46 lib/builtins/comparesf2.c \ 47 lib/builtins/comparetf2.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/divtf3.c \ 60 lib/builtins/divti3.c \ 61 lib/builtins/divxc3.c \ 62 lib/builtins/eprintf.c \ 63 lib/builtins/extenddftf2.c \ 64 lib/builtins/extendhfsf2.c \ 65 lib/builtins/extendsfdf2.c \ 66 lib/builtins/extendsftf2.c \ 67 lib/builtins/ffsdi2.c \ 68 lib/builtins/ffsti2.c \ 69 lib/builtins/fixdfdi.c \ 70 lib/builtins/fixdfsi.c \ 71 lib/builtins/fixdfti.c \ 72 lib/builtins/fixsfdi.c \ 73 lib/builtins/fixsfsi.c \ 74 lib/builtins/fixsfti.c \ 75 lib/builtins/fixtfdi.c \ 76 lib/builtins/fixtfsi.c \ 77 lib/builtins/fixtfti.c \ 78 lib/builtins/fixunsdfdi.c \ 79 lib/builtins/fixunsdfsi.c \ 80 lib/builtins/fixunsdfti.c \ 81 lib/builtins/fixunssfdi.c \ 82 lib/builtins/fixunssfsi.c \ 83 lib/builtins/fixunssfti.c \ 84 lib/builtins/fixunstfdi.c \ 85 lib/builtins/fixunstfsi.c \ 86 lib/builtins/fixunstfti.c \ 87 lib/builtins/fixunsxfdi.c \ 88 lib/builtins/fixunsxfsi.c \ 89 lib/builtins/fixunsxfti.c \ 90 lib/builtins/fixxfdi.c \ 91 lib/builtins/fixxfti.c \ 92 lib/builtins/floatdidf.c \ 93 lib/builtins/floatdisf.c \ 94 lib/builtins/floatdixf.c \ 95 lib/builtins/floatsidf.c \ 96 lib/builtins/floatsisf.c \ 97 lib/builtins/floatsitf.c \ 98 lib/builtins/floattidf.c \ 99 lib/builtins/floattisf.c \ 100 lib/builtins/floattixf.c \ 101 lib/builtins/floatundidf.c \ 102 lib/builtins/floatundisf.c \ 103 lib/builtins/floatundixf.c \ 104 lib/builtins/floatunsidf.c \ 105 lib/builtins/floatunsisf.c \ 106 lib/builtins/floatunsitf.c \ 107 lib/builtins/floatuntidf.c \ 108 lib/builtins/floatuntisf.c \ 109 lib/builtins/floatuntixf.c \ 110 lib/builtins/gcc_personality_v0.c \ 111 lib/builtins/int_util.c \ 112 lib/builtins/lshrdi3.c \ 113 lib/builtins/lshrti3.c \ 114 lib/builtins/moddi3.c \ 115 lib/builtins/modsi3.c \ 116 lib/builtins/modti3.c \ 117 lib/builtins/muldc3.c \ 118 lib/builtins/muldf3.c \ 119 lib/builtins/muldi3.c \ 120 lib/builtins/mulodi4.c \ 121 lib/builtins/mulosi4.c \ 122 lib/builtins/muloti4.c \ 123 lib/builtins/mulsc3.c \ 124 lib/builtins/mulsf3.c \ 125 lib/builtins/multf3.c \ 126 lib/builtins/multi3.c \ 127 lib/builtins/mulvdi3.c \ 128 lib/builtins/mulvsi3.c \ 129 lib/builtins/mulvti3.c \ 130 lib/builtins/mulxc3.c \ 131 lib/builtins/negdf2.c \ 132 lib/builtins/negdi2.c \ 133 lib/builtins/negsf2.c \ 134 lib/builtins/negti2.c \ 135 lib/builtins/negvdi2.c \ 136 lib/builtins/negvsi2.c \ 137 lib/builtins/negvti2.c \ 138 lib/builtins/paritydi2.c \ 139 lib/builtins/paritysi2.c \ 140 lib/builtins/parityti2.c \ 141 lib/builtins/popcountdi2.c \ 142 lib/builtins/popcountsi2.c \ 143 lib/builtins/popcountti2.c \ 144 lib/builtins/powidf2.c \ 145 lib/builtins/powisf2.c \ 146 lib/builtins/powitf2.c \ 147 lib/builtins/powixf2.c \ 148 lib/builtins/subdf3.c \ 149 lib/builtins/subsf3.c \ 150 lib/builtins/subtf3.c \ 151 lib/builtins/subvdi3.c \ 152 lib/builtins/subvsi3.c \ 153 lib/builtins/subvti3.c \ 154 lib/builtins/trampoline_setup.c \ 155 lib/builtins/truncdfhf2.c \ 156 lib/builtins/truncdfsf2.c \ 157 lib/builtins/truncsfhf2.c \ 158 lib/builtins/trunctfdf2.c \ 159 lib/builtins/trunctfsf2.c \ 160 lib/builtins/ucmpdi2.c \ 161 lib/builtins/ucmpti2.c \ 162 lib/builtins/udivdi3.c \ 163 lib/builtins/udivmoddi4.c \ 164 lib/builtins/udivmodsi4.c \ 165 lib/builtins/udivmodti4.c \ 166 lib/builtins/udivsi3.c \ 167 lib/builtins/udivti3.c \ 168 lib/builtins/umoddi3.c \ 169 lib/builtins/umodsi3.c \ 170 lib/builtins/umodti3.c 171 172# Only build enable_execute_stack.c on non-Windows hosts. 173ifneq ($(HOST_OS),windows) 174libcompiler_rt_common_SRC_FILES += \ 175 lib/builtins/enable_execute_stack.c 176endif 177 178# ARM-specific runtimes 179libcompiler_rt_arm_SRC_FILES := \ 180 lib/builtins/arm/aeabi_dcmp.S \ 181 lib/builtins/arm/aeabi_div0.c \ 182 lib/builtins/arm/aeabi_fcmp.S \ 183 lib/builtins/arm/aeabi_idivmod.S \ 184 lib/builtins/arm/aeabi_ldivmod.S \ 185 lib/builtins/arm/aeabi_memcmp.S \ 186 lib/builtins/arm/aeabi_memcpy.S \ 187 lib/builtins/arm/aeabi_memmove.S \ 188 lib/builtins/arm/aeabi_memset.S \ 189 lib/builtins/arm/aeabi_uidivmod.S \ 190 lib/builtins/arm/aeabi_uldivmod.S \ 191 lib/builtins/arm/comparesf2.S \ 192 lib/builtins/arm/divmodsi4.S \ 193 lib/builtins/arm/divsi3.S \ 194 lib/builtins/arm/modsi3.S \ 195 lib/builtins/arm/udivmodsi4.S \ 196 lib/builtins/arm/udivsi3.S \ 197 lib/builtins/arm/umodsi3.S \ 198 lib/builtins/arm/adddf3vfp.S \ 199 lib/builtins/arm/addsf3vfp.S \ 200 lib/builtins/arm/divdf3vfp.S \ 201 lib/builtins/arm/divsf3vfp.S \ 202 lib/builtins/arm/eqdf2vfp.S \ 203 lib/builtins/arm/eqsf2vfp.S \ 204 lib/builtins/arm/extendsfdf2vfp.S \ 205 lib/builtins/arm/fixdfsivfp.S \ 206 lib/builtins/arm/fixsfsivfp.S \ 207 lib/builtins/arm/fixunsdfsivfp.S \ 208 lib/builtins/arm/fixunssfsivfp.S \ 209 lib/builtins/arm/floatsidfvfp.S \ 210 lib/builtins/arm/floatsisfvfp.S \ 211 lib/builtins/arm/floatunssidfvfp.S \ 212 lib/builtins/arm/floatunssisfvfp.S \ 213 lib/builtins/arm/gedf2vfp.S \ 214 lib/builtins/arm/gesf2vfp.S \ 215 lib/builtins/arm/gtdf2vfp.S \ 216 lib/builtins/arm/gtsf2vfp.S \ 217 lib/builtins/arm/ledf2vfp.S \ 218 lib/builtins/arm/lesf2vfp.S \ 219 lib/builtins/arm/ltdf2vfp.S \ 220 lib/builtins/arm/ltsf2vfp.S \ 221 lib/builtins/arm/muldf3vfp.S \ 222 lib/builtins/arm/mulsf3vfp.S \ 223 lib/builtins/arm/nedf2vfp.S \ 224 lib/builtins/arm/negdf2vfp.S \ 225 lib/builtins/arm/negsf2vfp.S \ 226 lib/builtins/arm/nesf2vfp.S \ 227 lib/builtins/arm/subdf3vfp.S \ 228 lib/builtins/arm/subsf3vfp.S \ 229 lib/builtins/arm/truncdfsf2vfp.S \ 230 lib/builtins/arm/unorddf2vfp.S \ 231 lib/builtins/arm/unordsf2vfp.S 232 233 234# ARM64-specific runtimes 235libcompiler_rt_arm64_SRC_FILES := 236 237# MIPS-specific runtimes 238libcompiler_rt_mips_SRC_FILES := # nothing to add 239libcompiler_rt_mips64_SRC_FILES := # nothing to add 240 241# X86-specific runtimes 242libcompiler_rt_x86_SRC_FILES := \ 243 lib/builtins/i386/ashldi3.S \ 244 lib/builtins/i386/ashrdi3.S \ 245 lib/builtins/i386/divdi3.S \ 246 lib/builtins/i386/floatdidf.S \ 247 lib/builtins/i386/floatdisf.S \ 248 lib/builtins/i386/floatdixf.S \ 249 lib/builtins/i386/floatundidf.S \ 250 lib/builtins/i386/floatundisf.S \ 251 lib/builtins/i386/floatundixf.S \ 252 lib/builtins/i386/lshrdi3.S \ 253 lib/builtins/i386/moddi3.S \ 254 lib/builtins/i386/muldi3.S \ 255 lib/builtins/i386/udivdi3.S \ 256 lib/builtins/i386/umoddi3.S 257 258# X86_64-specific runtimes 259libcompiler_rt_x86_64_SRC_FILES := \ 260 lib/builtins/x86_64/floatundixf.S \ 261 lib/builtins/x86_64/floatdisf.c \ 262 lib/builtins/x86_64/floatdidf.c \ 263 lib/builtins/x86_64/floatdixf.c \ 264 lib/builtins/x86_64/floatundisf.S \ 265 lib/builtins/x86_64/floatundidf.S 266 267# The following list contains functions that are not available in libgcc.a, so 268# we potentially need them when using a Clang-built component (e.g., -ftrapv 269# with 64-bit integer multiplies. See http://llvm.org/bugs/show_bug.cgi?id=14469.) 270libcompiler_rt_extras_SRC_FILES := \ 271 lib/builtins/mulodi4.c 272 273# $(1): arch 274define get-libcompiler-rt-source-files 275 $(if $(findstring $(1),arm),$(call get-libcompiler-rt-arm-source-files), 276 $(if $(findstring $(1),mips),$(call get-libcompiler-rt-mips-source-files), 277 $(if $(findstring $(1),x86),$(call get-libcompiler-rt-x86-source-files), 278 $(if $(findstring $(1),x86_64),$(call get-libcompiler-rt-x86_64-source-files), 279 $(if $(findstring $(1),x32),$(call get-libcompiler-rt-x86-source-files), 280 $(if $(findstring $(1),arm64),$(call get-libcompiler-rt-arm64-source-files), 281 $(if $(findstring $(1),mips64),$(call get-libcompiler-rt-mips64-source-files), 282 $(error Unsupported ARCH $(1))))))))) 283endef 284 285# $(1): source list 286# $(2): arch 287# 288# If lib/builtins/<arch>/X.[cS] is included in the source list, we should filter out lib/builtins/X.c 289# in the result source list (i.e., use the one optimized for the arch.) Otherwise 290# there'll be multiple definitions for one symbol. 291define filter-libcompiler-rt-common-source-files 292 $(filter-out $(patsubst lib/builtins/$(strip $(2))/%.S,lib/builtins/%.c,\ 293 $(filter lib/builtins/$(strip $(2))/%.S,$(1))) \ 294 $(patsubst lib/builtins/$(strip $(2))/%.c,lib/builtins/%.c,\ 295 $(filter lib/builtins/$(strip $(2))/%.c,$(1))),$(1)) 296endef 297 298define get-libcompiler-rt-arm-common-source-files 299 $(call filter-libcompiler-rt-common-source-files, 300 $(libcompiler_rt_common_SRC_FILES) \ 301 $(libcompiler_rt_arm_SRC_FILES), arm) 302endef 303 304# $(1): common runtime list 305# 306# Add ARM runtimes implemented in VFP 307define add-libcompiler-rt-arm-vfp-source-files 308 $(filter-out $(addprefix lib/builtins/,adddf3.c addsf3.c comparedf2.c comparesf2.c \ 309 arm/comparesf2.S divdf3.c divsf3.c extendsfdf2.c \ 310 fixdfsi.c fixsfsi.c fixunsdfsi.c fixunssfsi.c \ 311 floatsidf.c floatsisf.c floatunsidf.c floatunsisf.c \ 312 muldf3.c mulsf3.c negdf2.c negsf2.c subdf3.c \ 313 subsf3.c truncdfsf2.c),$(1)) 314endef 315 316define get-libcompiler-rt-arm-source-files 317 $(if $(findstring $(ARCH_ARM_HAVE_VFP),true), 318 $(call add-libcompiler-rt-arm-vfp-source-files, 319 $(call get-libcompiler-rt-arm-common-source-files)), 320 $(call get-libcompiler-rt-arm-common-source-files)) 321endef 322 323define get-libcompiler-rt-arm64-source-files 324 $(call filter-libcompiler-rt-common-source-files, 325 $(libcompiler_rt_common_SRC_FILES) \ 326 $(libcompiler_rt_arm64_SRC_FILES),arm64) 327endef 328 329define get-libcompiler-rt-mips-source-files 330 $(call filter-libcompiler-rt-common-source-files, 331 $(libcompiler_rt_common_SRC_FILES) \ 332 $(libcompiler_rt_mips_SRC_FILES),mips) 333endef 334 335define get-libcompiler-rt-mips64-source-files 336 $(call filter-libcompiler-rt-common-source-files, 337 $(libcompiler_rt_common_SRC_FILES) \ 338 $(libcompiler_rt_mips64_SRC_FILES),mips64) 339endef 340 341define get-libcompiler-rt-x86-source-files 342 $(call filter-libcompiler-rt-common-source-files, 343 $(libcompiler_rt_common_SRC_FILES) \ 344 $(libcompiler_rt_x86_SRC_FILES),i386) 345endef 346 347define get-libcompiler-rt-x86_64-source-files 348 $(call filter-libcompiler-rt-common-source-files, 349 $(libcompiler_rt_common_SRC_FILES) \ 350 $(libcompiler_rt_x86_64_SRC_FILES),x86_64) 351endef 352 353#===================================================================== 354# Device Static Library: libcompiler_rt-extras 355#===================================================================== 356 357include $(CLEAR_VARS) 358 359LOCAL_MODULE := libcompiler_rt-extras 360LOCAL_MODULE_TAGS := optional 361LOCAL_MODULE_CLASS := STATIC_LIBRARIES 362LOCAL_CLANG := true 363LOCAL_SRC_FILES := $(libcompiler_rt_extras_SRC_FILES) 364LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 365LOCAL_ADDRESS_SANITIZER := false 366LOCAL_CXX_STL := none 367 368include $(BUILD_STATIC_LIBRARY) 369 370#===================================================================== 371# Host Static Library: libcompiler_rt-extras 372#===================================================================== 373 374include $(CLEAR_VARS) 375 376LOCAL_MODULE := libcompiler_rt-extras 377LOCAL_CLANG := true 378LOCAL_SRC_FILES := $(libcompiler_rt_extras_SRC_FILES) 379LOCAL_ADDRESS_SANITIZER := false 380LOCAL_MULTILIB := both 381LOCAL_CXX_STL := none 382 383include $(BUILD_HOST_STATIC_LIBRARY) 384 385# Don't build compiler-rt without clang 386ifneq ($(WITHOUT_TARGET_CLANG), true) 387 388#===================================================================== 389# Device Static Library: libcompiler_rt 390#===================================================================== 391 392include $(CLEAR_VARS) 393 394LOCAL_MODULE := libcompiler_rt 395LOCAL_CFLAGS_arm += -D__ARM_EABI__ 396LOCAL_CFLAGS_mips64 += -DCRT_HAS_128BIT -DCRT_LDBL_128BIT 397LOCAL_ASFLAGS := -integrated-as 398LOCAL_CLANG := true 399LOCAL_SRC_FILES_arm := $(call get-libcompiler-rt-source-files,arm) 400LOCAL_SRC_FILES_arm64 := $(call get-libcompiler-rt-source-files,arm64) 401LOCAL_SRC_FILES_mips := $(call get-libcompiler-rt-source-files,mips) 402LOCAL_SRC_FILES_mips64 := $(call get-libcompiler-rt-source-files,mips64) 403LOCAL_SRC_FILES_x86 := $(call get-libcompiler-rt-source-files,x86) 404LOCAL_SRC_FILES_x86_64 := $(call get-libcompiler-rt-source-files,x86_64) 405LOCAL_SRC_FILES_x86_64 += lib/builtins/ppc/floatditf.c 406LOCAL_MODULE_TARGET_ARCH := arm arm64 mips mips64 x86 x86_64 407LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 408LOCAL_ADDRESS_SANITIZER := false 409LOCAL_CXX_STL := none 410 411include $(BUILD_STATIC_LIBRARY) 412 413#===================================================================== 414# Host Static Library: libcompiler_rt 415#===================================================================== 416 417include $(CLEAR_VARS) 418 419LOCAL_MODULE := libcompiler_rt 420LOCAL_ASFLAGS := -integrated-as 421LOCAL_CLANG := true 422LOCAL_SRC_FILES := $(call get-libcompiler-rt-source-files,x86_64) 423LOCAL_ADDRESS_SANITIZER := false 424LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 425LOCAL_MULTILIB := both 426LOCAL_CXX_STL := none 427 428include $(BUILD_HOST_STATIC_LIBRARY) 429 430#===================================================================== 431# Host Static Library: libprofile_rt 432#===================================================================== 433 434include $(CLEAR_VARS) 435 436LOCAL_MODULE = libprofile_rt 437LOCAL_SRC_FILES = lib/profile/GCDAProfiling.c 438LOCAL_ADDRESS_SANITIZER := false 439LOCAL_MULTILIB := both 440LOCAL_CXX_STL := none 441 442include $(BUILD_HOST_STATIC_LIBRARY) 443 444#===================================================================== 445# Device Static Library: libprofile_rt 446#===================================================================== 447 448include $(CLEAR_VARS) 449 450LOCAL_MODULE = libprofile_rt 451LOCAL_CLANG := true 452LOCAL_SRC_FILES = lib/profile/GCDAProfiling.c 453LOCAL_ADDRESS_SANITIZER := false 454LOCAL_MULTILIB := both 455LOCAL_CXX_STL := none 456 457include $(BUILD_STATIC_LIBRARY) 458 459#===================================================================== 460# Device Shared Library: libcompiler_rt 461#===================================================================== 462 463include $(CLEAR_VARS) 464 465LOCAL_MODULE := libcompiler_rt 466LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 467LOCAL_WHOLE_STATIC_LIBRARIES := libcompiler_rt 468LOCAL_SHARED_LIBRARIES := libdl 469LOCAL_STATIC_LIBRARIES_arm := libunwind_llvm 470LOCAL_STATIC_LIBRARIES_arm64 := libunwindbacktrace 471LOCAL_STATIC_LIBRARIES_mips := libunwindbacktrace 472LOCAL_STATIC_LIBRARIES_mips64 := libunwindbacktrace 473LOCAL_STATIC_LIBRARIES_x86 := libunwindbacktrace 474LOCAL_STATIC_LIBRARIES_x86_64 := libunwindbacktrace 475LOCAL_MODULE_TARGET_ARCH := arm arm64 mips mips64 x86 x86_64 476LOCAL_ADDRESS_SANITIZER := false 477LOCAL_CXX_STL := none 478LOCAL_NO_LIBGCC := true 479 480include $(BUILD_SHARED_LIBRARY) 481 482#===================================================================== 483# Host Shared Library: libcompiler_rt 484#===================================================================== 485 486include $(CLEAR_VARS) 487 488LOCAL_MODULE := libcompiler_rt 489LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 490LOCAL_WHOLE_STATIC_LIBRARIES := libcompiler_rt 491ifneq ($(HOST_OS),darwin) 492LOCAL_STATIC_LIBRARIES := libunwindbacktrace 493endif 494LOCAL_CPPFLAGS := -nostdinc++ 495ifneq ($(HOST_OS),windows) 496LOCAL_LDFLAGS := -nodefaultlibs 497LOCAL_LDLIBS := -lpthread -lc -lm 498endif 499LOCAL_MULTILIB := both 500LOCAL_ADDRESS_SANITIZER := false 501LOCAL_CXX_STL := none 502LOCAL_NO_LIBGCC := true 503 504include $(BUILD_HOST_SHARED_LIBRARY) 505 506# Build asan, lsan, etc. 507include $(call all-makefiles-under,$(LOCAL_PATH)/lib) 508 509endif 510