blob: 1a8752fa42a455fed6527068b315abb09061cda4 [file] [log] [blame]
Ian Rogersafd9acc2014-06-17 08:21:54 -07001#
2# Copyright (C) 2011 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17ifndef ANDROID_COMMON_BUILD_MK
18ANDROID_COMMON_BUILD_MK = true
19
20include art/build/Android.common.mk
21
22# These can be overridden via the environment or by editing to
23# enable/disable certain build configuration.
24#
25# For example, to disable everything but the host debug build you use:
26#
27# (export ART_BUILD_TARGET_NDEBUG=false && export ART_BUILD_TARGET_DEBUG=false && export ART_BUILD_HOST_NDEBUG=false && ...)
28#
29# Beware that tests may use the non-debug build for performance, notable 055-enum-performance
30#
31ART_BUILD_TARGET_NDEBUG ?= true
32ART_BUILD_TARGET_DEBUG ?= true
33ART_BUILD_HOST_NDEBUG ?= true
34ART_BUILD_HOST_DEBUG ?= true
35
36ifeq ($(ART_BUILD_TARGET_NDEBUG),false)
37$(info Disabling ART_BUILD_TARGET_NDEBUG)
38endif
39ifeq ($(ART_BUILD_TARGET_DEBUG),false)
40$(info Disabling ART_BUILD_TARGET_DEBUG)
41endif
42ifeq ($(ART_BUILD_HOST_NDEBUG),false)
43$(info Disabling ART_BUILD_HOST_NDEBUG)
44endif
45ifeq ($(ART_BUILD_HOST_DEBUG),false)
46$(info Disabling ART_BUILD_HOST_DEBUG)
47endif
48
49#
50# Used to enable smart mode
51#
52ART_SMALL_MODE := false
53ifneq ($(wildcard art/SMALL_ART),)
54$(info Enabling ART_SMALL_MODE because of existence of art/SMALL_ART)
55ART_SMALL_MODE := true
56endif
57ifeq ($(WITH_ART_SMALL_MODE), true)
58ART_SMALL_MODE := true
59endif
60
61#
Ian Rogersafd9acc2014-06-17 08:21:54 -070062# Used to change the default GC. Valid values are CMS, SS, GSS. The default is CMS.
63#
Ian Rogers6f3dbba2014-10-14 17:41:57 -070064art_default_gc_type ?= CMS
65art_default_gc_type_cflags := -DART_DEFAULT_GC_TYPE_IS_$(art_default_gc_type)
Ian Rogersafd9acc2014-06-17 08:21:54 -070066
Andreas Gampeee0ebc82014-10-21 21:07:28 -070067ART_HOST_CFLAGS :=
68ART_TARGET_CFLAGS :=
69
Ian Rogersafd9acc2014-06-17 08:21:54 -070070# Clang build support.
71
72# Host.
73ART_HOST_CLANG := false
74ifneq ($(WITHOUT_HOST_CLANG),true)
75 # By default, host builds use clang for better warnings.
76 ART_HOST_CLANG := true
77endif
78
Sebastien Hertzea521dc2014-06-25 18:50:01 +020079# Clang on the target. Target builds use GCC by default.
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +020080ifneq ($(USE_CLANG_PLATFORM_BUILD),)
81ART_TARGET_CLANG := $(USE_CLANG_PLATFORM_BUILD)
82else
Ian Rogersd642a912014-10-02 09:41:44 -070083ART_TARGET_CLANG := false
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +020084endif
Ian Rogersafd9acc2014-06-17 08:21:54 -070085ART_TARGET_CLANG_arm :=
Sebastien Hertzea521dc2014-06-25 18:50:01 +020086ART_TARGET_CLANG_arm64 :=
Ian Rogersafd9acc2014-06-17 08:21:54 -070087ART_TARGET_CLANG_mips :=
88ART_TARGET_CLANG_x86 :=
89ART_TARGET_CLANG_x86_64 :=
90
91define set-target-local-clang-vars
92 LOCAL_CLANG := $(ART_TARGET_CLANG)
93 $(foreach arch,$(ART_TARGET_SUPPORTED_ARCH),
94 ifneq ($$(ART_TARGET_CLANG_$(arch)),)
95 LOCAL_CLANG_$(arch) := $$(ART_TARGET_CLANG_$(arch))
96 endif)
97endef
98
Ian Rogersafd9acc2014-06-17 08:21:54 -070099ART_TARGET_CLANG_CFLAGS :=
100ART_TARGET_CLANG_CFLAGS_arm :=
101ART_TARGET_CLANG_CFLAGS_arm64 :=
102ART_TARGET_CLANG_CFLAGS_mips :=
103ART_TARGET_CLANG_CFLAGS_x86 :=
104ART_TARGET_CLANG_CFLAGS_x86_64 :=
105
Ian Rogersd642a912014-10-02 09:41:44 -0700106# These are necessary for Clang ARM64 ART builds. TODO: remove.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700107ART_TARGET_CLANG_CFLAGS_arm64 += \
108 -Wno-implicit-exception-spec-mismatch \
109 -DNVALGRIND \
110 -Wno-unused-value
111
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700112# FIXME: upstream LLVM has a vectorizer bug that needs to be fixed
113ART_TARGET_CLANG_CFLAGS_arm64 += \
114 -fno-vectorize
115
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700116# Warn about thread safety violations with clang.
Dan Albert6c7cdc52014-12-02 14:58:06 -0800117art_clang_cflags := -Wthread-safety
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700118
119# Warn if switch fallthroughs aren't annotated.
120art_clang_cflags += -Wimplicit-fallthrough
121
122# Enable float equality warnings.
123art_clang_cflags += -Wfloat-equal
124
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800125# Enable warning of converting ints to void*.
126art_clang_cflags += -Wint-to-void-pointer-cast
127
128# GCC-only warnings.
129art_gcc_cflags := -Wunused-but-set-parameter
130# Suggest const: too many false positives, but good for a trial run.
131# -Wsuggest-attribute=const
132# Useless casts: too many, as we need to be 32/64 agnostic, but the compiler knows.
133# -Wuseless-cast
134# Zero-as-null: Have to convert all NULL and "diagnostic ignore" all includes like libnativehelper
135# that are still stuck pre-C++11.
136# -Wzero-as-null-pointer-constant \
137# Suggest final: Have to move to a more recent GCC.
138# -Wsuggest-final-types
139
140
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700141ifeq ($(ART_HOST_CLANG),true)
Ian Rogers4ad5cd32014-11-11 23:08:07 -0800142 # Bug: 15446488. We don't omit the frame pointer to work around
143 # clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
144 ART_HOST_CFLAGS += $(art_clang_cflags) -fno-omit-frame-pointer
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800145else
146 ART_HOST_CFLAGS += $(art_gcc_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700147endif
148ifeq ($(ART_TARGET_CLANG),true)
149 ART_TARGET_CFLAGS += $(art_clang_cflags)
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800150else
151 ART_TARGET_CFLAGS += $(art_gcc_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700152endif
153
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800154# Clear local variables now their use has ended.
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700155art_clang_cflags :=
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800156art_gcc_cflags :=
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700157
158ART_CPP_EXTENSION := .cc
159
160ART_C_INCLUDES := \
161 external/gtest/include \
162 external/valgrind/main/include \
163 external/valgrind/main \
164 external/vixl/src \
165 external/zlib \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700166
167# Base set of cflags used by all things ART.
168art_cflags := \
169 -fno-rtti \
170 -std=gnu++11 \
171 -ggdb3 \
172 -Wall \
173 -Werror \
174 -Wextra \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700175 -Wstrict-aliasing \
176 -fstrict-aliasing \
177 -Wunreachable-code \
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800178 -Wno-conversion-null \
179 -Wredundant-decls \
180 -Wshadow \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700181 -fvisibility=protected \
182 $(art_default_gc_type_cflags)
183
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800184# Missing declarations: too many at the moment, as we use "extern" quite a bit.
185# -Wmissing-declarations \
186
187
Mathieu Chartiercd195fe2014-11-25 18:36:01 -0800188
189ifdef ART_IMT_SIZE
190 art_cflags += -DIMT_SIZE=$(ART_IMT_SIZE)
191else
192 # Default is 64
193 art_cflags += -DIMT_SIZE=64
194endif
195
Ian Rogersafd9acc2014-06-17 08:21:54 -0700196ifeq ($(ART_SMALL_MODE),true)
197 art_cflags += -DART_SMALL_MODE=1
198endif
199
Nicolas Geoffray9bb492a2014-11-25 23:42:00 +0000200ifeq ($(ART_USE_OPTIMIZING_COMPILER),true)
201 art_cflags += -DART_USE_OPTIMIZING_COMPILER=1
202endif
203
Hiroshi Yamauchib0d22f12014-12-08 12:08:46 -0800204ifeq ($(ART_HEAP_POISONING),true)
205 art_cflags += -DART_HEAP_POISONING=1
206endif
207
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700208# Cflags for non-debug ART and ART tools.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700209art_non_debug_cflags := \
210 -O3
211
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700212# Cflags for debug ART and ART tools.
213art_debug_cflags := \
214 -O2 \
215 -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
Serban Constantinescu32f5b4d2014-11-25 20:05:46 +0000216 -DVIXL_DEBUG \
Ian Rogers50fe6da2014-10-17 01:18:08 -0700217 -UNDEBUG
Stephen Hines67a43382014-07-17 01:49:18 -0700218
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700219art_host_non_debug_cflags := $(art_non_debug_cflags)
220art_target_non_debug_cflags := $(art_non_debug_cflags)
Stephen Hines67a43382014-07-17 01:49:18 -0700221
Ian Rogersafd9acc2014-06-17 08:21:54 -0700222ifeq ($(HOST_OS),linux)
Stephen Hines67a43382014-07-17 01:49:18 -0700223 # Larger frame-size for host clang builds today
Dan Albert98b8bcf2014-11-14 19:56:21 -0800224 ifndef SANITIZE_HOST
Mathieu Chartier88f21ca2014-11-18 14:13:58 -0800225 art_host_non_debug_cflags += -Wframe-larger-than=2700
Dan Albert98b8bcf2014-11-14 19:56:21 -0800226 endif
Stephen Hines67a43382014-07-17 01:49:18 -0700227 art_target_non_debug_cflags += -Wframe-larger-than=1728
Ian Rogersafd9acc2014-06-17 08:21:54 -0700228endif
229
David 'Digit' Turner62753c42014-12-02 13:28:21 +0100230# DALVIK_VM_LIB will be empty for VM-less builds. Avoid $(error) calls here because
231# LIBART_IMG_XXX variables won't be defined.
232ifneq ($(DALVIK_VM_LIB),)
233 ifndef LIBART_IMG_HOST_BASE_ADDRESS
234 $(error LIBART_IMG_HOST_BASE_ADDRESS unset)
235 endif
236 ART_HOST_CFLAGS += $(art_cflags) -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS)
237 ART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default
Ian Rogersafd9acc2014-06-17 08:21:54 -0700238
David 'Digit' Turner62753c42014-12-02 13:28:21 +0100239 ifndef LIBART_IMG_TARGET_BASE_ADDRESS
240 $(error LIBART_IMG_TARGET_BASE_ADDRESS unset)
241 endif
242 ART_TARGET_CFLAGS += $(art_cflags) \
243 -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700244endif
Alex Lighta59dd802014-07-02 16:28:08 -0700245
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700246ART_HOST_NON_DEBUG_CFLAGS := $(art_host_non_debug_cflags)
247ART_TARGET_NON_DEBUG_CFLAGS := $(art_target_non_debug_cflags)
248ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags)
249ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
250
Alex Lighta59dd802014-07-02 16:28:08 -0700251ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA
252 LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA=-0x1000000
253endif
254ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA
255 LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA=0x1000000
256endif
257ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
258ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
259
260ifndef LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA
261 LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA=-0x1000000
262endif
263ifndef LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA
264 LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA=0x1000000
265endif
266ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA)
267ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA)
268
Ian Rogersafd9acc2014-06-17 08:21:54 -0700269# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
270# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
271
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700272# Clear locals now they've served their purpose.
273art_cflags :=
274art_debug_cflags :=
275art_non_debug_cflags :=
276art_host_non_debug_cflags :=
277art_target_non_debug_cflags :=
278art_default_gc_type :=
279art_default_gc_type_cflags :=
280
281ART_HOST_LDLIBS :=
282ifneq ($(ART_HOST_CLANG),true)
283 # GCC lacks libc++ assumed atomic operations, grab via libatomic.
284 ART_HOST_LDLIBS += -latomic
Ian Rogersafd9acc2014-06-17 08:21:54 -0700285endif
286
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700287ART_TARGET_LDFLAGS :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700288
289# $(1): ndebug_or_debug
290define set-target-local-cflags-vars
291 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
292 LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86)
Dehao Chen997660d2014-07-08 10:00:56 -0700293 LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700294 art_target_cflags_ndebug_or_debug := $(1)
295 ifeq ($$(art_target_cflags_ndebug_or_debug),debug)
296 LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
297 else
298 LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
299 endif
300
301 # TODO: Also set when ART_TARGET_CLANG_$(arch)!=false and ART_TARGET_CLANG==true
302 $(foreach arch,$(ART_SUPPORTED_ARCH),
303 ifeq ($$(ART_TARGET_CLANG_$(arch)),true)
304 LOCAL_CFLAGS_$(arch) += $$(ART_TARGET_CLANG_CFLAGS_$(arch))
305 endif)
306
307 # Clear locally used variables.
308 art_target_cflags_ndebug_or_debug :=
309endef
310
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700311# Support for disabling certain builds.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700312ART_BUILD_TARGET := false
313ART_BUILD_HOST := false
314ART_BUILD_NDEBUG := false
315ART_BUILD_DEBUG := false
316ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
317 ART_BUILD_TARGET := true
318 ART_BUILD_NDEBUG := true
319endif
320ifeq ($(ART_BUILD_TARGET_DEBUG),true)
321 ART_BUILD_TARGET := true
322 ART_BUILD_DEBUG := true
323endif
324ifeq ($(ART_BUILD_HOST_NDEBUG),true)
325 ART_BUILD_HOST := true
326 ART_BUILD_NDEBUG := true
327endif
328ifeq ($(ART_BUILD_HOST_DEBUG),true)
329 ART_BUILD_HOST := true
330 ART_BUILD_DEBUG := true
331endif
332
Ian Rogersafd9acc2014-06-17 08:21:54 -0700333endif # ANDROID_COMMON_BUILD_MK