blob: 03d773054b6c74156e723f986a81c8072867b464 [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 Wang1f982832014-02-06 18:08:44 -080021# Clang flags for all host or target rules
22CLANG_CONFIG_EXTRA_ASFLAGS :=
23CLANG_CONFIG_EXTRA_CFLAGS :=
Stephen Hines433f1612014-11-26 00:57:34 -080024CLANG_CONFIG_EXTRA_CONLYFLAGS := -std=gnu99
Ying Wang1f982832014-02-06 18:08:44 -080025CLANG_CONFIG_EXTRA_CPPFLAGS :=
26CLANG_CONFIG_EXTRA_LDFLAGS :=
27
Brian Carlstrom338d1e72014-06-17 14:36:05 -070028CLANG_CONFIG_EXTRA_CFLAGS += \
Ying Wang1f982832014-02-06 18:08:44 -080029 -D__compiler_offsetof=__builtin_offsetof
30
Brian Carlstrom338d1e72014-06-17 14:36:05 -070031# Help catch common 32/64-bit errors.
32CLANG_CONFIG_EXTRA_CFLAGS += \
33 -Werror=int-conversion
34
Stephen Hinesf6800212015-03-17 14:42:11 -070035# Disable overly aggressive warning for macros defined with a leading underscore
Elliott Hughes43146112015-08-28 10:31:28 -070036# This used to happen in AndroidConfig.h, which was included everywhere.
37# TODO: can we remove this now?
Stephen Hinesf6800212015-03-17 14:42:11 -070038CLANG_CONFIG_EXTRA_CFLAGS += \
39 -Wno-reserved-id-macro
40
Stephen Hinesb992bfc2015-04-10 09:06:12 -070041# Disable overly aggressive warning for format strings.
42# Bug: 20148343
43CLANG_CONFIG_EXTRA_CFLAGS += \
44 -Wno-format-pedantic
45
Ying Wang24e03362014-10-17 15:07:24 -070046# Workaround for ccache with clang.
47# See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
48CLANG_CONFIG_EXTRA_CFLAGS += \
Stephen Hinesc141b852014-11-03 23:39:49 -080049 -Wno-unused-command-line-argument
Ying Wang24e03362014-10-17 15:07:24 -070050
Stephen Hines433f1612014-11-26 00:57:34 -080051# Disable -Winconsistent-missing-override until we can clean up the existing
52# codebase for it.
53CLANG_CONFIG_EXTRA_CPPFLAGS += \
54 -Wno-inconsistent-missing-override
55
Ying Wang1f982832014-02-06 18:08:44 -080056CLANG_CONFIG_UNKNOWN_CFLAGS := \
Stephen Hines433f1612014-11-26 00:57:34 -080057 -finline-functions \
Bernhard Rosenkraenzerd6e11822014-05-12 16:05:14 +020058 -finline-limit=64 \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070059 -fno-canonical-system-headers \
Chih-Hung Hsieh90036612015-05-01 14:53:59 -070060 -Wno-clobbered \
61 -fno-devirtualize \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070062 -fno-tree-sra \
Chih-Hung Hsieh78df8322015-03-05 16:02:04 -080063 -fprefetch-loop-arrays \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070064 -funswitch-loops \
65 -Wmaybe-uninitialized \
Chih-Hung Hsieh90036612015-05-01 14:53:59 -070066 -Wno-error=clobbered \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070067 -Wno-error=maybe-uninitialized \
Chih-Hung Hsieh9205bc12015-04-02 14:42:20 -070068 -Wno-error=unused-but-set-parameter \
69 -Wno-error=unused-but-set-variable \
Chih-Hung Hsieh22b6c5c2014-10-23 16:39:09 -070070 -Wno-free-nonheap-object \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070071 -Wno-literal-suffix \
72 -Wno-maybe-uninitialized \
73 -Wno-old-style-declaration \
Ying Wang1f982832014-02-06 18:08:44 -080074 -Wno-psabi \
Andrew Hsieh48f239c2014-05-09 14:13:13 +080075 -Wno-unused-but-set-parameter \
Chih-Hung Hsieh9205bc12015-04-02 14:42:20 -070076 -Wno-unused-but-set-variable \
77 -Wno-unused-local-typedefs \
78 -Wunused-but-set-parameter \
79 -Wunused-but-set-variable
Ying Wang1f982832014-02-06 18:08:44 -080080
81# Clang flags for all host rules
Tim Murrayd318ba62014-04-21 14:00:31 -070082CLANG_CONFIG_HOST_EXTRA_ASFLAGS :=
83CLANG_CONFIG_HOST_EXTRA_CFLAGS :=
84CLANG_CONFIG_HOST_EXTRA_CPPFLAGS :=
85CLANG_CONFIG_HOST_EXTRA_LDFLAGS :=
Ying Wang1f982832014-02-06 18:08:44 -080086
Dan Willemsen057aaea2015-08-14 12:59:50 -070087# Clang flags for all host cross rules
88CLANG_CONFIG_HOST_CROSS_EXTRA_ASFLAGS :=
89CLANG_CONFIG_HOST_CROSS_EXTRA_CFLAGS :=
90CLANG_CONFIG_HOST_CROSS_EXTRA_CPPFLAGS :=
91CLANG_CONFIG_HOST_CROSS_EXTRA_LDFLAGS :=
92
Ying Wang1f982832014-02-06 18:08:44 -080093# Clang flags for all target rules
94CLANG_CONFIG_TARGET_EXTRA_ASFLAGS :=
95CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc
96CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc
97CLANG_CONFIG_TARGET_EXTRA_LDFLAGS :=
98
Dan Albertb5b2ffe2015-04-16 18:07:07 -070099CLANG_DEFAULT_UB_CHECKS := \
100 bool \
101 integer-divide-by-zero \
102 return \
103 returns-nonnull-attribute \
104 shift-exponent \
105 unreachable \
106 vla-bound \
107
108# TODO(danalbert): The following checks currently have compiler performance
109# issues.
110# CLANG_DEFAULT_UB_CHECKS += alignment
111# CLANG_DEFAULT_UB_CHECKS += bounds
112# CLANG_DEFAULT_UB_CHECKS += enum
113# CLANG_DEFAULT_UB_CHECKS += float-cast-overflow
114# CLANG_DEFAULT_UB_CHECKS += float-divide-by-zero
115# CLANG_DEFAULT_UB_CHECKS += nonnull-attribute
116# CLANG_DEFAULT_UB_CHECKS += null
117# CLANG_DEFAULT_UB_CHECKS += shift-base
118# CLANG_DEFAULT_UB_CHECKS += signed-integer-overflow
119
120# TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on.
121# https://llvm.org/PR19302
122# http://reviews.llvm.org/D6974
123# CLANG_DEFAULT_UB_CHECKS += object-size
124
Ying Wang1f982832014-02-06 18:08:44 -0800125# HOST config
Ying Wang6feb6d52014-04-17 10:03:35 -0700126clang_2nd_arch_prefix :=
Ying Wang1f982832014-02-06 18:08:44 -0800127include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk
Ying Wang6feb6d52014-04-17 10:03:35 -0700128
129# HOST_2ND_ARCH config
130ifdef HOST_2ND_ARCH
131clang_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX)
132include $(BUILD_SYSTEM)/clang/HOST_$(HOST_2ND_ARCH).mk
Tim Murray02cefc92014-03-20 13:48:35 -0700133endif
Ying Wang1f982832014-02-06 18:08:44 -0800134
Dan Willemsen057aaea2015-08-14 12:59:50 -0700135ifdef HOST_CROSS_OS
136include $(BUILD_SYSTEM)/clang/HOST_CROSS_$(HOST_CROSS_OS).mk
137endif
138
Ying Wang1f982832014-02-06 18:08:44 -0800139# TARGET config
140clang_2nd_arch_prefix :=
141include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk
142
143# TARGET_2ND_ARCH config
144ifdef TARGET_2ND_ARCH
145clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
146include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk
147endif
148
Dan Albert08cca282014-12-11 18:56:26 -0800149ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fno-omit-frame-pointer
Ying Wang1f982832014-02-06 18:08:44 -0800150ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
Dan Albert2daceaa2014-10-20 11:37:18 -0700151
Dan Albertabf4bc92015-06-16 23:27:34 -0700152ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES :=
Dan Albertb58fb4a2014-11-14 17:15:00 -0800153ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
Ying Wang1f982832014-02-06 18:08:44 -0800154
155# This allows us to use the superset of functionality that compiler-rt
156# provides to Clang (for supporting features like -ftrapv).
157COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras
Ying Wange5d4e742014-11-06 14:11:33 -0800158
159ifeq ($(HOST_PREFER_32_BIT),true)
160# We don't have 32-bit prebuilt libLLVM/libclang, so force to build them from source.
161FORCE_BUILD_LLVM_COMPONENTS := true
162endif