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