blob: 6df3e178cfac72d59b662151f459dfe960603045 [file] [log] [blame]
Ying Wangba8b3772014-03-10 18:23:08 -07001## Clang configurations.
2
Dan Albert2d6d5c62015-11-18 18:00:40 -08003LLVM_PREBUILTS_VERSION ?= 3.8
4LLVM_PREBUILTS_BASE ?= prebuilts/clang/host
Dan Albert8b1d1772015-11-13 23:06:07 -08005LLVM_PREBUILTS_PATH := $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/bin
Dan Albert343ed672015-01-25 16:20:57 -08006LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_PATH)/../lib/clang/$(LLVM_PREBUILTS_VERSION)/lib/linux/
Ying Wang1f982832014-02-06 18:08:44 -08007
Stephen Hines7bc754b2014-02-19 09:03:00 -08008CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX)
9CLANG_CXX := $(LLVM_PREBUILTS_PATH)/clang++$(BUILD_EXECUTABLE_SUFFIX)
Stephen Hines7bc754b2014-02-19 09:03:00 -080010LLVM_AS := $(LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX)
11LLVM_LINK := $(LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX)
Tim Murray75b58cc2014-04-30 13:54:32 -070012
Stephen Hinesb34b7ae2014-09-30 02:37:20 -070013CLANG_TBLGEN := $(BUILD_OUT_EXECUTABLES)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX)
14LLVM_TBLGEN := $(BUILD_OUT_EXECUTABLES)/llvm-tblgen$(BUILD_EXECUTABLE_SUFFIX)
Stephen Hines7bc754b2014-02-19 09:03:00 -080015
Stephen Hines96d2a8c2016-01-21 23:50:53 -080016# RenderScript-specific tools
17# These are tied to the version of LLVM directly in external/, so they might
18# trail the host prebuilts being used for the rest of the build process.
19RS_LLVM_PREBUILTS_VERSION := 3.8
20RS_LLVM_PREBUILTS_BASE := prebuilts/clang/host
21RS_LLVM_PREBUILTS_PATH := $(RS_LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(RS_LLVM_PREBUILTS_VERSION)/bin
Stephen Hines49b69532016-01-22 15:11:34 -080022RS_CLANG := $(RS_LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX)
Stephen Hines96d2a8c2016-01-21 23:50:53 -080023RS_LLVM_AS := $(RS_LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX)
24RS_LLVM_LINK := $(RS_LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX)
25
Ying Wang1f982832014-02-06 18:08:44 -080026# Clang flags for all host or target rules
27CLANG_CONFIG_EXTRA_ASFLAGS :=
28CLANG_CONFIG_EXTRA_CFLAGS :=
Stephen Hines433f1612014-11-26 00:57:34 -080029CLANG_CONFIG_EXTRA_CONLYFLAGS := -std=gnu99
Ying Wang1f982832014-02-06 18:08:44 -080030CLANG_CONFIG_EXTRA_CPPFLAGS :=
31CLANG_CONFIG_EXTRA_LDFLAGS :=
32
Brian Carlstrom338d1e72014-06-17 14:36:05 -070033CLANG_CONFIG_EXTRA_CFLAGS += \
Ying Wang1f982832014-02-06 18:08:44 -080034 -D__compiler_offsetof=__builtin_offsetof
35
Brian Carlstrom338d1e72014-06-17 14:36:05 -070036# Help catch common 32/64-bit errors.
37CLANG_CONFIG_EXTRA_CFLAGS += \
38 -Werror=int-conversion
39
Stephen Hinesf6800212015-03-17 14:42:11 -070040# Disable overly aggressive warning for macros defined with a leading underscore
Elliott Hughes43146112015-08-28 10:31:28 -070041# This used to happen in AndroidConfig.h, which was included everywhere.
42# TODO: can we remove this now?
Stephen Hinesf6800212015-03-17 14:42:11 -070043CLANG_CONFIG_EXTRA_CFLAGS += \
44 -Wno-reserved-id-macro
45
Stephen Hinesb992bfc2015-04-10 09:06:12 -070046# Disable overly aggressive warning for format strings.
47# Bug: 20148343
48CLANG_CONFIG_EXTRA_CFLAGS += \
49 -Wno-format-pedantic
50
Ying Wang24e03362014-10-17 15:07:24 -070051# Workaround for ccache with clang.
52# See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
53CLANG_CONFIG_EXTRA_CFLAGS += \
Stephen Hinesc141b852014-11-03 23:39:49 -080054 -Wno-unused-command-line-argument
Ying Wang24e03362014-10-17 15:07:24 -070055
Stephen Hines433f1612014-11-26 00:57:34 -080056# Disable -Winconsistent-missing-override until we can clean up the existing
57# codebase for it.
58CLANG_CONFIG_EXTRA_CPPFLAGS += \
59 -Wno-inconsistent-missing-override
60
Colin Cross63e3b022015-09-24 22:14:25 -070061# Force clang to always output color diagnostics. Ninja will strip the ANSI
62# color codes if it is not running in a terminal.
63CLANG_CONFIG_EXTRA_CFLAGS += \
64 -fcolor-diagnostics
65
Ying Wang1f982832014-02-06 18:08:44 -080066CLANG_CONFIG_UNKNOWN_CFLAGS := \
Stephen Hines433f1612014-11-26 00:57:34 -080067 -finline-functions \
Bernhard Rosenkraenzerd6e11822014-05-12 16:05:14 +020068 -finline-limit=64 \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070069 -fno-canonical-system-headers \
Chih-Hung Hsieh0ba68ba2015-05-01 14:53:59 -070070 -Wno-clobbered \
71 -fno-devirtualize \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070072 -fno-tree-sra \
Chih-Hung Hsieh78df8322015-03-05 16:02:04 -080073 -fprefetch-loop-arrays \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070074 -funswitch-loops \
Chih-Hung Hsieh7e44d7f2015-03-19 15:17:06 -070075 -Werror=unused-but-set-parameter \
Elliott Hughes3101e612015-04-03 07:43:46 -070076 -Werror=unused-but-set-variable \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070077 -Wmaybe-uninitialized \
Chih-Hung Hsieh0ba68ba2015-05-01 14:53:59 -070078 -Wno-error=clobbered \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070079 -Wno-error=maybe-uninitialized \
Chih-Hung Hsieh7e44d7f2015-03-19 15:17:06 -070080 -Wno-error=unused-but-set-parameter \
Chih-Hung Hsieh9205bc12015-04-02 14:42:20 -070081 -Wno-error=unused-but-set-variable \
Chih-Hung Hsieh22b6c5c2014-10-23 16:39:09 -070082 -Wno-free-nonheap-object \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070083 -Wno-literal-suffix \
84 -Wno-maybe-uninitialized \
85 -Wno-old-style-declaration \
Ying Wang1f982832014-02-06 18:08:44 -080086 -Wno-psabi \
Andrew Hsieh48f239c2014-05-09 14:13:13 +080087 -Wno-unused-but-set-parameter \
Chih-Hung Hsieh9205bc12015-04-02 14:42:20 -070088 -Wno-unused-but-set-variable \
89 -Wno-unused-local-typedefs \
90 -Wunused-but-set-parameter \
Colin Cross63e3b022015-09-24 22:14:25 -070091 -Wunused-but-set-variable \
Dan Willemsen6a66a882015-10-14 16:44:53 -070092 -fdiagnostics-color \
93 -fdebug-prefix-map=/proc/self/cwd=
Ying Wang1f982832014-02-06 18:08:44 -080094
95# Clang flags for all host rules
Tim Murrayd318ba62014-04-21 14:00:31 -070096CLANG_CONFIG_HOST_EXTRA_ASFLAGS :=
97CLANG_CONFIG_HOST_EXTRA_CFLAGS :=
98CLANG_CONFIG_HOST_EXTRA_CPPFLAGS :=
99CLANG_CONFIG_HOST_EXTRA_LDFLAGS :=
Ying Wang1f982832014-02-06 18:08:44 -0800100
Dan Willemsen057aaea2015-08-14 12:59:50 -0700101# Clang flags for all host cross rules
102CLANG_CONFIG_HOST_CROSS_EXTRA_ASFLAGS :=
103CLANG_CONFIG_HOST_CROSS_EXTRA_CFLAGS :=
104CLANG_CONFIG_HOST_CROSS_EXTRA_CPPFLAGS :=
105CLANG_CONFIG_HOST_CROSS_EXTRA_LDFLAGS :=
106
Ying Wang1f982832014-02-06 18:08:44 -0800107# Clang flags for all target rules
108CLANG_CONFIG_TARGET_EXTRA_ASFLAGS :=
109CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc
110CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc
111CLANG_CONFIG_TARGET_EXTRA_LDFLAGS :=
112
Dan Albertb5b2ffe2015-04-16 18:07:07 -0700113CLANG_DEFAULT_UB_CHECKS := \
114 bool \
115 integer-divide-by-zero \
116 return \
117 returns-nonnull-attribute \
118 shift-exponent \
119 unreachable \
120 vla-bound \
121
122# TODO(danalbert): The following checks currently have compiler performance
123# issues.
124# CLANG_DEFAULT_UB_CHECKS += alignment
125# CLANG_DEFAULT_UB_CHECKS += bounds
126# CLANG_DEFAULT_UB_CHECKS += enum
127# CLANG_DEFAULT_UB_CHECKS += float-cast-overflow
128# CLANG_DEFAULT_UB_CHECKS += float-divide-by-zero
129# CLANG_DEFAULT_UB_CHECKS += nonnull-attribute
130# CLANG_DEFAULT_UB_CHECKS += null
131# CLANG_DEFAULT_UB_CHECKS += shift-base
132# CLANG_DEFAULT_UB_CHECKS += signed-integer-overflow
133
134# TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on.
135# https://llvm.org/PR19302
136# http://reviews.llvm.org/D6974
137# CLANG_DEFAULT_UB_CHECKS += object-size
138
Ying Wang1f982832014-02-06 18:08:44 -0800139# HOST config
Ying Wang6feb6d52014-04-17 10:03:35 -0700140clang_2nd_arch_prefix :=
Ying Wang1f982832014-02-06 18:08:44 -0800141include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk
Ying Wang6feb6d52014-04-17 10:03:35 -0700142
143# HOST_2ND_ARCH config
144ifdef HOST_2ND_ARCH
145clang_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX)
146include $(BUILD_SYSTEM)/clang/HOST_$(HOST_2ND_ARCH).mk
Tim Murray02cefc92014-03-20 13:48:35 -0700147endif
Ying Wang1f982832014-02-06 18:08:44 -0800148
Dan Willemsen057aaea2015-08-14 12:59:50 -0700149ifdef HOST_CROSS_OS
150include $(BUILD_SYSTEM)/clang/HOST_CROSS_$(HOST_CROSS_OS).mk
151endif
152
Ying Wang1f982832014-02-06 18:08:44 -0800153# TARGET config
154clang_2nd_arch_prefix :=
155include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk
156
157# TARGET_2ND_ARCH config
158ifdef TARGET_2ND_ARCH
159clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
160include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk
161endif
162
Dan Albert08cca282014-12-11 18:56:26 -0800163ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fno-omit-frame-pointer
Ying Wang1f982832014-02-06 18:08:44 -0800164ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
Dan Albert2daceaa2014-10-20 11:37:18 -0700165
Dan Albertabf4bc92015-06-16 23:27:34 -0700166ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES :=
Dan Albertb58fb4a2014-11-14 17:15:00 -0800167ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
Ying Wang1f982832014-02-06 18:08:44 -0800168
169# This allows us to use the superset of functionality that compiler-rt
170# provides to Clang (for supporting features like -ftrapv).
171COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras
Ying Wange5d4e742014-11-06 14:11:33 -0800172
173ifeq ($(HOST_PREFER_32_BIT),true)
174# We don't have 32-bit prebuilt libLLVM/libclang, so force to build them from source.
175FORCE_BUILD_LLVM_COMPONENTS := true
176endif