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# ARM-specific runtimes 173libcompiler_rt_arm_SRC_FILES := \ 174 lib/builtins/arm/aeabi_dcmp.S \ 175 lib/builtins/arm/aeabi_div0.c \ 176 lib/builtins/arm/aeabi_fcmp.S \ 177 lib/builtins/arm/aeabi_idivmod.S \ 178 lib/builtins/arm/aeabi_ldivmod.S \ 179 lib/builtins/arm/aeabi_memcmp.S \ 180 lib/builtins/arm/aeabi_memcpy.S \ 181 lib/builtins/arm/aeabi_memmove.S \ 182 lib/builtins/arm/aeabi_memset.S \ 183 lib/builtins/arm/aeabi_uidivmod.S \ 184 lib/builtins/arm/aeabi_uldivmod.S \ 185 lib/builtins/arm/comparesf2.S \ 186 lib/builtins/arm/divmodsi4.S \ 187 lib/builtins/arm/divsi3.S \ 188 lib/builtins/arm/modsi3.S \ 189 lib/builtins/arm/udivmodsi4.S \ 190 lib/builtins/arm/udivsi3.S \ 191 lib/builtins/arm/umodsi3.S \ 192 lib/builtins/arm/adddf3vfp.S \ 193 lib/builtins/arm/addsf3vfp.S \ 194 lib/builtins/arm/divdf3vfp.S \ 195 lib/builtins/arm/divsf3vfp.S \ 196 lib/builtins/arm/eqdf2vfp.S \ 197 lib/builtins/arm/eqsf2vfp.S \ 198 lib/builtins/arm/extendsfdf2vfp.S \ 199 lib/builtins/arm/fixdfsivfp.S \ 200 lib/builtins/arm/fixsfsivfp.S \ 201 lib/builtins/arm/fixunsdfsivfp.S \ 202 lib/builtins/arm/fixunssfsivfp.S \ 203 lib/builtins/arm/floatsidfvfp.S \ 204 lib/builtins/arm/floatsisfvfp.S \ 205 lib/builtins/arm/floatunssidfvfp.S \ 206 lib/builtins/arm/floatunssisfvfp.S \ 207 lib/builtins/arm/gedf2vfp.S \ 208 lib/builtins/arm/gesf2vfp.S \ 209 lib/builtins/arm/gtdf2vfp.S \ 210 lib/builtins/arm/gtsf2vfp.S \ 211 lib/builtins/arm/ledf2vfp.S \ 212 lib/builtins/arm/lesf2vfp.S \ 213 lib/builtins/arm/ltdf2vfp.S \ 214 lib/builtins/arm/ltsf2vfp.S \ 215 lib/builtins/arm/muldf3vfp.S \ 216 lib/builtins/arm/mulsf3vfp.S \ 217 lib/builtins/arm/nedf2vfp.S \ 218 lib/builtins/arm/negdf2vfp.S \ 219 lib/builtins/arm/negsf2vfp.S \ 220 lib/builtins/arm/nesf2vfp.S \ 221 lib/builtins/arm/subdf3vfp.S \ 222 lib/builtins/arm/subsf3vfp.S \ 223 lib/builtins/arm/truncdfsf2vfp.S \ 224 lib/builtins/arm/unorddf2vfp.S \ 225 lib/builtins/arm/unordsf2vfp.S 226 227 228# ARM64-specific runtimes 229libcompiler_rt_arm64_SRC_FILES := 230 231# MIPS-specific runtimes 232libcompiler_rt_mips_SRC_FILES := # nothing to add 233libcompiler_rt_mips64_SRC_FILES := # nothing to add 234 235# X86-specific runtimes 236libcompiler_rt_x86_SRC_FILES := \ 237 lib/builtins/i386/ashldi3.S \ 238 lib/builtins/i386/ashrdi3.S \ 239 lib/builtins/i386/divdi3.S \ 240 lib/builtins/i386/floatdidf.S \ 241 lib/builtins/i386/floatdisf.S \ 242 lib/builtins/i386/floatdixf.S \ 243 lib/builtins/i386/floatundidf.S \ 244 lib/builtins/i386/floatundisf.S \ 245 lib/builtins/i386/floatundixf.S \ 246 lib/builtins/i386/lshrdi3.S \ 247 lib/builtins/i386/moddi3.S \ 248 lib/builtins/i386/muldi3.S \ 249 lib/builtins/i386/udivdi3.S \ 250 lib/builtins/i386/umoddi3.S 251 252# X86_64-specific runtimes 253libcompiler_rt_x86_64_SRC_FILES := \ 254 lib/builtins/x86_64/floatundixf.S \ 255 lib/builtins/x86_64/floatdisf.c \ 256 lib/builtins/x86_64/floatdidf.c \ 257 lib/builtins/x86_64/floatdixf.c \ 258 lib/builtins/x86_64/floatundisf.S \ 259 lib/builtins/x86_64/floatundidf.S 260 261# The following list contains functions that are not available in libgcc.a, so 262# we potentially need them when using a Clang-built component (e.g., -ftrapv 263# with 64-bit integer multiplies. See http://llvm.org/bugs/show_bug.cgi?id=14469.) 264libcompiler_rt_extras_SRC_FILES := \ 265 lib/builtins/mulodi4.c 266 267# $(1): arch 268define get-libcompiler-rt-source-files 269 $(if $(findstring $(1),arm),$(call get-libcompiler-rt-arm-source-files), 270 $(if $(findstring $(1),mips),$(call get-libcompiler-rt-mips-source-files), 271 $(if $(findstring $(1),x86),$(call get-libcompiler-rt-x86-source-files), 272 $(if $(findstring $(1),x86_64),$(call get-libcompiler-rt-x86_64-source-files), 273 $(if $(findstring $(1),x32),$(call get-libcompiler-rt-x86-source-files), 274 $(if $(findstring $(1),arm64),$(call get-libcompiler-rt-arm64-source-files), 275 $(if $(findstring $(1),mips64),$(call get-libcompiler-rt-mips64-source-files), 276 $(error Unsupported ARCH $(1))))))))) 277endef 278 279# $(1): source list 280# $(2): arch 281# 282# If lib/builtins/<arch>/X.[cS] is included in the source list, we should filter out lib/builtins/X.c 283# in the result source list (i.e., use the one optimized for the arch.) Otherwise 284# there'll be multiple definitions for one symbol. 285define filter-libcompiler-rt-common-source-files 286 $(filter-out $(patsubst lib/builtins/$(strip $(2))/%.S,lib/builtins/%.c,\ 287 $(filter lib/builtins/$(strip $(2))/%.S,$(1))) \ 288 $(patsubst lib/builtins/$(strip $(2))/%.c,lib/builtins/%.c,\ 289 $(filter lib/builtins/$(strip $(2))/%.c,$(1))),$(1)) 290endef 291 292define get-libcompiler-rt-arm-source-files 293 $(call filter-libcompiler-rt-common-source-files, 294 $(libcompiler_rt_common_SRC_FILES) \ 295 $(libcompiler_rt_arm_SRC_FILES), arm) 296endef 297 298define get-libcompiler-rt-arm64-source-files 299 $(call filter-libcompiler-rt-common-source-files, 300 $(libcompiler_rt_common_SRC_FILES) \ 301 $(libcompiler_rt_arm64_SRC_FILES),arm64) 302endef 303 304define get-libcompiler-rt-mips-source-files 305 $(call filter-libcompiler-rt-common-source-files, 306 $(libcompiler_rt_common_SRC_FILES) \ 307 $(libcompiler_rt_mips_SRC_FILES),mips) 308endef 309 310define get-libcompiler-rt-mips64-source-files 311 $(call filter-libcompiler-rt-common-source-files, 312 $(libcompiler_rt_common_SRC_FILES) \ 313 $(libcompiler_rt_mips64_SRC_FILES),mips64) 314endef 315 316define get-libcompiler-rt-x86-source-files 317 $(call filter-libcompiler-rt-common-source-files, 318 $(libcompiler_rt_common_SRC_FILES) \ 319 $(libcompiler_rt_x86_SRC_FILES),i386) 320endef 321 322define get-libcompiler-rt-x86_64-source-files 323 $(call filter-libcompiler-rt-common-source-files, 324 $(libcompiler_rt_common_SRC_FILES) \ 325 $(libcompiler_rt_x86_64_SRC_FILES),x86_64) 326endef 327 328libcompiler_rt_common_CFLAGS := \ 329 -Wno-unused-parameter \ 330 -Werror 331 332#===================================================================== 333# Device Static Library: libcompiler_rt-extras 334#===================================================================== 335 336include $(CLEAR_VARS) 337 338LOCAL_MODULE := libcompiler_rt-extras 339LOCAL_MODULE_TAGS := optional 340LOCAL_MODULE_CLASS := STATIC_LIBRARIES 341LOCAL_CFLAGS := $(libcompiler_rt_common_CFLAGS) 342LOCAL_CLANG := true 343LOCAL_SRC_FILES := $(libcompiler_rt_extras_SRC_FILES) 344LOCAL_SRC_FILES_mips += lib/builtins/clear_cache.c 345LOCAL_SRC_FILES_mips64 += lib/builtins/clear_cache.c 346LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 347LOCAL_SANITIZE := never 348LOCAL_CXX_STL := none 349 350include $(BUILD_STATIC_LIBRARY) 351 352#===================================================================== 353# Host Static Library: libcompiler_rt-extras 354#===================================================================== 355 356include $(CLEAR_VARS) 357 358LOCAL_MODULE := libcompiler_rt-extras 359LOCAL_CFLAGS := $(libcompiler_rt_common_CFLAGS) 360LOCAL_CLANG := true 361LOCAL_SRC_FILES := $(libcompiler_rt_extras_SRC_FILES) 362LOCAL_SANITIZE := never 363LOCAL_MULTILIB := both 364LOCAL_CXX_STL := none 365LOCAL_MODULE_HOST_OS := darwin linux windows 366 367include $(BUILD_HOST_STATIC_LIBRARY) 368 369# Don't build compiler-rt without clang 370ifneq ($(WITHOUT_TARGET_CLANG), true) 371 372#===================================================================== 373# Device Static Library: libcompiler_rt 374#===================================================================== 375 376include $(CLEAR_VARS) 377 378LOCAL_MODULE := libcompiler_rt 379LOCAL_CFLAGS := $(libcompiler_rt_common_CFLAGS) 380LOCAL_CFLAGS_arm += -D__ARM_EABI__ 381LOCAL_CFLAGS_mips64 += -DCRT_HAS_128BIT 382LOCAL_ASFLAGS := -integrated-as 383LOCAL_CLANG := true 384LOCAL_SRC_FILES := lib/builtins/enable_execute_stack.c 385LOCAL_SRC_FILES_arm := $(call get-libcompiler-rt-source-files,arm) 386LOCAL_SRC_FILES_arm64 := $(call get-libcompiler-rt-source-files,arm64) 387LOCAL_SRC_FILES_mips := $(call get-libcompiler-rt-source-files,mips) 388LOCAL_SRC_FILES_mips64 := $(call get-libcompiler-rt-source-files,mips64) 389LOCAL_SRC_FILES_x86 := $(call get-libcompiler-rt-source-files,x86) 390LOCAL_SRC_FILES_x86_64 := $(call get-libcompiler-rt-source-files,x86_64) 391LOCAL_SRC_FILES_x86_64 += lib/builtins/ppc/floatditf.c 392LOCAL_MODULE_TARGET_ARCH := arm arm64 mips mips64 x86 x86_64 393LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 394LOCAL_SANITIZE := never 395LOCAL_CXX_STL := none 396 397# These don't actually link, but are required to get exported headers 398LOCAL_STATIC_LIBRARIES_arm64 := libunwindbacktrace 399LOCAL_STATIC_LIBRARIES_mips := libunwindbacktrace 400LOCAL_STATIC_LIBRARIES_mips64 := libunwindbacktrace 401LOCAL_STATIC_LIBRARIES_x86 := libunwindbacktrace 402LOCAL_STATIC_LIBRARIES_x86_64 := libunwindbacktrace 403 404include $(BUILD_STATIC_LIBRARY) 405 406#===================================================================== 407# Host Static Library: libcompiler_rt 408#===================================================================== 409 410include $(CLEAR_VARS) 411 412LOCAL_MODULE := libcompiler_rt 413LOCAL_CFLAGS := $(libcompiler_rt_common_CFLAGS) 414LOCAL_ASFLAGS := -integrated-as 415LOCAL_CLANG := true 416LOCAL_SRC_FILES := $(call get-libcompiler-rt-source-files,x86_64) 417# Only build enable_execute_stack.c on non-Windows hosts. 418LOCAL_SRC_FILES_darwin := lib/builtins/enable_execute_stack.c 419LOCAL_SRC_FILES_linux := lib/builtins/enable_execute_stack.c 420LOCAL_SANITIZE := never 421LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 422LOCAL_MULTILIB := both 423LOCAL_CXX_STL := none 424 425# These don't actually link, but are required to get exported headers 426LOCAL_STATIC_LIBRARIES_linux := libunwindbacktrace 427LOCAL_STATIC_LIBRARIES_windows := libunwindbacktrace 428 429include $(BUILD_HOST_STATIC_LIBRARY) 430 431#===================================================================== 432# Device Shared Library: libcompiler_rt 433#===================================================================== 434 435include $(CLEAR_VARS) 436 437LOCAL_MODULE := libcompiler_rt 438LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 439LOCAL_WHOLE_STATIC_LIBRARIES := libcompiler_rt 440LOCAL_SHARED_LIBRARIES := libdl liblog 441LOCAL_STATIC_LIBRARIES := liblzma 442LOCAL_STATIC_LIBRARIES_arm := libunwind_llvm 443LOCAL_STATIC_LIBRARIES_arm64 := libunwindbacktrace 444LOCAL_STATIC_LIBRARIES_mips := libunwindbacktrace 445LOCAL_STATIC_LIBRARIES_mips64 := libunwindbacktrace 446LOCAL_STATIC_LIBRARIES_x86 := libunwindbacktrace 447LOCAL_STATIC_LIBRARIES_x86_64 := libunwindbacktrace 448LOCAL_LDFLAGS_arm := -Wl,--exclude-libs,libunwind_llvm.a 449LOCAL_LDFLAGS_arm64 := -Wl,--exclude-libs,libunwindbacktrace.a 450LOCAL_LDFLAGS_mips := -Wl,--exclude-libs,libunwindbacktrace.a 451LOCAL_LDFLAGS_mips64 := -Wl,--exclude-libs,libunwindbacktrace.a 452LOCAL_LDFLAGS_x86 := -Wl,--exclude-libs,libunwindbacktrace.a 453LOCAL_LDFLAGS_x86_64 := -Wl,--exclude-libs,libunwindbacktrace.a 454LOCAL_MODULE_TARGET_ARCH := arm arm64 mips mips64 x86 x86_64 455LOCAL_SANITIZE := never 456LOCAL_CXX_STL := none 457LOCAL_NO_LIBGCC := true 458 459include $(BUILD_SHARED_LIBRARY) 460 461#===================================================================== 462# Host Shared Library: libcompiler_rt 463#===================================================================== 464 465include $(CLEAR_VARS) 466 467LOCAL_MODULE := libcompiler_rt 468LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 469LOCAL_WHOLE_STATIC_LIBRARIES := libcompiler_rt 470LOCAL_STATIC_LIBRARIES_linux := libunwindbacktrace 471LOCAL_STATIC_LIBRARIES_windows := libunwindbacktrace 472LOCAL_CPPFLAGS := -nostdinc++ 473LOCAL_LDFLAGS_darwin := -nodefaultlibs 474LOCAL_LDFLAGS_linux := -nodefaultlibs 475LOCAL_LDLIBS_darwin := -lpthread -lc -lm 476LOCAL_LDLIBS_linux := -lpthread -lc -lm 477LOCAL_MULTILIB := both 478LOCAL_SANITIZE := never 479LOCAL_CXX_STL := none 480LOCAL_NO_LIBGCC := true 481 482include $(BUILD_HOST_SHARED_LIBRARY) 483 484# Build asan, lsan, etc. 485include $(call all-makefiles-under,$(LOCAL_PATH)/lib) 486 487endif 488