config.mk revision 343ed674e35ae0911542abe67dca3fb3a1cccf95
1## Clang configurations. 2 3# WITHOUT_CLANG covers both HOST and TARGET 4ifeq ($(WITHOUT_CLANG),true) 5WITHOUT_TARGET_CLANG := true 6WITHOUT_HOST_CLANG := true 7endif 8 9LLVM_PREBUILTS_VERSION := 3.6 10LLVM_PREBUILTS_PATH := prebuilts/clang/$(BUILD_OS)-x86/host/$(LLVM_PREBUILTS_VERSION)/bin 11LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_PATH)/../lib/clang/$(LLVM_PREBUILTS_VERSION)/lib/linux/ 12 13CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX) 14CLANG_CXX := $(LLVM_PREBUILTS_PATH)/clang++$(BUILD_EXECUTABLE_SUFFIX) 15LLVM_AS := $(LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX) 16LLVM_LINK := $(LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX) 17 18CLANG_TBLGEN := $(BUILD_OUT_EXECUTABLES)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX) 19LLVM_TBLGEN := $(BUILD_OUT_EXECUTABLES)/llvm-tblgen$(BUILD_EXECUTABLE_SUFFIX) 20 21# The C/C++ compiler can be wrapped by setting the CC/CXX_WRAPPER vars. 22ifdef CC_WRAPPER 23 ifneq ($(CC_WRAPPER),$(firstword $(CLANG))) 24 CLANG := $(CC_WRAPPER) $(CLANG) 25 endif 26endif 27ifdef CXX_WRAPPER 28 ifneq ($(CXX_WRAPPER),$(firstword $(CLANG_CXX))) 29 CLANG_CXX := $(CXX_WRAPPER) $(CLANG_CXX) 30 endif 31endif 32 33# Clang flags for all host or target rules 34CLANG_CONFIG_EXTRA_ASFLAGS := 35CLANG_CONFIG_EXTRA_CFLAGS := 36CLANG_CONFIG_EXTRA_CONLYFLAGS := -std=gnu99 37CLANG_CONFIG_EXTRA_CPPFLAGS := 38CLANG_CONFIG_EXTRA_LDFLAGS := 39 40CLANG_CONFIG_EXTRA_CFLAGS += \ 41 -D__compiler_offsetof=__builtin_offsetof 42 43# Help catch common 32/64-bit errors. 44CLANG_CONFIG_EXTRA_CFLAGS += \ 45 -Werror=int-conversion 46 47# Disable overly aggressive warning for macros defined with a leading underscore 48# This happens in AndroidConfig.h, which is included nearly everywhere. 49CLANG_CONFIG_EXTRA_CFLAGS += \ 50 -Wno-reserved-id-macro 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 62CLANG_CONFIG_UNKNOWN_CFLAGS := \ 63 -finline-functions \ 64 -finline-limit=64 \ 65 -fno-canonical-system-headers \ 66 -fno-tree-sra \ 67 -fprefetch-loop-arrays \ 68 -funswitch-loops \ 69 -Wmaybe-uninitialized \ 70 -Wno-error=maybe-uninitialized \ 71 -Wno-free-nonheap-object \ 72 -Wno-literal-suffix \ 73 -Wno-maybe-uninitialized \ 74 -Wno-old-style-declaration \ 75 -Wno-psabi \ 76 -Wno-unused-but-set-variable \ 77 -Wno-unused-but-set-parameter \ 78 -Wno-unused-local-typedefs 79 80# Clang flags for all host rules 81CLANG_CONFIG_HOST_EXTRA_ASFLAGS := 82CLANG_CONFIG_HOST_EXTRA_CFLAGS := 83CLANG_CONFIG_HOST_EXTRA_CPPFLAGS := 84CLANG_CONFIG_HOST_EXTRA_LDFLAGS := 85 86# Clang flags for all target rules 87CLANG_CONFIG_TARGET_EXTRA_ASFLAGS := 88CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc 89CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc 90CLANG_CONFIG_TARGET_EXTRA_LDFLAGS := 91 92# HOST config 93clang_2nd_arch_prefix := 94include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk 95 96# HOST_2ND_ARCH config 97ifdef HOST_2ND_ARCH 98clang_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX) 99include $(BUILD_SYSTEM)/clang/HOST_$(HOST_2ND_ARCH).mk 100endif 101 102# TARGET config 103clang_2nd_arch_prefix := 104include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk 105 106# TARGET_2ND_ARCH config 107ifdef TARGET_2ND_ARCH 108clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) 109include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk 110endif 111 112# Address sanitizer clang config 113ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan_$(TARGET_ARCH)_android 114ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address -fno-omit-frame-pointer 115ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit 116 117ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl $(ADDRESS_SANITIZER_RUNTIME_LIBRARY) 118ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan 119 120# This allows us to use the superset of functionality that compiler-rt 121# provides to Clang (for supporting features like -ftrapv). 122COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras 123 124ifeq ($(HOST_PREFER_32_BIT),true) 125# We don't have 32-bit prebuilt libLLVM/libclang, so force to build them from source. 126FORCE_BUILD_LLVM_COMPONENTS := true 127endif 128