blob: 478c63c9a54c2df92c63956a0ba4604e4924f553 [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#
87# Used to enable optimizing compiler
88#
Ian Rogersafd9acc2014-06-17 08:21:54 -070089ifeq ($(ART_USE_OPTIMIZING_COMPILER),true)
90DEX2OAT_FLAGS := --compiler-backend=Optimizing
Ian Rogersafd9acc2014-06-17 08:21:54 -070091endif
92
93#
94# Used to change the default GC. Valid values are CMS, SS, GSS. The default is CMS.
95#
Ian Rogers6f3dbba2014-10-14 17:41:57 -070096art_default_gc_type ?= CMS
97art_default_gc_type_cflags := -DART_DEFAULT_GC_TYPE_IS_$(art_default_gc_type)
Ian Rogersafd9acc2014-06-17 08:21:54 -070098
99ifeq ($(ART_USE_PORTABLE_COMPILER),true)
100 LLVM_ROOT_PATH := external/llvm
101 # Don't fail a dalvik minimal host build.
102 -include $(LLVM_ROOT_PATH)/llvm.mk
103endif
104
Andreas Gampeee0ebc82014-10-21 21:07:28 -0700105ART_HOST_CFLAGS :=
106ART_TARGET_CFLAGS :=
107
Ian Rogersafd9acc2014-06-17 08:21:54 -0700108# Clang build support.
109
110# Host.
111ART_HOST_CLANG := false
112ifneq ($(WITHOUT_HOST_CLANG),true)
113 # By default, host builds use clang for better warnings.
114 ART_HOST_CLANG := true
115endif
116
Sebastien Hertzea521dc2014-06-25 18:50:01 +0200117# Clang on the target. Target builds use GCC by default.
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +0200118ifneq ($(USE_CLANG_PLATFORM_BUILD),)
119ART_TARGET_CLANG := $(USE_CLANG_PLATFORM_BUILD)
120else
Ian Rogersd642a912014-10-02 09:41:44 -0700121ART_TARGET_CLANG := false
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +0200122endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700123ART_TARGET_CLANG_arm :=
Sebastien Hertzea521dc2014-06-25 18:50:01 +0200124ART_TARGET_CLANG_arm64 :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700125ART_TARGET_CLANG_mips :=
126ART_TARGET_CLANG_x86 :=
127ART_TARGET_CLANG_x86_64 :=
128
129define set-target-local-clang-vars
130 LOCAL_CLANG := $(ART_TARGET_CLANG)
131 $(foreach arch,$(ART_TARGET_SUPPORTED_ARCH),
132 ifneq ($$(ART_TARGET_CLANG_$(arch)),)
133 LOCAL_CLANG_$(arch) := $$(ART_TARGET_CLANG_$(arch))
134 endif)
135endef
136
Ian Rogersafd9acc2014-06-17 08:21:54 -0700137ART_TARGET_CLANG_CFLAGS :=
138ART_TARGET_CLANG_CFLAGS_arm :=
139ART_TARGET_CLANG_CFLAGS_arm64 :=
140ART_TARGET_CLANG_CFLAGS_mips :=
141ART_TARGET_CLANG_CFLAGS_x86 :=
142ART_TARGET_CLANG_CFLAGS_x86_64 :=
143
Ian Rogersd642a912014-10-02 09:41:44 -0700144# These are necessary for Clang ARM64 ART builds. TODO: remove.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700145ART_TARGET_CLANG_CFLAGS_arm64 += \
146 -Wno-implicit-exception-spec-mismatch \
147 -DNVALGRIND \
148 -Wno-unused-value
149
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700150# FIXME: upstream LLVM has a vectorizer bug that needs to be fixed
151ART_TARGET_CLANG_CFLAGS_arm64 += \
152 -fno-vectorize
153
154# Colorize clang compiler warnings.
155art_clang_cflags := -fcolor-diagnostics
156
157# Warn about thread safety violations with clang.
158art_clang_cflags += -Wthread-safety
159
160# Warn if switch fallthroughs aren't annotated.
161art_clang_cflags += -Wimplicit-fallthrough
162
163# Enable float equality warnings.
164art_clang_cflags += -Wfloat-equal
165
166ifeq ($(ART_HOST_CLANG),true)
167 ART_HOST_CFLAGS += $(art_clang_cflags)
168endif
169ifeq ($(ART_TARGET_CLANG),true)
170 ART_TARGET_CFLAGS += $(art_clang_cflags)
171endif
172
173# Clear local variable now its use has ended.
174art_clang_cflags :=
175
176ART_CPP_EXTENSION := .cc
177
178ART_C_INCLUDES := \
179 external/gtest/include \
180 external/valgrind/main/include \
181 external/valgrind/main \
182 external/vixl/src \
183 external/zlib \
184 frameworks/compile/mclinker/include
185
186# Base set of cflags used by all things ART.
187art_cflags := \
188 -fno-rtti \
189 -std=gnu++11 \
190 -ggdb3 \
191 -Wall \
192 -Werror \
193 -Wextra \
194 -Wno-sign-promo \
195 -Wno-unused-parameter \
196 -Wstrict-aliasing \
197 -fstrict-aliasing \
198 -Wunreachable-code \
199 -fvisibility=protected \
200 $(art_default_gc_type_cflags)
201
Ian Rogersafd9acc2014-06-17 08:21:54 -0700202ifeq ($(ART_SMALL_MODE),true)
203 art_cflags += -DART_SMALL_MODE=1
204endif
205
206ifeq ($(ART_SEA_IR_MODE),true)
207 art_cflags += -DART_SEA_IR_MODE=1
208endif
209
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700210# Cflags for non-debug ART and ART tools.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700211art_non_debug_cflags := \
212 -O3
213
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700214# Cflags for debug ART and ART tools.
215art_debug_cflags := \
216 -O2 \
217 -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
Ian Rogers50fe6da2014-10-17 01:18:08 -0700218 -UNDEBUG
Stephen Hines67a43382014-07-17 01:49:18 -0700219
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700220art_host_non_debug_cflags := $(art_non_debug_cflags)
221art_target_non_debug_cflags := $(art_non_debug_cflags)
Stephen Hines67a43382014-07-17 01:49:18 -0700222
Ian Rogersafd9acc2014-06-17 08:21:54 -0700223ifeq ($(HOST_OS),linux)
Stephen Hines67a43382014-07-17 01:49:18 -0700224 # Larger frame-size for host clang builds today
Stephen Hines11597272014-07-23 19:47:35 -0700225 art_host_non_debug_cflags += -Wframe-larger-than=2600
Stephen Hines67a43382014-07-17 01:49:18 -0700226 art_target_non_debug_cflags += -Wframe-larger-than=1728
Ian Rogersafd9acc2014-06-17 08:21:54 -0700227endif
228
Ian Rogersafd9acc2014-06-17 08:21:54 -0700229ifndef LIBART_IMG_HOST_BASE_ADDRESS
230 $(error LIBART_IMG_HOST_BASE_ADDRESS unset)
231endif
Andreas Gampeee0ebc82014-10-21 21:07:28 -0700232ART_HOST_CFLAGS += $(art_cflags) -DANDROID_SMP=1 -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700233ART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default
Ian Rogersafd9acc2014-06-17 08:21:54 -0700234
235ifndef LIBART_IMG_TARGET_BASE_ADDRESS
236 $(error LIBART_IMG_TARGET_BASE_ADDRESS unset)
237endif
Andreas Gampeee0ebc82014-10-21 21:07:28 -0700238ART_TARGET_CFLAGS += $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS)
Alex Lighta59dd802014-07-02 16:28:08 -0700239
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700240ART_HOST_NON_DEBUG_CFLAGS := $(art_host_non_debug_cflags)
241ART_TARGET_NON_DEBUG_CFLAGS := $(art_target_non_debug_cflags)
242ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags)
243ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
244
Alex Lighta59dd802014-07-02 16:28:08 -0700245ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA
246 LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA=-0x1000000
247endif
248ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA
249 LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA=0x1000000
250endif
251ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
252ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
253
254ifndef LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA
255 LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA=-0x1000000
256endif
257ifndef LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA
258 LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA=0x1000000
259endif
260ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA)
261ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA)
262
Ian Rogersafd9acc2014-06-17 08:21:54 -0700263ifeq ($(TARGET_CPU_SMP),true)
264 ART_TARGET_CFLAGS += -DANDROID_SMP=1
265else
266 ifeq ($(TARGET_CPU_SMP),false)
267 ART_TARGET_CFLAGS += -DANDROID_SMP=0
268 else
269 $(warning TARGET_CPU_SMP should be (true|false), found $(TARGET_CPU_SMP))
270 # Make sure we emit barriers for the worst case.
271 ART_TARGET_CFLAGS += -DANDROID_SMP=1
272 endif
273endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700274
275# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
276# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
277
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700278# Clear locals now they've served their purpose.
279art_cflags :=
280art_debug_cflags :=
281art_non_debug_cflags :=
282art_host_non_debug_cflags :=
283art_target_non_debug_cflags :=
284art_default_gc_type :=
285art_default_gc_type_cflags :=
286
287ART_HOST_LDLIBS :=
288ifneq ($(ART_HOST_CLANG),true)
289 # GCC lacks libc++ assumed atomic operations, grab via libatomic.
290 ART_HOST_LDLIBS += -latomic
Ian Rogersafd9acc2014-06-17 08:21:54 -0700291endif
292
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700293ART_TARGET_LDFLAGS :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700294
295# $(1): ndebug_or_debug
296define set-target-local-cflags-vars
297 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
298 LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86)
Dehao Chen997660d2014-07-08 10:00:56 -0700299 LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700300 art_target_cflags_ndebug_or_debug := $(1)
301 ifeq ($$(art_target_cflags_ndebug_or_debug),debug)
302 LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
303 else
304 LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
305 endif
306
307 # TODO: Also set when ART_TARGET_CLANG_$(arch)!=false and ART_TARGET_CLANG==true
308 $(foreach arch,$(ART_SUPPORTED_ARCH),
309 ifeq ($$(ART_TARGET_CLANG_$(arch)),true)
310 LOCAL_CFLAGS_$(arch) += $$(ART_TARGET_CLANG_CFLAGS_$(arch))
311 endif)
312
313 # Clear locally used variables.
314 art_target_cflags_ndebug_or_debug :=
315endef
316
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700317# Support for disabling certain builds.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700318ART_BUILD_TARGET := false
319ART_BUILD_HOST := false
320ART_BUILD_NDEBUG := false
321ART_BUILD_DEBUG := false
322ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
323 ART_BUILD_TARGET := true
324 ART_BUILD_NDEBUG := true
325endif
326ifeq ($(ART_BUILD_TARGET_DEBUG),true)
327 ART_BUILD_TARGET := true
328 ART_BUILD_DEBUG := true
329endif
330ifeq ($(ART_BUILD_HOST_NDEBUG),true)
331 ART_BUILD_HOST := true
332 ART_BUILD_NDEBUG := true
333endif
334ifeq ($(ART_BUILD_HOST_DEBUG),true)
335 ART_BUILD_HOST := true
336 ART_BUILD_DEBUG := true
337endif
338
Ian Rogersafd9acc2014-06-17 08:21:54 -0700339endif # ANDROID_COMMON_BUILD_MK