blob: 55a482197ffda0c5b9eaf235fc68e7ec64bba392 [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#
89ART_USE_OPTIMIZING_COMPILER := false
90ifneq ($(wildcard art/USE_OPTIMIZING_COMPILER),)
91$(info Enabling ART_USE_OPTIMIZING_COMPILER because of existence of art/USE_OPTIMIZING_COMPILER)
92ART_USE_OPTIMIZING_COMPILER := true
93endif
94ifeq ($(WITH_ART_USE_OPTIMIZING_COMPILER), true)
95ART_USE_OPTIMIZING_COMPILER := true
96endif
97
98ifeq ($(ART_USE_OPTIMIZING_COMPILER),true)
99DEX2OAT_FLAGS := --compiler-backend=Optimizing
100DALVIKVM_FLAGS += -Xcompiler-option --compiler-backend=Optimizing
101endif
102
103#
104# Used to change the default GC. Valid values are CMS, SS, GSS. The default is CMS.
105#
106ART_DEFAULT_GC_TYPE ?= CMS
107ART_DEFAULT_GC_TYPE_CFLAGS := -DART_DEFAULT_GC_TYPE_IS_$(ART_DEFAULT_GC_TYPE)
108
109ifeq ($(ART_USE_PORTABLE_COMPILER),true)
110 LLVM_ROOT_PATH := external/llvm
111 # Don't fail a dalvik minimal host build.
112 -include $(LLVM_ROOT_PATH)/llvm.mk
113endif
114
115# Clang build support.
116
117# Host.
118ART_HOST_CLANG := false
119ifneq ($(WITHOUT_HOST_CLANG),true)
120 # By default, host builds use clang for better warnings.
121 ART_HOST_CLANG := true
122endif
123
Sebastien Hertzea521dc2014-06-25 18:50:01 +0200124# Clang on the target. Target builds use GCC by default.
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +0200125ifneq ($(USE_CLANG_PLATFORM_BUILD),)
126ART_TARGET_CLANG := $(USE_CLANG_PLATFORM_BUILD)
127else
Ian Rogersd642a912014-10-02 09:41:44 -0700128ART_TARGET_CLANG := false
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +0200129endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700130ART_TARGET_CLANG_arm :=
Sebastien Hertzea521dc2014-06-25 18:50:01 +0200131ART_TARGET_CLANG_arm64 :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700132ART_TARGET_CLANG_mips :=
133ART_TARGET_CLANG_x86 :=
134ART_TARGET_CLANG_x86_64 :=
135
136define set-target-local-clang-vars
137 LOCAL_CLANG := $(ART_TARGET_CLANG)
138 $(foreach arch,$(ART_TARGET_SUPPORTED_ARCH),
139 ifneq ($$(ART_TARGET_CLANG_$(arch)),)
140 LOCAL_CLANG_$(arch) := $$(ART_TARGET_CLANG_$(arch))
141 endif)
142endef
143
144ART_CPP_EXTENSION := .cc
145
Ian Rogersafd9acc2014-06-17 08:21:54 -0700146ART_C_INCLUDES := \
147 external/gtest/include \
148 external/valgrind/main/include \
149 external/valgrind/main \
150 external/vixl/src \
151 external/zlib \
152 frameworks/compile/mclinker/include
153
154art_cflags := \
155 -fno-rtti \
156 -std=gnu++11 \
157 -ggdb3 \
158 -Wall \
159 -Werror \
160 -Wextra \
161 -Wno-sign-promo \
162 -Wno-unused-parameter \
163 -Wstrict-aliasing \
Andreas Gampe29b38412014-08-13 00:15:43 -0700164 -fstrict-aliasing \
Ian Rogers07140832014-09-30 15:43:59 -0700165 -Wunreachable-code \
Andreas Gampe29b38412014-08-13 00:15:43 -0700166 -fvisibility=protected
Ian Rogersafd9acc2014-06-17 08:21:54 -0700167
168ART_TARGET_CLANG_CFLAGS :=
169ART_TARGET_CLANG_CFLAGS_arm :=
170ART_TARGET_CLANG_CFLAGS_arm64 :=
171ART_TARGET_CLANG_CFLAGS_mips :=
172ART_TARGET_CLANG_CFLAGS_x86 :=
173ART_TARGET_CLANG_CFLAGS_x86_64 :=
174
Ian Rogersd642a912014-10-02 09:41:44 -0700175# These are necessary for Clang ARM64 ART builds. TODO: remove.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700176ART_TARGET_CLANG_CFLAGS_arm64 += \
177 -Wno-implicit-exception-spec-mismatch \
178 -DNVALGRIND \
179 -Wno-unused-value
180
181ifeq ($(ART_SMALL_MODE),true)
182 art_cflags += -DART_SMALL_MODE=1
183endif
184
185ifeq ($(ART_SEA_IR_MODE),true)
186 art_cflags += -DART_SEA_IR_MODE=1
187endif
188
189art_non_debug_cflags := \
190 -O3
191
Stephen Hines67a43382014-07-17 01:49:18 -0700192art_host_non_debug_cflags := \
193 $(art_non_debug_cflags)
194
195art_target_non_debug_cflags := \
196 $(art_non_debug_cflags)
197
Ian Rogersafd9acc2014-06-17 08:21:54 -0700198ifeq ($(HOST_OS),linux)
Stephen Hines67a43382014-07-17 01:49:18 -0700199 # Larger frame-size for host clang builds today
Stephen Hines11597272014-07-23 19:47:35 -0700200 art_host_non_debug_cflags += -Wframe-larger-than=2600
Stephen Hines67a43382014-07-17 01:49:18 -0700201 art_target_non_debug_cflags += -Wframe-larger-than=1728
Ian Rogersafd9acc2014-06-17 08:21:54 -0700202endif
203
204# FIXME: upstream LLVM has a vectorizer bug that needs to be fixed
205ART_TARGET_CLANG_CFLAGS_arm64 += \
206 -fno-vectorize
207
208art_debug_cflags := \
209 -O1 \
210 -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
211 -UNDEBUG
212
213ifndef LIBART_IMG_HOST_BASE_ADDRESS
214 $(error LIBART_IMG_HOST_BASE_ADDRESS unset)
215endif
216ART_HOST_CFLAGS := $(art_cflags) -DANDROID_SMP=1 -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS)
217ART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default
218ART_HOST_CFLAGS += $(ART_DEFAULT_GC_TYPE_CFLAGS)
219
220ifndef LIBART_IMG_TARGET_BASE_ADDRESS
221 $(error LIBART_IMG_TARGET_BASE_ADDRESS unset)
222endif
223ART_TARGET_CFLAGS := $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS)
Alex Lighta59dd802014-07-02 16:28:08 -0700224
225ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA
226 LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA=-0x1000000
227endif
228ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA
229 LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA=0x1000000
230endif
231ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
232ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
233
234ifndef LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA
235 LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA=-0x1000000
236endif
237ifndef LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA
238 LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA=0x1000000
239endif
240ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA)
241ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA)
242
Ian Rogersd642a912014-10-02 09:41:44 -0700243# Colorize clang compiler warnings.
244ifeq ($(ART_HOST_CLANG),true)
245 ART_HOST_CFLAGS += -fcolor-diagnostics
246endif
247ifeq ($(ART_TARGET_CLANG),true)
248 ART_TARGET_CFLAGS += -fcolor-diagnostics
249endif
250
Dehao Chen997660d2014-07-08 10:00:56 -0700251ART_TARGET_LDFLAGS :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700252ifeq ($(TARGET_CPU_SMP),true)
253 ART_TARGET_CFLAGS += -DANDROID_SMP=1
254else
255 ifeq ($(TARGET_CPU_SMP),false)
256 ART_TARGET_CFLAGS += -DANDROID_SMP=0
257 else
258 $(warning TARGET_CPU_SMP should be (true|false), found $(TARGET_CPU_SMP))
259 # Make sure we emit barriers for the worst case.
260 ART_TARGET_CFLAGS += -DANDROID_SMP=1
261 endif
262endif
263ART_TARGET_CFLAGS += $(ART_DEFAULT_GC_TYPE_CFLAGS)
264
265# DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES is set in ../build/core/dex_preopt.mk based on
266# the TARGET_CPU_VARIANT
267ifeq ($(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
268$(error Required DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES is not set)
269endif
270ART_TARGET_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
271
272# Enable thread-safety for GCC 4.6, and clang, but not for GCC 4.7 or later where this feature was
273# removed. Warn when -Wthread-safety is not used.
274ifneq ($(filter 4.6 4.6.%, $(TARGET_GCC_VERSION)),)
275 ART_TARGET_CFLAGS += -Wthread-safety
276else
277 # FIXME: add -Wthread-safety when the problem is fixed
278 ifeq ($(ART_TARGET_CLANG),true)
279 ART_TARGET_CFLAGS +=
280 else
281 # Warn if -Wthread-safety is not supported and not doing a top-level or 'mma' build.
282 ifneq ($(ONE_SHOT_MAKEFILE),)
283 # Enable target GCC 4.6 with: export TARGET_GCC_VERSION_EXP=4.6
284 $(info Using target GCC $(TARGET_GCC_VERSION) disables thread-safety checks.)
285 endif
286 endif
287endif
288# We compile with GCC 4.6 or clang on the host, both of which support -Wthread-safety.
289ART_HOST_CFLAGS += -Wthread-safety
290
291# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
292# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
293
294# Addition CPU specific CFLAGS.
295ifeq ($(TARGET_ARCH),arm)
296 ifneq ($(filter cortex-a15, $(TARGET_CPU_VARIANT)),)
297 # Fake a ARM feature for LPAE support.
298 ART_TARGET_CFLAGS += -D__ARM_FEATURE_LPAE=1
299 endif
300endif
301
Stephen Hines67a43382014-07-17 01:49:18 -0700302ART_HOST_NON_DEBUG_CFLAGS := $(art_host_non_debug_cflags)
303ART_TARGET_NON_DEBUG_CFLAGS := $(art_target_non_debug_cflags)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700304
305# TODO: move -fkeep-inline-functions to art_debug_cflags when target gcc > 4.4 (and -lsupc++)
306ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags) -fkeep-inline-functions
307ART_HOST_DEBUG_LDLIBS := -lsupc++
308
309ifneq ($(HOST_OS),linux)
310 # Some Mac OS pthread header files are broken with -fkeep-inline-functions.
311 ART_HOST_DEBUG_CFLAGS := $(filter-out -fkeep-inline-functions,$(ART_HOST_DEBUG_CFLAGS))
312 # Mac OS doesn't have libsupc++.
313 ART_HOST_DEBUG_LDLIBS := $(filter-out -lsupc++,$(ART_HOST_DEBUG_LDLIBS))
314endif
315
316ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
317
318# $(1): ndebug_or_debug
319define set-target-local-cflags-vars
320 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
321 LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86)
Dehao Chen997660d2014-07-08 10:00:56 -0700322 LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700323 art_target_cflags_ndebug_or_debug := $(1)
324 ifeq ($$(art_target_cflags_ndebug_or_debug),debug)
325 LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
326 else
327 LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
328 endif
329
330 # TODO: Also set when ART_TARGET_CLANG_$(arch)!=false and ART_TARGET_CLANG==true
331 $(foreach arch,$(ART_SUPPORTED_ARCH),
332 ifeq ($$(ART_TARGET_CLANG_$(arch)),true)
333 LOCAL_CFLAGS_$(arch) += $$(ART_TARGET_CLANG_CFLAGS_$(arch))
334 endif)
335
336 # Clear locally used variables.
337 art_target_cflags_ndebug_or_debug :=
338endef
339
340ART_BUILD_TARGET := false
341ART_BUILD_HOST := false
342ART_BUILD_NDEBUG := false
343ART_BUILD_DEBUG := false
344ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
345 ART_BUILD_TARGET := true
346 ART_BUILD_NDEBUG := true
347endif
348ifeq ($(ART_BUILD_TARGET_DEBUG),true)
349 ART_BUILD_TARGET := true
350 ART_BUILD_DEBUG := true
351endif
352ifeq ($(ART_BUILD_HOST_NDEBUG),true)
353 ART_BUILD_HOST := true
354 ART_BUILD_NDEBUG := true
355endif
356ifeq ($(ART_BUILD_HOST_DEBUG),true)
357 ART_BUILD_HOST := true
358 ART_BUILD_DEBUG := true
359endif
360
361# Clear locally defined variables that aren't necessary in the rest of the build system.
362ART_DEFAULT_GC_TYPE :=
363ART_DEFAULT_GC_TYPE_CFLAGS :=
364art_cflags :=
Stephen Hines67a43382014-07-17 01:49:18 -0700365art_target_non_debug_cflags :=
366art_host_non_debug_cflags :=
367art_non_debug_cflags :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700368
369endif # ANDROID_COMMON_BUILD_MK