blob: 9275c97808c9e12b14553dd9545c2b16586191be [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#
62# Used to enable SEA mode
63#
64ART_SEA_IR_MODE := false
65ifneq ($(wildcard art/SEA_IR_ART),)
66$(info Enabling ART_SEA_IR_MODE because of existence of art/SEA_IR_ART)
67ART_SEA_IR_MODE := true
68endif
69ifeq ($(WITH_ART_SEA_IR_MODE), true)
70ART_SEA_IR_MODE := true
71endif
72
73#
74# Used to enable portable mode
75#
76ART_USE_PORTABLE_COMPILER := false
77ifneq ($(wildcard art/USE_PORTABLE_COMPILER),)
78$(info Enabling ART_USE_PORTABLE_COMPILER because of existence of art/USE_PORTABLE_COMPILER)
79ART_USE_PORTABLE_COMPILER := true
80endif
81ifeq ($(WITH_ART_USE_PORTABLE_COMPILER),true)
82$(info Enabling ART_USE_PORTABLE_COMPILER because WITH_ART_USE_PORTABLE_COMPILER=true)
83ART_USE_PORTABLE_COMPILER := true
84endif
85
86#
Ian Rogersafd9acc2014-06-17 08:21:54 -070087# Used to change the default GC. Valid values are CMS, SS, GSS. The default is CMS.
88#
Ian Rogers6f3dbba2014-10-14 17:41:57 -070089art_default_gc_type ?= CMS
90art_default_gc_type_cflags := -DART_DEFAULT_GC_TYPE_IS_$(art_default_gc_type)
Ian Rogersafd9acc2014-06-17 08:21:54 -070091
92ifeq ($(ART_USE_PORTABLE_COMPILER),true)
93 LLVM_ROOT_PATH := external/llvm
94 # Don't fail a dalvik minimal host build.
95 -include $(LLVM_ROOT_PATH)/llvm.mk
96endif
97
Andreas Gampeee0ebc82014-10-21 21:07:28 -070098ART_HOST_CFLAGS :=
99ART_TARGET_CFLAGS :=
100
Ian Rogersafd9acc2014-06-17 08:21:54 -0700101# Clang build support.
102
103# Host.
104ART_HOST_CLANG := false
105ifneq ($(WITHOUT_HOST_CLANG),true)
106 # By default, host builds use clang for better warnings.
107 ART_HOST_CLANG := true
108endif
109
Sebastien Hertzea521dc2014-06-25 18:50:01 +0200110# Clang on the target. Target builds use GCC by default.
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +0200111ifneq ($(USE_CLANG_PLATFORM_BUILD),)
112ART_TARGET_CLANG := $(USE_CLANG_PLATFORM_BUILD)
113else
Ian Rogersd642a912014-10-02 09:41:44 -0700114ART_TARGET_CLANG := false
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +0200115endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700116ART_TARGET_CLANG_arm :=
Sebastien Hertzea521dc2014-06-25 18:50:01 +0200117ART_TARGET_CLANG_arm64 :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700118ART_TARGET_CLANG_mips :=
119ART_TARGET_CLANG_x86 :=
120ART_TARGET_CLANG_x86_64 :=
121
122define set-target-local-clang-vars
123 LOCAL_CLANG := $(ART_TARGET_CLANG)
124 $(foreach arch,$(ART_TARGET_SUPPORTED_ARCH),
125 ifneq ($$(ART_TARGET_CLANG_$(arch)),)
126 LOCAL_CLANG_$(arch) := $$(ART_TARGET_CLANG_$(arch))
127 endif)
128endef
129
Ian Rogersafd9acc2014-06-17 08:21:54 -0700130ART_TARGET_CLANG_CFLAGS :=
131ART_TARGET_CLANG_CFLAGS_arm :=
132ART_TARGET_CLANG_CFLAGS_arm64 :=
133ART_TARGET_CLANG_CFLAGS_mips :=
134ART_TARGET_CLANG_CFLAGS_x86 :=
135ART_TARGET_CLANG_CFLAGS_x86_64 :=
136
Ian Rogersd642a912014-10-02 09:41:44 -0700137# These are necessary for Clang ARM64 ART builds. TODO: remove.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700138ART_TARGET_CLANG_CFLAGS_arm64 += \
139 -Wno-implicit-exception-spec-mismatch \
140 -DNVALGRIND \
141 -Wno-unused-value
142
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700143# FIXME: upstream LLVM has a vectorizer bug that needs to be fixed
144ART_TARGET_CLANG_CFLAGS_arm64 += \
145 -fno-vectorize
146
147# Colorize clang compiler warnings.
148art_clang_cflags := -fcolor-diagnostics
149
150# Warn about thread safety violations with clang.
151art_clang_cflags += -Wthread-safety
152
153# Warn if switch fallthroughs aren't annotated.
154art_clang_cflags += -Wimplicit-fallthrough
155
156# Enable float equality warnings.
157art_clang_cflags += -Wfloat-equal
158
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800159# Enable warning of converting ints to void*.
160art_clang_cflags += -Wint-to-void-pointer-cast
161
162# GCC-only warnings.
163art_gcc_cflags := -Wunused-but-set-parameter
164# Suggest const: too many false positives, but good for a trial run.
165# -Wsuggest-attribute=const
166# Useless casts: too many, as we need to be 32/64 agnostic, but the compiler knows.
167# -Wuseless-cast
168# Zero-as-null: Have to convert all NULL and "diagnostic ignore" all includes like libnativehelper
169# that are still stuck pre-C++11.
170# -Wzero-as-null-pointer-constant \
171# Suggest final: Have to move to a more recent GCC.
172# -Wsuggest-final-types
173
174
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700175ifeq ($(ART_HOST_CLANG),true)
Ian Rogers4ad5cd32014-11-11 23:08:07 -0800176 # Bug: 15446488. We don't omit the frame pointer to work around
177 # clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
178 ART_HOST_CFLAGS += $(art_clang_cflags) -fno-omit-frame-pointer
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800179else
180 ART_HOST_CFLAGS += $(art_gcc_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700181endif
182ifeq ($(ART_TARGET_CLANG),true)
183 ART_TARGET_CFLAGS += $(art_clang_cflags)
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800184else
185 ART_TARGET_CFLAGS += $(art_gcc_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700186endif
187
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800188# Clear local variables now their use has ended.
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700189art_clang_cflags :=
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800190art_gcc_cflags :=
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700191
192ART_CPP_EXTENSION := .cc
193
194ART_C_INCLUDES := \
195 external/gtest/include \
196 external/valgrind/main/include \
197 external/valgrind/main \
198 external/vixl/src \
199 external/zlib \
200 frameworks/compile/mclinker/include
201
202# Base set of cflags used by all things ART.
203art_cflags := \
204 -fno-rtti \
205 -std=gnu++11 \
206 -ggdb3 \
207 -Wall \
208 -Werror \
209 -Wextra \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700210 -Wstrict-aliasing \
211 -fstrict-aliasing \
212 -Wunreachable-code \
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800213 -Wno-conversion-null \
214 -Wredundant-decls \
215 -Wshadow \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700216 -fvisibility=protected \
217 $(art_default_gc_type_cflags)
218
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800219# Missing declarations: too many at the moment, as we use "extern" quite a bit.
220# -Wmissing-declarations \
221
222
Mathieu Chartiercd195fe2014-11-25 18:36:01 -0800223
224ifdef ART_IMT_SIZE
225 art_cflags += -DIMT_SIZE=$(ART_IMT_SIZE)
226else
227 # Default is 64
228 art_cflags += -DIMT_SIZE=64
229endif
230
Ian Rogersafd9acc2014-06-17 08:21:54 -0700231ifeq ($(ART_SMALL_MODE),true)
232 art_cflags += -DART_SMALL_MODE=1
233endif
234
235ifeq ($(ART_SEA_IR_MODE),true)
236 art_cflags += -DART_SEA_IR_MODE=1
237endif
238
Nicolas Geoffray9bb492a2014-11-25 23:42:00 +0000239ifeq ($(ART_USE_OPTIMIZING_COMPILER),true)
240 art_cflags += -DART_USE_OPTIMIZING_COMPILER=1
241endif
242
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700243# Cflags for non-debug ART and ART tools.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700244art_non_debug_cflags := \
245 -O3
246
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700247# Cflags for debug ART and ART tools.
248art_debug_cflags := \
249 -O2 \
250 -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
Serban Constantinescu32f5b4d2014-11-25 20:05:46 +0000251 -DVIXL_DEBUG \
Ian Rogers50fe6da2014-10-17 01:18:08 -0700252 -UNDEBUG
Stephen Hines67a43382014-07-17 01:49:18 -0700253
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700254art_host_non_debug_cflags := $(art_non_debug_cflags)
255art_target_non_debug_cflags := $(art_non_debug_cflags)
Stephen Hines67a43382014-07-17 01:49:18 -0700256
Ian Rogersafd9acc2014-06-17 08:21:54 -0700257ifeq ($(HOST_OS),linux)
Stephen Hines67a43382014-07-17 01:49:18 -0700258 # Larger frame-size for host clang builds today
Dan Albert98b8bcf2014-11-14 19:56:21 -0800259 ifndef SANITIZE_HOST
Mathieu Chartier88f21ca2014-11-18 14:13:58 -0800260 art_host_non_debug_cflags += -Wframe-larger-than=2700
Dan Albert98b8bcf2014-11-14 19:56:21 -0800261 endif
Stephen Hines67a43382014-07-17 01:49:18 -0700262 art_target_non_debug_cflags += -Wframe-larger-than=1728
Ian Rogersafd9acc2014-06-17 08:21:54 -0700263endif
264
David 'Digit' Turner62753c42014-12-02 13:28:21 +0100265# DALVIK_VM_LIB will be empty for VM-less builds. Avoid $(error) calls here because
266# LIBART_IMG_XXX variables won't be defined.
267ifneq ($(DALVIK_VM_LIB),)
268 ifndef LIBART_IMG_HOST_BASE_ADDRESS
269 $(error LIBART_IMG_HOST_BASE_ADDRESS unset)
270 endif
271 ART_HOST_CFLAGS += $(art_cflags) -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS)
272 ART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default
Ian Rogersafd9acc2014-06-17 08:21:54 -0700273
David 'Digit' Turner62753c42014-12-02 13:28:21 +0100274 ifndef LIBART_IMG_TARGET_BASE_ADDRESS
275 $(error LIBART_IMG_TARGET_BASE_ADDRESS unset)
276 endif
277 ART_TARGET_CFLAGS += $(art_cflags) \
278 -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700279endif
Alex Lighta59dd802014-07-02 16:28:08 -0700280
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700281ART_HOST_NON_DEBUG_CFLAGS := $(art_host_non_debug_cflags)
282ART_TARGET_NON_DEBUG_CFLAGS := $(art_target_non_debug_cflags)
283ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags)
284ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
285
Alex Lighta59dd802014-07-02 16:28:08 -0700286ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA
287 LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA=-0x1000000
288endif
289ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA
290 LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA=0x1000000
291endif
292ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
293ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
294
295ifndef LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA
296 LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA=-0x1000000
297endif
298ifndef LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA
299 LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA=0x1000000
300endif
301ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA)
302ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA)
303
Ian Rogersafd9acc2014-06-17 08:21:54 -0700304# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
305# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
306
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700307# Clear locals now they've served their purpose.
308art_cflags :=
309art_debug_cflags :=
310art_non_debug_cflags :=
311art_host_non_debug_cflags :=
312art_target_non_debug_cflags :=
313art_default_gc_type :=
314art_default_gc_type_cflags :=
315
316ART_HOST_LDLIBS :=
317ifneq ($(ART_HOST_CLANG),true)
318 # GCC lacks libc++ assumed atomic operations, grab via libatomic.
319 ART_HOST_LDLIBS += -latomic
Ian Rogersafd9acc2014-06-17 08:21:54 -0700320endif
321
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700322ART_TARGET_LDFLAGS :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700323
324# $(1): ndebug_or_debug
325define set-target-local-cflags-vars
326 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
327 LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86)
Dehao Chen997660d2014-07-08 10:00:56 -0700328 LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700329 art_target_cflags_ndebug_or_debug := $(1)
330 ifeq ($$(art_target_cflags_ndebug_or_debug),debug)
331 LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
332 else
333 LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
334 endif
335
336 # TODO: Also set when ART_TARGET_CLANG_$(arch)!=false and ART_TARGET_CLANG==true
337 $(foreach arch,$(ART_SUPPORTED_ARCH),
338 ifeq ($$(ART_TARGET_CLANG_$(arch)),true)
339 LOCAL_CFLAGS_$(arch) += $$(ART_TARGET_CLANG_CFLAGS_$(arch))
340 endif)
341
342 # Clear locally used variables.
343 art_target_cflags_ndebug_or_debug :=
344endef
345
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700346# Support for disabling certain builds.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700347ART_BUILD_TARGET := false
348ART_BUILD_HOST := false
349ART_BUILD_NDEBUG := false
350ART_BUILD_DEBUG := false
351ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
352 ART_BUILD_TARGET := true
353 ART_BUILD_NDEBUG := true
354endif
355ifeq ($(ART_BUILD_TARGET_DEBUG),true)
356 ART_BUILD_TARGET := true
357 ART_BUILD_DEBUG := true
358endif
359ifeq ($(ART_BUILD_HOST_NDEBUG),true)
360 ART_BUILD_HOST := true
361 ART_BUILD_NDEBUG := true
362endif
363ifeq ($(ART_BUILD_HOST_DEBUG),true)
364 ART_BUILD_HOST := true
365 ART_BUILD_DEBUG := true
366endif
367
Ian Rogersafd9acc2014-06-17 08:21:54 -0700368endif # ANDROID_COMMON_BUILD_MK