blob: e0d9b2c9b524a40da44b4701f6a8577e4f541d57 [file] [log] [blame]
Ying Wangba8b3772014-03-10 18:23:08 -07001## 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
Stephen Hines433f1612014-11-26 00:57:34 -08009LLVM_PREBUILTS_VERSION := 3.6
Lai Wei-Chih8affa162014-09-17 13:55:08 +080010LLVM_PREBUILTS_PATH := prebuilts/clang/$(BUILD_OS)-x86/host/$(LLVM_PREBUILTS_VERSION)/bin
Dan Albert343ed672015-01-25 16:20:57 -080011LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_PATH)/../lib/clang/$(LLVM_PREBUILTS_VERSION)/lib/linux/
Ying Wang1f982832014-02-06 18:08:44 -080012
Stephen Hines7bc754b2014-02-19 09:03:00 -080013CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX)
14CLANG_CXX := $(LLVM_PREBUILTS_PATH)/clang++$(BUILD_EXECUTABLE_SUFFIX)
Stephen Hines7bc754b2014-02-19 09:03:00 -080015LLVM_AS := $(LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX)
16LLVM_LINK := $(LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX)
Tim Murray75b58cc2014-04-30 13:54:32 -070017
Stephen Hinesb34b7ae2014-09-30 02:37:20 -070018CLANG_TBLGEN := $(BUILD_OUT_EXECUTABLES)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX)
19LLVM_TBLGEN := $(BUILD_OUT_EXECUTABLES)/llvm-tblgen$(BUILD_EXECUTABLE_SUFFIX)
Stephen Hines7bc754b2014-02-19 09:03:00 -080020
Ying Wang1b0fc432014-07-29 14:08:33 -070021# 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
Ying Wang1f982832014-02-06 18:08:44 -080032
33# Clang flags for all host or target rules
34CLANG_CONFIG_EXTRA_ASFLAGS :=
35CLANG_CONFIG_EXTRA_CFLAGS :=
Stephen Hines433f1612014-11-26 00:57:34 -080036CLANG_CONFIG_EXTRA_CONLYFLAGS := -std=gnu99
Ying Wang1f982832014-02-06 18:08:44 -080037CLANG_CONFIG_EXTRA_CPPFLAGS :=
38CLANG_CONFIG_EXTRA_LDFLAGS :=
39
Brian Carlstrom338d1e72014-06-17 14:36:05 -070040CLANG_CONFIG_EXTRA_CFLAGS += \
Ying Wang1f982832014-02-06 18:08:44 -080041 -D__compiler_offsetof=__builtin_offsetof
42
Brian Carlstrom338d1e72014-06-17 14:36:05 -070043# Help catch common 32/64-bit errors.
44CLANG_CONFIG_EXTRA_CFLAGS += \
45 -Werror=int-conversion
46
Stephen Hinesf6800212015-03-17 14:42:11 -070047# 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
Ying Wang24e03362014-10-17 15:07:24 -070052# Workaround for ccache with clang.
53# See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
54CLANG_CONFIG_EXTRA_CFLAGS += \
Stephen Hinesc141b852014-11-03 23:39:49 -080055 -Wno-unused-command-line-argument
Ying Wang24e03362014-10-17 15:07:24 -070056
Stephen Hines433f1612014-11-26 00:57:34 -080057# 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
Ying Wang1f982832014-02-06 18:08:44 -080062CLANG_CONFIG_UNKNOWN_CFLAGS := \
Stephen Hines433f1612014-11-26 00:57:34 -080063 -finline-functions \
Bernhard Rosenkraenzerd6e11822014-05-12 16:05:14 +020064 -finline-limit=64 \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070065 -fno-canonical-system-headers \
66 -fno-tree-sra \
Chih-Hung Hsieh78df8322015-03-05 16:02:04 -080067 -fprefetch-loop-arrays \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070068 -funswitch-loops \
Chih-Hung Hsieh7e44d7f2015-03-19 15:17:06 -070069 -Werror=unused-but-set-parameter \
Elliott Hughes3101e612015-04-03 07:43:46 -070070 -Werror=unused-but-set-variable \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070071 -Wmaybe-uninitialized \
72 -Wno-error=maybe-uninitialized \
Chih-Hung Hsieh7e44d7f2015-03-19 15:17:06 -070073 -Wno-error=unused-but-set-parameter \
Chih-Hung Hsieh9205bc12015-04-02 14:42:20 -070074 -Wno-error=unused-but-set-variable \
Chih-Hung Hsieh22b6c5c2014-10-23 16:39:09 -070075 -Wno-free-nonheap-object \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070076 -Wno-literal-suffix \
77 -Wno-maybe-uninitialized \
78 -Wno-old-style-declaration \
Ying Wang1f982832014-02-06 18:08:44 -080079 -Wno-psabi \
Andrew Hsieh48f239c2014-05-09 14:13:13 +080080 -Wno-unused-but-set-parameter \
Chih-Hung Hsieh9205bc12015-04-02 14:42:20 -070081 -Wno-unused-but-set-variable \
82 -Wno-unused-local-typedefs \
83 -Wunused-but-set-parameter \
84 -Wunused-but-set-variable
Ying Wang1f982832014-02-06 18:08:44 -080085
86# Clang flags for all host rules
Tim Murrayd318ba62014-04-21 14:00:31 -070087CLANG_CONFIG_HOST_EXTRA_ASFLAGS :=
88CLANG_CONFIG_HOST_EXTRA_CFLAGS :=
89CLANG_CONFIG_HOST_EXTRA_CPPFLAGS :=
90CLANG_CONFIG_HOST_EXTRA_LDFLAGS :=
Ying Wang1f982832014-02-06 18:08:44 -080091
92# Clang flags for all target rules
93CLANG_CONFIG_TARGET_EXTRA_ASFLAGS :=
94CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc
95CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc
96CLANG_CONFIG_TARGET_EXTRA_LDFLAGS :=
97
98# HOST config
Ying Wang6feb6d52014-04-17 10:03:35 -070099clang_2nd_arch_prefix :=
Ying Wang1f982832014-02-06 18:08:44 -0800100include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk
Ying Wang6feb6d52014-04-17 10:03:35 -0700101
102# HOST_2ND_ARCH config
103ifdef HOST_2ND_ARCH
104clang_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX)
105include $(BUILD_SYSTEM)/clang/HOST_$(HOST_2ND_ARCH).mk
Tim Murray02cefc92014-03-20 13:48:35 -0700106endif
Ying Wang1f982832014-02-06 18:08:44 -0800107
108# TARGET config
109clang_2nd_arch_prefix :=
110include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk
111
112# TARGET_2ND_ARCH config
113ifdef TARGET_2ND_ARCH
114clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
115include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk
116endif
117
Ying Wang1f982832014-02-06 18:08:44 -0800118# Address sanitizer clang config
Evgeniy Stepanov5d8029f2014-02-21 18:10:53 +0400119ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan_$(TARGET_ARCH)_android
120ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address -fno-omit-frame-pointer
Ying Wang1f982832014-02-06 18:08:44 -0800121ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
Dan Albert2daceaa2014-10-20 11:37:18 -0700122
Dan Albertb58fb4a2014-11-14 17:15:00 -0800123ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl $(ADDRESS_SANITIZER_RUNTIME_LIBRARY)
124ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
Ying Wang1f982832014-02-06 18:08:44 -0800125
126# This allows us to use the superset of functionality that compiler-rt
127# provides to Clang (for supporting features like -ftrapv).
128COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras
Ying Wange5d4e742014-11-06 14:11:33 -0800129
130ifeq ($(HOST_PREFER_32_BIT),true)
131# We don't have 32-bit prebuilt libLLVM/libclang, so force to build them from source.
132FORCE_BUILD_LLVM_COMPONENTS := true
133endif