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_PATH := prebuilts/clang/$(BUILD_OS)-x86/host/3.5/bin 10LLVM_PREBUILTS_HEADER_PATH := prebuilts/clang/$(BUILD_OS)-x86/host/3.5/lib/clang/3.5/include/ 11 12CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX) 13CLANG_CXX := $(LLVM_PREBUILTS_PATH)/clang++$(BUILD_EXECUTABLE_SUFFIX) 14LLVM_AS := $(LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX) 15LLVM_LINK := $(LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX) 16 17CLANG_TBLGEN := $(BUILD_OUT_EXECUTABLES)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX) 18LLVM_TBLGEN := $(BUILD_OUT_EXECUTABLES)/llvm-tblgen$(BUILD_EXECUTABLE_SUFFIX) 19 20# The C/C++ compiler can be wrapped by setting the CC/CXX_WRAPPER vars. 21ifdef CC_WRAPPER 22 ifneq ($(CC_WRAPPER),$(firstword $(CLANG))) 23 CLANG := $(CC_WRAPPER) $(CLANG) 24 endif 25endif 26ifdef CXX_WRAPPER 27 ifneq ($(CXX_WRAPPER),$(firstword $(CLANG_CXX))) 28 CLANG_CXX := $(CXX_WRAPPER) $(CLANG_CXX) 29 endif 30endif 31 32# Clang flags for all host or target rules 33CLANG_CONFIG_EXTRA_ASFLAGS := 34CLANG_CONFIG_EXTRA_CFLAGS := 35CLANG_CONFIG_EXTRA_CPPFLAGS := 36CLANG_CONFIG_EXTRA_LDFLAGS := 37 38CLANG_CONFIG_EXTRA_CFLAGS += \ 39 -D__compiler_offsetof=__builtin_offsetof 40 41# Help catch common 32/64-bit errors. 42CLANG_CONFIG_EXTRA_CFLAGS += \ 43 -Werror=int-conversion 44 45CLANG_CONFIG_UNKNOWN_CFLAGS := \ 46 -funswitch-loops \ 47 -fno-tree-sra \ 48 -finline-limit=64 \ 49 -Wno-psabi \ 50 -Wno-unused-but-set-variable \ 51 -Wno-unused-but-set-parameter \ 52 -Wmaybe-uninitialized \ 53 -Wno-maybe-uninitialized \ 54 -Wno-error=maybe-uninitialized \ 55 -fno-canonical-system-headers 56 57# Clang flags for all host rules 58CLANG_CONFIG_HOST_EXTRA_ASFLAGS := 59CLANG_CONFIG_HOST_EXTRA_CFLAGS := 60CLANG_CONFIG_HOST_EXTRA_CPPFLAGS := 61CLANG_CONFIG_HOST_EXTRA_LDFLAGS := 62 63# Clang flags for all target rules 64CLANG_CONFIG_TARGET_EXTRA_ASFLAGS := 65CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc 66CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc 67CLANG_CONFIG_TARGET_EXTRA_LDFLAGS := 68 69# HOST config 70clang_2nd_arch_prefix := 71include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk 72 73# HOST_2ND_ARCH config 74ifdef HOST_2ND_ARCH 75clang_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX) 76include $(BUILD_SYSTEM)/clang/HOST_$(HOST_2ND_ARCH).mk 77endif 78 79# TARGET config 80clang_2nd_arch_prefix := 81include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk 82 83# TARGET_2ND_ARCH config 84ifdef TARGET_2ND_ARCH 85clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) 86include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk 87endif 88 89 90# Clang compiler-specific libc headers 91CLANG_CONFIG_EXTRA_HOST_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH) 92CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH) $(TARGET_OUT_HEADERS)/clang 93 94# Address sanitizer clang config 95ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan_$(TARGET_ARCH)_android 96ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address -fno-omit-frame-pointer 97ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit 98ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl $(ADDRESS_SANITIZER_RUNTIME_LIBRARY) 99ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan 100 101# This allows us to use the superset of functionality that compiler-rt 102# provides to Clang (for supporting features like -ftrapv). 103COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras 104