blob: b31e419ffe0e4969bd151798458e34287f3324cd [file] [log] [blame]
Ying Wangba8b3772014-03-10 18:23:08 -07001## Clang configurations.
2
Dan Albert8b1d1772015-11-13 23:06:07 -08003LLVM_PREBUILTS_PATH := $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/bin
Stephen Hinescdb52b52016-02-04 11:43:41 -08004LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_PATH)/../lib64/clang/$(LLVM_RELEASE_VERSION)/lib/linux/
Ying Wang1f982832014-02-06 18:08:44 -08005
Dan Willemsen6e22c752016-06-06 12:21:06 -07006# These will come from Soong, drop the environment versions
7unexport CLANG
8unexport CLANG_CXX
9unexport CCC_CC
10unexport CCC_CXX
11
Stephen Hinesb34b7ae2014-09-30 02:37:20 -070012CLANG_TBLGEN := $(BUILD_OUT_EXECUTABLES)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX)
13LLVM_TBLGEN := $(BUILD_OUT_EXECUTABLES)/llvm-tblgen$(BUILD_EXECUTABLE_SUFFIX)
Stephen Hines7bc754b2014-02-19 09:03:00 -080014
Stephen Hines96d2a8c2016-01-21 23:50:53 -080015# RenderScript-specific tools
16# These are tied to the version of LLVM directly in external/, so they might
17# trail the host prebuilts being used for the rest of the build process.
Stephen Hines348b81a2016-04-29 16:50:48 -070018RS_LLVM_PREBUILTS_VERSION := clang-2812033
Stephen Hines96d2a8c2016-01-21 23:50:53 -080019RS_LLVM_PREBUILTS_BASE := prebuilts/clang/host
20RS_LLVM_PREBUILTS_PATH := $(RS_LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(RS_LLVM_PREBUILTS_VERSION)/bin
Stephen Hines49b69532016-01-22 15:11:34 -080021RS_CLANG := $(RS_LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX)
Stephen Hines96d2a8c2016-01-21 23:50:53 -080022RS_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 -080025CLANG_CONFIG_UNKNOWN_CFLAGS := \
Stephen Hines433f1612014-11-26 00:57:34 -080026 -finline-functions \
Bernhard Rosenkraenzerd6e11822014-05-12 16:05:14 +020027 -finline-limit=64 \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070028 -fno-canonical-system-headers \
Chih-Hung Hsieh0ba68ba2015-05-01 14:53:59 -070029 -Wno-clobbered \
30 -fno-devirtualize \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070031 -fno-tree-sra \
Chih-Hung Hsieh78df8322015-03-05 16:02:04 -080032 -fprefetch-loop-arrays \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070033 -funswitch-loops \
Chih-Hung Hsieh7e44d7f2015-03-19 15:17:06 -070034 -Werror=unused-but-set-parameter \
Elliott Hughes3101e612015-04-03 07:43:46 -070035 -Werror=unused-but-set-variable \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070036 -Wmaybe-uninitialized \
Chih-Hung Hsieh0ba68ba2015-05-01 14:53:59 -070037 -Wno-error=clobbered \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070038 -Wno-error=maybe-uninitialized \
Chih-Hung Hsieh7e44d7f2015-03-19 15:17:06 -070039 -Wno-error=unused-but-set-parameter \
Chih-Hung Hsieh9205bc12015-04-02 14:42:20 -070040 -Wno-error=unused-but-set-variable \
Chih-Hung Hsieh22b6c5c2014-10-23 16:39:09 -070041 -Wno-free-nonheap-object \
Chih-Hung Hsiehfb482c62014-08-26 16:37:00 -070042 -Wno-literal-suffix \
43 -Wno-maybe-uninitialized \
44 -Wno-old-style-declaration \
Ying Wang1f982832014-02-06 18:08:44 -080045 -Wno-psabi \
Andrew Hsieh48f239c2014-05-09 14:13:13 +080046 -Wno-unused-but-set-parameter \
Chih-Hung Hsieh9205bc12015-04-02 14:42:20 -070047 -Wno-unused-but-set-variable \
48 -Wno-unused-local-typedefs \
49 -Wunused-but-set-parameter \
Colin Cross63e3b022015-09-24 22:14:25 -070050 -Wunused-but-set-variable \
Dan Willemsen6a66a882015-10-14 16:44:53 -070051 -fdiagnostics-color \
Dan Willemsen02268f02016-05-19 14:39:25 -070052 -mthumb-interwork \
53 -fgcse-after-reload \
54 -frerun-cse-after-loop \
55 -frename-registers \
56 -fno-align-jumps \
57 -fno-builtin-sin \
58 -fno-caller-saves \
59 -fno-early-inlining \
60 -fno-move-loop-invariants \
61 -fno-partial-inlining \
62 -fno-strict-volatile-bitfields \
63 -fno-tree-copy-prop \
64 -fno-tree-loop-optimize \
65 -msynci \
66 -mno-synci \
67 -mno-fused-madd \
68 -finline-limit=300 \
69 -fno-inline-functions-called-once \
70 -mfpmath=sse \
71 -mbionic
72
73define convert-to-clang-flags
74$(strip $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(1)))
75endef
Ying Wang1f982832014-02-06 18:08:44 -080076
Dan Albertb5b2ffe2015-04-16 18:07:07 -070077CLANG_DEFAULT_UB_CHECKS := \
78 bool \
79 integer-divide-by-zero \
80 return \
81 returns-nonnull-attribute \
82 shift-exponent \
83 unreachable \
84 vla-bound \
85
86# TODO(danalbert): The following checks currently have compiler performance
87# issues.
88# CLANG_DEFAULT_UB_CHECKS += alignment
89# CLANG_DEFAULT_UB_CHECKS += bounds
90# CLANG_DEFAULT_UB_CHECKS += enum
91# CLANG_DEFAULT_UB_CHECKS += float-cast-overflow
92# CLANG_DEFAULT_UB_CHECKS += float-divide-by-zero
93# CLANG_DEFAULT_UB_CHECKS += nonnull-attribute
94# CLANG_DEFAULT_UB_CHECKS += null
95# CLANG_DEFAULT_UB_CHECKS += shift-base
96# CLANG_DEFAULT_UB_CHECKS += signed-integer-overflow
97
98# TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on.
99# https://llvm.org/PR19302
100# http://reviews.llvm.org/D6974
101# CLANG_DEFAULT_UB_CHECKS += object-size
102
Ying Wang1f982832014-02-06 18:08:44 -0800103# HOST config
Ying Wang6feb6d52014-04-17 10:03:35 -0700104clang_2nd_arch_prefix :=
Ying Wang1f982832014-02-06 18:08:44 -0800105include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk
Ying Wang6feb6d52014-04-17 10:03:35 -0700106
107# HOST_2ND_ARCH config
108ifdef HOST_2ND_ARCH
109clang_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX)
110include $(BUILD_SYSTEM)/clang/HOST_$(HOST_2ND_ARCH).mk
Tim Murray02cefc92014-03-20 13:48:35 -0700111endif
Ying Wang1f982832014-02-06 18:08:44 -0800112
Dan Willemsen9ecbf832016-02-05 16:20:19 -0800113ifdef HOST_CROSS_ARCH
114clang_2nd_arch_prefix :=
115include $(BUILD_SYSTEM)/clang/HOST_CROSS_$(HOST_CROSS_ARCH).mk
116ifdef HOST_CROSS_2ND_ARCH
117clang_2nd_arch_prefix := $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)
118include $(BUILD_SYSTEM)/clang/HOST_CROSS_$(HOST_CROSS_2ND_ARCH).mk
119endif
Dan Willemsen057aaea2015-08-14 12:59:50 -0700120endif
121
Ying Wang1f982832014-02-06 18:08:44 -0800122# TARGET config
123clang_2nd_arch_prefix :=
124include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk
125
126# TARGET_2ND_ARCH config
127ifdef TARGET_2ND_ARCH
128clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
129include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk
130endif
131
Dan Albert08cca282014-12-11 18:56:26 -0800132ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fno-omit-frame-pointer
Ying Wang1f982832014-02-06 18:08:44 -0800133ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
Dan Albert2daceaa2014-10-20 11:37:18 -0700134
Dan Albertb58fb4a2014-11-14 17:15:00 -0800135ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
Ying Wang1f982832014-02-06 18:08:44 -0800136
137# This allows us to use the superset of functionality that compiler-rt
138# provides to Clang (for supporting features like -ftrapv).
139COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras
Ying Wange5d4e742014-11-06 14:11:33 -0800140
141ifeq ($(HOST_PREFER_32_BIT),true)
142# We don't have 32-bit prebuilt libLLVM/libclang, so force to build them from source.
143FORCE_BUILD_LLVM_COMPONENTS := true
144endif
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -0700145
Chih-Hung Hsiehd9cd1fa2016-08-02 14:22:06 -0700146# A list of projects that are allowed to set LOCAL_CLANG to false.
Chih-Hung Hsieh3ea1e512016-08-03 11:39:02 -0700147# INTERNAL_LOCAL_CLANG_EXCEPTION_PROJECTS is defined later in other config.mk.
148LOCAL_CLANG_EXCEPTION_PROJECTS = \
Chih-Hung Hsieh82c78c52016-08-03 10:42:10 -0700149 bionic/tests/ \
Chih-Hung Hsiehd9cd1fa2016-08-02 14:22:06 -0700150 device/huawei/angler/ \
151 device/lge/bullhead/ \
152 external/valgrind/ \
153 hardware/qcom/ \
154 $(INTERNAL_LOCAL_CLANG_EXCEPTION_PROJECTS)
155
156# Find $1 in the exception project list.
157define find_in_local_clang_exception_projects
158$(subst $(space),, \
159 $(foreach project,$(LOCAL_CLANG_EXCEPTION_PROJECTS), \
160 $(if $(filter $(project)%,$(1)),$(project)) \
161 ) \
162)
163endef
164
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -0700165include $(BUILD_SYSTEM)/clang/tidy.mk