blob: 330fd1cecfd1d6e3af850aacf0580f56e914898c [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
22RS_LLVM_AS := $(RS_LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX)
23RS_LLVM_LINK := $(RS_LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX)
24
Ying Wang1f982832014-02-06 18:08:44 -080025# Clang flags for all host or target rules
26CLANG_CONFIG_EXTRA_ASFLAGS :=
27CLANG_CONFIG_EXTRA_CFLAGS :=
Stephen Hines433f1612014-11-26 00:57:34 -080028CLANG_CONFIG_EXTRA_CONLYFLAGS := -std=gnu99
Ying Wang1f982832014-02-06 18:08:44 -080029CLANG_CONFIG_EXTRA_CPPFLAGS :=
30CLANG_CONFIG_EXTRA_LDFLAGS :=
31
Brian Carlstrom338d1e72014-06-17 14:36:05 -070032CLANG_CONFIG_EXTRA_CFLAGS += \
Ying Wang1f982832014-02-06 18:08:44 -080033 -D__compiler_offsetof=__builtin_offsetof
34
Brian Carlstrom338d1e72014-06-17 14:36:05 -070035# Help catch common 32/64-bit errors.
36CLANG_CONFIG_EXTRA_CFLAGS += \
37 -Werror=int-conversion
38
Stephen Hinesf6800212015-03-17 14:42:11 -070039# Disable overly aggressive warning for macros defined with a leading underscore
Elliott Hughes43146112015-08-28 10:31:28 -070040# This used to happen in AndroidConfig.h, which was included everywhere.
41# TODO: can we remove this now?
Stephen Hinesf6800212015-03-17 14:42:11 -070042CLANG_CONFIG_EXTRA_CFLAGS += \
43 -Wno-reserved-id-macro
44
Stephen Hinesb992bfc2015-04-10 09:06:12 -070045# Disable overly aggressive warning for format strings.
46# Bug: 20148343
47CLANG_CONFIG_EXTRA_CFLAGS += \
48 -Wno-format-pedantic
49
Ying Wang24e03362014-10-17 15:07:24 -070050# Workaround for ccache with clang.
51# See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
52CLANG_CONFIG_EXTRA_CFLAGS += \
Stephen Hinesc141b852014-11-03 23:39:49 -080053 -Wno-unused-command-line-argument
Ying Wang24e03362014-10-17 15:07:24 -070054
Stephen Hines433f1612014-11-26 00:57:34 -080055# Disable -Winconsistent-missing-override until we can clean up the existing
56# codebase for it.
57CLANG_CONFIG_EXTRA_CPPFLAGS += \
58 -Wno-inconsistent-missing-override
59
Colin Cross63e3b022015-09-24 22:14:25 -070060# Force clang to always output color diagnostics. Ninja will strip the ANSI
61# color codes if it is not running in a terminal.
62CLANG_CONFIG_EXTRA_CFLAGS += \
63 -fcolor-diagnostics
64
Ying Wang1f982832014-02-06 18:08:44 -080065CLANG_CONFIG_UNKNOWN_CFLAGS := \
Stephen Hines433f1612014-11-26 00:57:34 -080066 -finline-functions \
Bernhard Rosenkraenzerd6e11822014-05-12 16:05:14 +020067 -finline-limit=64 \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070068 -fno-canonical-system-headers \
Chih-Hung Hsieh0ba68ba2015-05-01 14:53:59 -070069 -Wno-clobbered \
70 -fno-devirtualize \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070071 -fno-tree-sra \
Chih-Hung Hsieh78df8322015-03-05 16:02:04 -080072 -fprefetch-loop-arrays \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070073 -funswitch-loops \
Chih-Hung Hsieh7e44d7f2015-03-19 15:17:06 -070074 -Werror=unused-but-set-parameter \
Elliott Hughes3101e612015-04-03 07:43:46 -070075 -Werror=unused-but-set-variable \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070076 -Wmaybe-uninitialized \
Chih-Hung Hsieh0ba68ba2015-05-01 14:53:59 -070077 -Wno-error=clobbered \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070078 -Wno-error=maybe-uninitialized \
Chih-Hung Hsieh7e44d7f2015-03-19 15:17:06 -070079 -Wno-error=unused-but-set-parameter \
Chih-Hung Hsieh9205bc12015-04-02 14:42:20 -070080 -Wno-error=unused-but-set-variable \
Chih-Hung Hsieh22b6c5c2014-10-23 16:39:09 -070081 -Wno-free-nonheap-object \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070082 -Wno-literal-suffix \
83 -Wno-maybe-uninitialized \
84 -Wno-old-style-declaration \
Ying Wang1f982832014-02-06 18:08:44 -080085 -Wno-psabi \
Andrew Hsieh48f239c2014-05-09 14:13:13 +080086 -Wno-unused-but-set-parameter \
Chih-Hung Hsieh9205bc12015-04-02 14:42:20 -070087 -Wno-unused-but-set-variable \
88 -Wno-unused-local-typedefs \
89 -Wunused-but-set-parameter \
Colin Cross63e3b022015-09-24 22:14:25 -070090 -Wunused-but-set-variable \
Dan Willemsen6a66a882015-10-14 16:44:53 -070091 -fdiagnostics-color \
92 -fdebug-prefix-map=/proc/self/cwd=
Ying Wang1f982832014-02-06 18:08:44 -080093
94# Clang flags for all host rules
Tim Murrayd318ba62014-04-21 14:00:31 -070095CLANG_CONFIG_HOST_EXTRA_ASFLAGS :=
96CLANG_CONFIG_HOST_EXTRA_CFLAGS :=
97CLANG_CONFIG_HOST_EXTRA_CPPFLAGS :=
98CLANG_CONFIG_HOST_EXTRA_LDFLAGS :=
Ying Wang1f982832014-02-06 18:08:44 -080099
Dan Willemsen057aaea2015-08-14 12:59:50 -0700100# Clang flags for all host cross rules
101CLANG_CONFIG_HOST_CROSS_EXTRA_ASFLAGS :=
102CLANG_CONFIG_HOST_CROSS_EXTRA_CFLAGS :=
103CLANG_CONFIG_HOST_CROSS_EXTRA_CPPFLAGS :=
104CLANG_CONFIG_HOST_CROSS_EXTRA_LDFLAGS :=
105
Ying Wang1f982832014-02-06 18:08:44 -0800106# Clang flags for all target rules
107CLANG_CONFIG_TARGET_EXTRA_ASFLAGS :=
108CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc
109CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc
110CLANG_CONFIG_TARGET_EXTRA_LDFLAGS :=
111
Dan Albertb5b2ffe2015-04-16 18:07:07 -0700112CLANG_DEFAULT_UB_CHECKS := \
113 bool \
114 integer-divide-by-zero \
115 return \
116 returns-nonnull-attribute \
117 shift-exponent \
118 unreachable \
119 vla-bound \
120
121# TODO(danalbert): The following checks currently have compiler performance
122# issues.
123# CLANG_DEFAULT_UB_CHECKS += alignment
124# CLANG_DEFAULT_UB_CHECKS += bounds
125# CLANG_DEFAULT_UB_CHECKS += enum
126# CLANG_DEFAULT_UB_CHECKS += float-cast-overflow
127# CLANG_DEFAULT_UB_CHECKS += float-divide-by-zero
128# CLANG_DEFAULT_UB_CHECKS += nonnull-attribute
129# CLANG_DEFAULT_UB_CHECKS += null
130# CLANG_DEFAULT_UB_CHECKS += shift-base
131# CLANG_DEFAULT_UB_CHECKS += signed-integer-overflow
132
133# TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on.
134# https://llvm.org/PR19302
135# http://reviews.llvm.org/D6974
136# CLANG_DEFAULT_UB_CHECKS += object-size
137
Ying Wang1f982832014-02-06 18:08:44 -0800138# HOST config
Ying Wang6feb6d52014-04-17 10:03:35 -0700139clang_2nd_arch_prefix :=
Ying Wang1f982832014-02-06 18:08:44 -0800140include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk
Ying Wang6feb6d52014-04-17 10:03:35 -0700141
142# HOST_2ND_ARCH config
143ifdef HOST_2ND_ARCH
144clang_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX)
145include $(BUILD_SYSTEM)/clang/HOST_$(HOST_2ND_ARCH).mk
Tim Murray02cefc92014-03-20 13:48:35 -0700146endif
Ying Wang1f982832014-02-06 18:08:44 -0800147
Dan Willemsen057aaea2015-08-14 12:59:50 -0700148ifdef HOST_CROSS_OS
149include $(BUILD_SYSTEM)/clang/HOST_CROSS_$(HOST_CROSS_OS).mk
150endif
151
Ying Wang1f982832014-02-06 18:08:44 -0800152# TARGET config
153clang_2nd_arch_prefix :=
154include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk
155
156# TARGET_2ND_ARCH config
157ifdef TARGET_2ND_ARCH
158clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
159include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk
160endif
161
Dan Albert08cca282014-12-11 18:56:26 -0800162ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fno-omit-frame-pointer
Ying Wang1f982832014-02-06 18:08:44 -0800163ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
Dan Albert2daceaa2014-10-20 11:37:18 -0700164
Dan Albertabf4bc92015-06-16 23:27:34 -0700165ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES :=
Dan Albertb58fb4a2014-11-14 17:15:00 -0800166ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
Ying Wang1f982832014-02-06 18:08:44 -0800167
168# This allows us to use the superset of functionality that compiler-rt
169# provides to Clang (for supporting features like -ftrapv).
170COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras
Ying Wange5d4e742014-11-06 14:11:33 -0800171
172ifeq ($(HOST_PREFER_32_BIT),true)
173# We don't have 32-bit prebuilt libLLVM/libclang, so force to build them from source.
174FORCE_BUILD_LLVM_COMPONENTS := true
175endif