2014-03-11 02:23:08 +01:00
|
|
|
## Clang configurations.
|
|
|
|
|
2015-10-21 17:32:45 +02:00
|
|
|
LLVM_PREBUILTS_VERSION := 3.6
|
|
|
|
FORCE_BUILD_SANITIZER_SHARED_OBJECTS := true
|
2015-09-29 05:33:03 +02:00
|
|
|
LLVM_PREBUILTS_PATH := prebuilts/clang/host/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/bin
|
2015-01-26 01:20:57 +01:00
|
|
|
LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_PATH)/../lib/clang/$(LLVM_PREBUILTS_VERSION)/lib/linux/
|
2014-02-19 18:03:00 +01:00
|
|
|
|
|
|
|
CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX)
|
|
|
|
CLANG_CXX := $(LLVM_PREBUILTS_PATH)/clang++$(BUILD_EXECUTABLE_SUFFIX)
|
|
|
|
LLVM_AS := $(LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX)
|
|
|
|
LLVM_LINK := $(LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX)
|
2014-04-30 22:54:32 +02:00
|
|
|
|
2014-09-30 11:37:20 +02:00
|
|
|
CLANG_TBLGEN := $(BUILD_OUT_EXECUTABLES)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX)
|
|
|
|
LLVM_TBLGEN := $(BUILD_OUT_EXECUTABLES)/llvm-tblgen$(BUILD_EXECUTABLE_SUFFIX)
|
2014-02-07 03:08:44 +01:00
|
|
|
|
|
|
|
# Clang flags for all host or target rules
|
|
|
|
CLANG_CONFIG_EXTRA_ASFLAGS :=
|
|
|
|
CLANG_CONFIG_EXTRA_CFLAGS :=
|
2014-11-26 09:57:34 +01:00
|
|
|
CLANG_CONFIG_EXTRA_CONLYFLAGS := -std=gnu99
|
2014-02-07 03:08:44 +01:00
|
|
|
CLANG_CONFIG_EXTRA_CPPFLAGS :=
|
|
|
|
CLANG_CONFIG_EXTRA_LDFLAGS :=
|
|
|
|
|
2014-06-17 23:36:05 +02:00
|
|
|
CLANG_CONFIG_EXTRA_CFLAGS += \
|
2014-02-07 03:08:44 +01:00
|
|
|
-D__compiler_offsetof=__builtin_offsetof
|
|
|
|
|
2014-06-17 23:36:05 +02:00
|
|
|
# Help catch common 32/64-bit errors.
|
|
|
|
CLANG_CONFIG_EXTRA_CFLAGS += \
|
|
|
|
-Werror=int-conversion
|
|
|
|
|
2015-03-17 22:42:11 +01:00
|
|
|
# Disable overly aggressive warning for macros defined with a leading underscore
|
2015-08-28 19:31:28 +02:00
|
|
|
# This used to happen in AndroidConfig.h, which was included everywhere.
|
|
|
|
# TODO: can we remove this now?
|
2015-03-17 22:42:11 +01:00
|
|
|
CLANG_CONFIG_EXTRA_CFLAGS += \
|
|
|
|
-Wno-reserved-id-macro
|
|
|
|
|
2015-04-10 18:06:12 +02:00
|
|
|
# Disable overly aggressive warning for format strings.
|
|
|
|
# Bug: 20148343
|
|
|
|
CLANG_CONFIG_EXTRA_CFLAGS += \
|
|
|
|
-Wno-format-pedantic
|
|
|
|
|
2014-10-18 00:07:24 +02:00
|
|
|
# Workaround for ccache with clang.
|
|
|
|
# See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
|
|
|
|
CLANG_CONFIG_EXTRA_CFLAGS += \
|
2014-11-04 08:39:49 +01:00
|
|
|
-Wno-unused-command-line-argument
|
2014-10-18 00:07:24 +02:00
|
|
|
|
2014-11-26 09:57:34 +01:00
|
|
|
# Disable -Winconsistent-missing-override until we can clean up the existing
|
|
|
|
# codebase for it.
|
|
|
|
CLANG_CONFIG_EXTRA_CPPFLAGS += \
|
|
|
|
-Wno-inconsistent-missing-override
|
|
|
|
|
2015-09-25 07:14:25 +02:00
|
|
|
# Force clang to always output color diagnostics. Ninja will strip the ANSI
|
|
|
|
# color codes if it is not running in a terminal.
|
|
|
|
CLANG_CONFIG_EXTRA_CFLAGS += \
|
|
|
|
-fcolor-diagnostics
|
|
|
|
|
2014-02-07 03:08:44 +01:00
|
|
|
CLANG_CONFIG_UNKNOWN_CFLAGS := \
|
2014-11-26 09:57:34 +01:00
|
|
|
-finline-functions \
|
2014-05-12 16:05:14 +02:00
|
|
|
-finline-limit=64 \
|
2014-08-27 01:37:00 +02:00
|
|
|
-fno-canonical-system-headers \
|
2015-05-01 23:53:59 +02:00
|
|
|
-Wno-clobbered \
|
|
|
|
-fno-devirtualize \
|
2014-08-27 01:37:00 +02:00
|
|
|
-fno-tree-sra \
|
2015-03-06 01:02:04 +01:00
|
|
|
-fprefetch-loop-arrays \
|
2014-08-27 01:37:00 +02:00
|
|
|
-funswitch-loops \
|
2015-03-19 23:17:06 +01:00
|
|
|
-Werror=unused-but-set-parameter \
|
2015-04-03 16:43:46 +02:00
|
|
|
-Werror=unused-but-set-variable \
|
2014-08-27 01:37:00 +02:00
|
|
|
-Wmaybe-uninitialized \
|
2015-05-01 23:53:59 +02:00
|
|
|
-Wno-error=clobbered \
|
2014-08-27 01:37:00 +02:00
|
|
|
-Wno-error=maybe-uninitialized \
|
2015-03-19 23:17:06 +01:00
|
|
|
-Wno-error=unused-but-set-parameter \
|
2015-04-02 23:42:20 +02:00
|
|
|
-Wno-error=unused-but-set-variable \
|
2014-10-24 01:39:09 +02:00
|
|
|
-Wno-free-nonheap-object \
|
2014-08-27 01:37:00 +02:00
|
|
|
-Wno-literal-suffix \
|
|
|
|
-Wno-maybe-uninitialized \
|
|
|
|
-Wno-old-style-declaration \
|
2014-02-07 03:08:44 +01:00
|
|
|
-Wno-psabi \
|
2014-05-09 08:13:13 +02:00
|
|
|
-Wno-unused-but-set-parameter \
|
2015-04-02 23:42:20 +02:00
|
|
|
-Wno-unused-but-set-variable \
|
|
|
|
-Wno-unused-local-typedefs \
|
|
|
|
-Wunused-but-set-parameter \
|
2015-09-25 07:14:25 +02:00
|
|
|
-Wunused-but-set-variable \
|
2015-10-15 01:44:53 +02:00
|
|
|
-fdiagnostics-color \
|
|
|
|
-fdebug-prefix-map=/proc/self/cwd=
|
2014-02-07 03:08:44 +01:00
|
|
|
|
|
|
|
# Clang flags for all host rules
|
2014-04-21 23:00:31 +02:00
|
|
|
CLANG_CONFIG_HOST_EXTRA_ASFLAGS :=
|
|
|
|
CLANG_CONFIG_HOST_EXTRA_CFLAGS :=
|
|
|
|
CLANG_CONFIG_HOST_EXTRA_CPPFLAGS :=
|
|
|
|
CLANG_CONFIG_HOST_EXTRA_LDFLAGS :=
|
2014-02-07 03:08:44 +01:00
|
|
|
|
2015-08-14 21:59:50 +02:00
|
|
|
# Clang flags for all host cross rules
|
|
|
|
CLANG_CONFIG_HOST_CROSS_EXTRA_ASFLAGS :=
|
|
|
|
CLANG_CONFIG_HOST_CROSS_EXTRA_CFLAGS :=
|
|
|
|
CLANG_CONFIG_HOST_CROSS_EXTRA_CPPFLAGS :=
|
|
|
|
CLANG_CONFIG_HOST_CROSS_EXTRA_LDFLAGS :=
|
|
|
|
|
2014-02-07 03:08:44 +01:00
|
|
|
# Clang flags for all target rules
|
|
|
|
CLANG_CONFIG_TARGET_EXTRA_ASFLAGS :=
|
|
|
|
CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc
|
|
|
|
CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc
|
|
|
|
CLANG_CONFIG_TARGET_EXTRA_LDFLAGS :=
|
|
|
|
|
2015-04-17 03:07:07 +02:00
|
|
|
CLANG_DEFAULT_UB_CHECKS := \
|
|
|
|
bool \
|
|
|
|
integer-divide-by-zero \
|
|
|
|
return \
|
|
|
|
returns-nonnull-attribute \
|
|
|
|
shift-exponent \
|
|
|
|
unreachable \
|
|
|
|
vla-bound \
|
|
|
|
|
|
|
|
# TODO(danalbert): The following checks currently have compiler performance
|
|
|
|
# issues.
|
|
|
|
# CLANG_DEFAULT_UB_CHECKS += alignment
|
|
|
|
# CLANG_DEFAULT_UB_CHECKS += bounds
|
|
|
|
# CLANG_DEFAULT_UB_CHECKS += enum
|
|
|
|
# CLANG_DEFAULT_UB_CHECKS += float-cast-overflow
|
|
|
|
# CLANG_DEFAULT_UB_CHECKS += float-divide-by-zero
|
|
|
|
# CLANG_DEFAULT_UB_CHECKS += nonnull-attribute
|
|
|
|
# CLANG_DEFAULT_UB_CHECKS += null
|
|
|
|
# CLANG_DEFAULT_UB_CHECKS += shift-base
|
|
|
|
# CLANG_DEFAULT_UB_CHECKS += signed-integer-overflow
|
|
|
|
|
|
|
|
# TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on.
|
|
|
|
# https://llvm.org/PR19302
|
|
|
|
# http://reviews.llvm.org/D6974
|
|
|
|
# CLANG_DEFAULT_UB_CHECKS += object-size
|
|
|
|
|
2014-02-07 03:08:44 +01:00
|
|
|
# HOST config
|
2014-04-17 19:03:35 +02:00
|
|
|
clang_2nd_arch_prefix :=
|
2014-02-07 03:08:44 +01:00
|
|
|
include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk
|
2014-04-17 19:03:35 +02:00
|
|
|
|
|
|
|
# HOST_2ND_ARCH config
|
|
|
|
ifdef HOST_2ND_ARCH
|
|
|
|
clang_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX)
|
|
|
|
include $(BUILD_SYSTEM)/clang/HOST_$(HOST_2ND_ARCH).mk
|
2014-03-20 21:48:35 +01:00
|
|
|
endif
|
2014-02-07 03:08:44 +01:00
|
|
|
|
2015-08-14 21:59:50 +02:00
|
|
|
ifdef HOST_CROSS_OS
|
|
|
|
include $(BUILD_SYSTEM)/clang/HOST_CROSS_$(HOST_CROSS_OS).mk
|
|
|
|
endif
|
|
|
|
|
2014-02-07 03:08:44 +01:00
|
|
|
# TARGET config
|
|
|
|
clang_2nd_arch_prefix :=
|
|
|
|
include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk
|
|
|
|
|
|
|
|
# TARGET_2ND_ARCH config
|
|
|
|
ifdef TARGET_2ND_ARCH
|
|
|
|
clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
|
|
|
|
include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk
|
|
|
|
endif
|
|
|
|
|
2014-12-12 03:56:26 +01:00
|
|
|
ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fno-omit-frame-pointer
|
2014-02-07 03:08:44 +01:00
|
|
|
ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
|
2014-10-20 20:37:18 +02:00
|
|
|
|
2015-06-17 08:27:34 +02:00
|
|
|
ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES :=
|
2014-11-15 02:15:00 +01:00
|
|
|
ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
|
2014-02-07 03:08:44 +01:00
|
|
|
|
|
|
|
# This allows us to use the superset of functionality that compiler-rt
|
|
|
|
# provides to Clang (for supporting features like -ftrapv).
|
|
|
|
COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras
|
2014-11-06 23:11:33 +01:00
|
|
|
|
|
|
|
ifeq ($(HOST_PREFER_32_BIT),true)
|
|
|
|
# We don't have 32-bit prebuilt libLLVM/libclang, so force to build them from source.
|
|
|
|
FORCE_BUILD_LLVM_COMPONENTS := true
|
|
|
|
endif
|