1## Clang configurations. 2 3LLVM_PREBUILTS_PATH := $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/bin 4LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_PATH)/../lib64/clang/$(LLVM_RELEASE_VERSION)/lib/linux/ 5 6CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX) 7CLANG_CXX := $(LLVM_PREBUILTS_PATH)/clang++$(BUILD_EXECUTABLE_SUFFIX) 8LLVM_AS := $(LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX) 9LLVM_LINK := $(LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX) 10 11CLANG_TBLGEN := $(BUILD_OUT_EXECUTABLES)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX) 12LLVM_TBLGEN := $(BUILD_OUT_EXECUTABLES)/llvm-tblgen$(BUILD_EXECUTABLE_SUFFIX) 13 14# RenderScript-specific tools 15# These are tied to the version of LLVM directly in external/, so they might 16# trail the host prebuilts being used for the rest of the build process. 17RS_LLVM_PREBUILTS_VERSION := clang-2690385 18RS_LLVM_PREBUILTS_BASE := prebuilts/clang/host 19RS_LLVM_PREBUILTS_PATH := $(RS_LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(RS_LLVM_PREBUILTS_VERSION)/bin 20RS_CLANG := $(RS_LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX) 21RS_LLVM_AS := $(RS_LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX) 22RS_LLVM_LINK := $(RS_LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX) 23 24# Clang flags for all host or target rules 25CLANG_CONFIG_EXTRA_ASFLAGS := 26CLANG_CONFIG_EXTRA_CFLAGS := 27CLANG_CONFIG_EXTRA_CONLYFLAGS := -std=gnu99 28CLANG_CONFIG_EXTRA_CPPFLAGS := 29CLANG_CONFIG_EXTRA_LDFLAGS := 30 31CLANG_CONFIG_EXTRA_CFLAGS += \ 32 -D__compiler_offsetof=__builtin_offsetof 33 34# Help catch common 32/64-bit errors. 35CLANG_CONFIG_EXTRA_CFLAGS += \ 36 -Werror=int-conversion 37 38# Disable overly aggressive warning for macros defined with a leading underscore 39# This used to happen in AndroidConfig.h, which was included everywhere. 40# TODO: can we remove this now? 41CLANG_CONFIG_EXTRA_CFLAGS += \ 42 -Wno-reserved-id-macro 43 44# Disable overly aggressive warning for format strings. 45# Bug: 20148343 46CLANG_CONFIG_EXTRA_CFLAGS += \ 47 -Wno-format-pedantic 48 49# Workaround for ccache with clang. 50# See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html. 51CLANG_CONFIG_EXTRA_CFLAGS += \ 52 -Wno-unused-command-line-argument 53 54# Disable -Winconsistent-missing-override until we can clean up the existing 55# codebase for it. 56CLANG_CONFIG_EXTRA_CPPFLAGS += \ 57 -Wno-inconsistent-missing-override 58 59# Force clang to always output color diagnostics. Ninja will strip the ANSI 60# color codes if it is not running in a terminal. 61ifdef BUILDING_WITH_NINJA 62CLANG_CONFIG_EXTRA_CFLAGS += \ 63 -fcolor-diagnostics 64endif 65 66CLANG_CONFIG_UNKNOWN_CFLAGS := \ 67 -finline-functions \ 68 -finline-limit=64 \ 69 -fno-canonical-system-headers \ 70 -Wno-clobbered \ 71 -fno-devirtualize \ 72 -fno-tree-sra \ 73 -fprefetch-loop-arrays \ 74 -funswitch-loops \ 75 -Werror=unused-but-set-parameter \ 76 -Werror=unused-but-set-variable \ 77 -Wmaybe-uninitialized \ 78 -Wno-error=clobbered \ 79 -Wno-error=maybe-uninitialized \ 80 -Wno-error=unused-but-set-parameter \ 81 -Wno-error=unused-but-set-variable \ 82 -Wno-free-nonheap-object \ 83 -Wno-literal-suffix \ 84 -Wno-maybe-uninitialized \ 85 -Wno-old-style-declaration \ 86 -Wno-psabi \ 87 -Wno-unused-but-set-parameter \ 88 -Wno-unused-but-set-variable \ 89 -Wno-unused-local-typedefs \ 90 -Wunused-but-set-parameter \ 91 -Wunused-but-set-variable \ 92 -fdiagnostics-color \ 93 -fdebug-prefix-map=/proc/self/cwd= 94 95# Clang flags for all host rules 96CLANG_CONFIG_HOST_EXTRA_ASFLAGS := 97CLANG_CONFIG_HOST_EXTRA_CFLAGS := 98CLANG_CONFIG_HOST_EXTRA_CPPFLAGS := 99CLANG_CONFIG_HOST_EXTRA_LDFLAGS := 100 101# Clang flags for all host cross rules 102CLANG_CONFIG_HOST_CROSS_EXTRA_ASFLAGS := 103CLANG_CONFIG_HOST_CROSS_EXTRA_CFLAGS := 104CLANG_CONFIG_HOST_CROSS_EXTRA_CPPFLAGS := 105CLANG_CONFIG_HOST_CROSS_EXTRA_LDFLAGS := 106 107# Clang flags for all target rules 108CLANG_CONFIG_TARGET_EXTRA_ASFLAGS := 109CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc 110CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc 111CLANG_CONFIG_TARGET_EXTRA_LDFLAGS := 112 113CLANG_DEFAULT_UB_CHECKS := \ 114 bool \ 115 integer-divide-by-zero \ 116 return \ 117 returns-nonnull-attribute \ 118 shift-exponent \ 119 unreachable \ 120 vla-bound \ 121 122# TODO(danalbert): The following checks currently have compiler performance 123# issues. 124# CLANG_DEFAULT_UB_CHECKS += alignment 125# CLANG_DEFAULT_UB_CHECKS += bounds 126# CLANG_DEFAULT_UB_CHECKS += enum 127# CLANG_DEFAULT_UB_CHECKS += float-cast-overflow 128# CLANG_DEFAULT_UB_CHECKS += float-divide-by-zero 129# CLANG_DEFAULT_UB_CHECKS += nonnull-attribute 130# CLANG_DEFAULT_UB_CHECKS += null 131# CLANG_DEFAULT_UB_CHECKS += shift-base 132# CLANG_DEFAULT_UB_CHECKS += signed-integer-overflow 133 134# TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on. 135# https://llvm.org/PR19302 136# http://reviews.llvm.org/D6974 137# CLANG_DEFAULT_UB_CHECKS += object-size 138 139# HOST config 140clang_2nd_arch_prefix := 141include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk 142 143# HOST_2ND_ARCH config 144ifdef HOST_2ND_ARCH 145clang_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX) 146include $(BUILD_SYSTEM)/clang/HOST_$(HOST_2ND_ARCH).mk 147endif 148 149ifdef HOST_CROSS_ARCH 150clang_2nd_arch_prefix := 151include $(BUILD_SYSTEM)/clang/HOST_CROSS_$(HOST_CROSS_ARCH).mk 152ifdef HOST_CROSS_2ND_ARCH 153clang_2nd_arch_prefix := $(HOST_CROSS_2ND_ARCH_VAR_PREFIX) 154include $(BUILD_SYSTEM)/clang/HOST_CROSS_$(HOST_CROSS_2ND_ARCH).mk 155endif 156endif 157 158# TARGET config 159clang_2nd_arch_prefix := 160include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk 161 162# TARGET_2ND_ARCH config 163ifdef TARGET_2ND_ARCH 164clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) 165include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk 166endif 167 168ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fno-omit-frame-pointer 169ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit 170 171ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := 172ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan 173 174# This allows us to use the superset of functionality that compiler-rt 175# provides to Clang (for supporting features like -ftrapv). 176COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras 177 178ifeq ($(HOST_PREFER_32_BIT),true) 179# We don't have 32-bit prebuilt libLLVM/libclang, so force to build them from source. 180FORCE_BUILD_LLVM_COMPONENTS := true 181endif 182