config.mk revision 49b695375c64d369b15aefb48942cc84cb250485
1## Clang configurations. 2 3LLVM_PREBUILTS_VERSION ?= 3.8 4LLVM_PREBUILTS_BASE ?= prebuilts/clang/host 5LLVM_PREBUILTS_PATH := $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/bin 6LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_PATH)/../lib/clang/$(LLVM_PREBUILTS_VERSION)/lib/linux/ 7 8CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX) 9CLANG_CXX := $(LLVM_PREBUILTS_PATH)/clang++$(BUILD_EXECUTABLE_SUFFIX) 10LLVM_AS := $(LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX) 11LLVM_LINK := $(LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX) 12 13CLANG_TBLGEN := $(BUILD_OUT_EXECUTABLES)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX) 14LLVM_TBLGEN := $(BUILD_OUT_EXECUTABLES)/llvm-tblgen$(BUILD_EXECUTABLE_SUFFIX) 15 16# RenderScript-specific tools 17# These are tied to the version of LLVM directly in external/, so they might 18# trail the host prebuilts being used for the rest of the build process. 19RS_LLVM_PREBUILTS_VERSION := 3.8 20RS_LLVM_PREBUILTS_BASE := prebuilts/clang/host 21RS_LLVM_PREBUILTS_PATH := $(RS_LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(RS_LLVM_PREBUILTS_VERSION)/bin 22RS_CLANG := $(RS_LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX) 23RS_LLVM_AS := $(RS_LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX) 24RS_LLVM_LINK := $(RS_LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX) 25 26# Clang flags for all host or target rules 27CLANG_CONFIG_EXTRA_ASFLAGS := 28CLANG_CONFIG_EXTRA_CFLAGS := 29CLANG_CONFIG_EXTRA_CONLYFLAGS := -std=gnu99 30CLANG_CONFIG_EXTRA_CPPFLAGS := 31CLANG_CONFIG_EXTRA_LDFLAGS := 32 33CLANG_CONFIG_EXTRA_CFLAGS += \ 34 -D__compiler_offsetof=__builtin_offsetof 35 36# Help catch common 32/64-bit errors. 37CLANG_CONFIG_EXTRA_CFLAGS += \ 38 -Werror=int-conversion 39 40# Disable overly aggressive warning for macros defined with a leading underscore 41# This used to happen in AndroidConfig.h, which was included everywhere. 42# TODO: can we remove this now? 43CLANG_CONFIG_EXTRA_CFLAGS += \ 44 -Wno-reserved-id-macro 45 46# Disable overly aggressive warning for format strings. 47# Bug: 20148343 48CLANG_CONFIG_EXTRA_CFLAGS += \ 49 -Wno-format-pedantic 50 51# Workaround for ccache with clang. 52# See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html. 53CLANG_CONFIG_EXTRA_CFLAGS += \ 54 -Wno-unused-command-line-argument 55 56# Disable -Winconsistent-missing-override until we can clean up the existing 57# codebase for it. 58CLANG_CONFIG_EXTRA_CPPFLAGS += \ 59 -Wno-inconsistent-missing-override 60 61# Force clang to always output color diagnostics. Ninja will strip the ANSI 62# color codes if it is not running in a terminal. 63CLANG_CONFIG_EXTRA_CFLAGS += \ 64 -fcolor-diagnostics 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_OS 150include $(BUILD_SYSTEM)/clang/HOST_CROSS_$(HOST_CROSS_OS).mk 151endif 152 153# TARGET config 154clang_2nd_arch_prefix := 155include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk 156 157# TARGET_2ND_ARCH config 158ifdef TARGET_2ND_ARCH 159clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) 160include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk 161endif 162 163ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fno-omit-frame-pointer 164ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit 165 166ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := 167ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan 168 169# This allows us to use the superset of functionality that compiler-rt 170# provides to Clang (for supporting features like -ftrapv). 171COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras 172 173ifeq ($(HOST_PREFER_32_BIT),true) 174# We don't have 32-bit prebuilt libLLVM/libclang, so force to build them from source. 175FORCE_BUILD_LLVM_COMPONENTS := true 176endif 177