blob: 42049deb08b2a7088f896f5985ffff29e9e8eec5 [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#
96ART_DEFAULT_GC_TYPE ?= CMS
97ART_DEFAULT_GC_TYPE_CFLAGS := -DART_DEFAULT_GC_TYPE_IS_$(ART_DEFAULT_GC_TYPE)
98
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
105# Clang build support.
106
107# Host.
108ART_HOST_CLANG := false
109ifneq ($(WITHOUT_HOST_CLANG),true)
110 # By default, host builds use clang for better warnings.
111 ART_HOST_CLANG := true
112endif
113
Sebastien Hertzea521dc2014-06-25 18:50:01 +0200114# Clang on the target. Target builds use GCC by default.
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +0200115ifneq ($(USE_CLANG_PLATFORM_BUILD),)
116ART_TARGET_CLANG := $(USE_CLANG_PLATFORM_BUILD)
117else
Ian Rogersd642a912014-10-02 09:41:44 -0700118ART_TARGET_CLANG := false
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +0200119endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700120ART_TARGET_CLANG_arm :=
Sebastien Hertzea521dc2014-06-25 18:50:01 +0200121ART_TARGET_CLANG_arm64 :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700122ART_TARGET_CLANG_mips :=
123ART_TARGET_CLANG_x86 :=
124ART_TARGET_CLANG_x86_64 :=
125
126define set-target-local-clang-vars
127 LOCAL_CLANG := $(ART_TARGET_CLANG)
128 $(foreach arch,$(ART_TARGET_SUPPORTED_ARCH),
129 ifneq ($$(ART_TARGET_CLANG_$(arch)),)
130 LOCAL_CLANG_$(arch) := $$(ART_TARGET_CLANG_$(arch))
131 endif)
132endef
133
134ART_CPP_EXTENSION := .cc
135
Ian Rogersafd9acc2014-06-17 08:21:54 -0700136ART_C_INCLUDES := \
137 external/gtest/include \
138 external/valgrind/main/include \
139 external/valgrind/main \
140 external/vixl/src \
141 external/zlib \
142 frameworks/compile/mclinker/include
143
144art_cflags := \
145 -fno-rtti \
146 -std=gnu++11 \
147 -ggdb3 \
148 -Wall \
149 -Werror \
150 -Wextra \
151 -Wno-sign-promo \
152 -Wno-unused-parameter \
153 -Wstrict-aliasing \
Andreas Gampe29b38412014-08-13 00:15:43 -0700154 -fstrict-aliasing \
Ian Rogers07140832014-09-30 15:43:59 -0700155 -Wunreachable-code \
Andreas Gampe29b38412014-08-13 00:15:43 -0700156 -fvisibility=protected
Ian Rogersafd9acc2014-06-17 08:21:54 -0700157
158ART_TARGET_CLANG_CFLAGS :=
159ART_TARGET_CLANG_CFLAGS_arm :=
160ART_TARGET_CLANG_CFLAGS_arm64 :=
161ART_TARGET_CLANG_CFLAGS_mips :=
162ART_TARGET_CLANG_CFLAGS_x86 :=
163ART_TARGET_CLANG_CFLAGS_x86_64 :=
164
Ian Rogersd642a912014-10-02 09:41:44 -0700165# These are necessary for Clang ARM64 ART builds. TODO: remove.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700166ART_TARGET_CLANG_CFLAGS_arm64 += \
167 -Wno-implicit-exception-spec-mismatch \
168 -DNVALGRIND \
169 -Wno-unused-value
170
171ifeq ($(ART_SMALL_MODE),true)
172 art_cflags += -DART_SMALL_MODE=1
173endif
174
175ifeq ($(ART_SEA_IR_MODE),true)
176 art_cflags += -DART_SEA_IR_MODE=1
177endif
178
179art_non_debug_cflags := \
180 -O3
181
Stephen Hines67a43382014-07-17 01:49:18 -0700182art_host_non_debug_cflags := \
183 $(art_non_debug_cflags)
184
185art_target_non_debug_cflags := \
186 $(art_non_debug_cflags)
187
Ian Rogersafd9acc2014-06-17 08:21:54 -0700188ifeq ($(HOST_OS),linux)
Stephen Hines67a43382014-07-17 01:49:18 -0700189 # Larger frame-size for host clang builds today
Stephen Hines11597272014-07-23 19:47:35 -0700190 art_host_non_debug_cflags += -Wframe-larger-than=2600
Stephen Hines67a43382014-07-17 01:49:18 -0700191 art_target_non_debug_cflags += -Wframe-larger-than=1728
Ian Rogersafd9acc2014-06-17 08:21:54 -0700192endif
193
194# FIXME: upstream LLVM has a vectorizer bug that needs to be fixed
195ART_TARGET_CLANG_CFLAGS_arm64 += \
196 -fno-vectorize
197
198art_debug_cflags := \
Ian Rogers59c07062014-10-10 13:03:39 -0700199 -O2 \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700200 -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
201 -UNDEBUG
202
203ifndef LIBART_IMG_HOST_BASE_ADDRESS
204 $(error LIBART_IMG_HOST_BASE_ADDRESS unset)
205endif
206ART_HOST_CFLAGS := $(art_cflags) -DANDROID_SMP=1 -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS)
207ART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default
208ART_HOST_CFLAGS += $(ART_DEFAULT_GC_TYPE_CFLAGS)
209
210ifndef LIBART_IMG_TARGET_BASE_ADDRESS
211 $(error LIBART_IMG_TARGET_BASE_ADDRESS unset)
212endif
213ART_TARGET_CFLAGS := $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS)
Alex Lighta59dd802014-07-02 16:28:08 -0700214
215ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA
216 LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA=-0x1000000
217endif
218ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA
219 LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA=0x1000000
220endif
221ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
222ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
223
224ifndef LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA
225 LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA=-0x1000000
226endif
227ifndef LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA
228 LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA=0x1000000
229endif
230ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA)
231ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA)
232
Ian Rogersd642a912014-10-02 09:41:44 -0700233# Colorize clang compiler warnings.
Ian Rogersfc787ec2014-10-09 21:56:44 -0700234art_clang_cflags := -fcolor-diagnostics
235
236# Warn if switch fallthroughs aren't annotated.
237art_clang_cflags += -Wimplicit-fallthrough
238
Ian Rogersd642a912014-10-02 09:41:44 -0700239ifeq ($(ART_HOST_CLANG),true)
Ian Rogersfc787ec2014-10-09 21:56:44 -0700240 ART_HOST_CFLAGS += $(art_clang_cflags)
Ian Rogersd642a912014-10-02 09:41:44 -0700241endif
242ifeq ($(ART_TARGET_CLANG),true)
Ian Rogersfc787ec2014-10-09 21:56:44 -0700243 ART_TARGET_CFLAGS += $(art_clang_cflags)
Ian Rogersd642a912014-10-02 09:41:44 -0700244endif
245
Ian Rogersfc787ec2014-10-09 21:56:44 -0700246art_clang_cflags :=
247
Dehao Chen997660d2014-07-08 10:00:56 -0700248ART_TARGET_LDFLAGS :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700249ifeq ($(TARGET_CPU_SMP),true)
250 ART_TARGET_CFLAGS += -DANDROID_SMP=1
251else
252 ifeq ($(TARGET_CPU_SMP),false)
253 ART_TARGET_CFLAGS += -DANDROID_SMP=0
254 else
255 $(warning TARGET_CPU_SMP should be (true|false), found $(TARGET_CPU_SMP))
256 # Make sure we emit barriers for the worst case.
257 ART_TARGET_CFLAGS += -DANDROID_SMP=1
258 endif
259endif
260ART_TARGET_CFLAGS += $(ART_DEFAULT_GC_TYPE_CFLAGS)
261
262# DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES is set in ../build/core/dex_preopt.mk based on
263# the TARGET_CPU_VARIANT
264ifeq ($(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
265$(error Required DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES is not set)
266endif
267ART_TARGET_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
268
269# Enable thread-safety for GCC 4.6, and clang, but not for GCC 4.7 or later where this feature was
270# removed. Warn when -Wthread-safety is not used.
271ifneq ($(filter 4.6 4.6.%, $(TARGET_GCC_VERSION)),)
272 ART_TARGET_CFLAGS += -Wthread-safety
273else
274 # FIXME: add -Wthread-safety when the problem is fixed
275 ifeq ($(ART_TARGET_CLANG),true)
276 ART_TARGET_CFLAGS +=
277 else
278 # Warn if -Wthread-safety is not supported and not doing a top-level or 'mma' build.
279 ifneq ($(ONE_SHOT_MAKEFILE),)
280 # Enable target GCC 4.6 with: export TARGET_GCC_VERSION_EXP=4.6
281 $(info Using target GCC $(TARGET_GCC_VERSION) disables thread-safety checks.)
282 endif
283 endif
284endif
285# We compile with GCC 4.6 or clang on the host, both of which support -Wthread-safety.
286ART_HOST_CFLAGS += -Wthread-safety
287
288# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
289# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
290
291# Addition CPU specific CFLAGS.
292ifeq ($(TARGET_ARCH),arm)
293 ifneq ($(filter cortex-a15, $(TARGET_CPU_VARIANT)),)
294 # Fake a ARM feature for LPAE support.
295 ART_TARGET_CFLAGS += -D__ARM_FEATURE_LPAE=1
296 endif
297endif
298
Stephen Hines67a43382014-07-17 01:49:18 -0700299ART_HOST_NON_DEBUG_CFLAGS := $(art_host_non_debug_cflags)
300ART_TARGET_NON_DEBUG_CFLAGS := $(art_target_non_debug_cflags)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700301
302# TODO: move -fkeep-inline-functions to art_debug_cflags when target gcc > 4.4 (and -lsupc++)
303ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags) -fkeep-inline-functions
304ART_HOST_DEBUG_LDLIBS := -lsupc++
305
306ifneq ($(HOST_OS),linux)
307 # Some Mac OS pthread header files are broken with -fkeep-inline-functions.
308 ART_HOST_DEBUG_CFLAGS := $(filter-out -fkeep-inline-functions,$(ART_HOST_DEBUG_CFLAGS))
309 # Mac OS doesn't have libsupc++.
310 ART_HOST_DEBUG_LDLIBS := $(filter-out -lsupc++,$(ART_HOST_DEBUG_LDLIBS))
311endif
312
313ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
314
315# $(1): ndebug_or_debug
316define set-target-local-cflags-vars
317 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
318 LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86)
Dehao Chen997660d2014-07-08 10:00:56 -0700319 LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700320 art_target_cflags_ndebug_or_debug := $(1)
321 ifeq ($$(art_target_cflags_ndebug_or_debug),debug)
322 LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
323 else
324 LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
325 endif
326
327 # TODO: Also set when ART_TARGET_CLANG_$(arch)!=false and ART_TARGET_CLANG==true
328 $(foreach arch,$(ART_SUPPORTED_ARCH),
329 ifeq ($$(ART_TARGET_CLANG_$(arch)),true)
330 LOCAL_CFLAGS_$(arch) += $$(ART_TARGET_CLANG_CFLAGS_$(arch))
331 endif)
332
333 # Clear locally used variables.
334 art_target_cflags_ndebug_or_debug :=
335endef
336
337ART_BUILD_TARGET := false
338ART_BUILD_HOST := false
339ART_BUILD_NDEBUG := false
340ART_BUILD_DEBUG := false
341ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
342 ART_BUILD_TARGET := true
343 ART_BUILD_NDEBUG := true
344endif
345ifeq ($(ART_BUILD_TARGET_DEBUG),true)
346 ART_BUILD_TARGET := true
347 ART_BUILD_DEBUG := true
348endif
349ifeq ($(ART_BUILD_HOST_NDEBUG),true)
350 ART_BUILD_HOST := true
351 ART_BUILD_NDEBUG := true
352endif
353ifeq ($(ART_BUILD_HOST_DEBUG),true)
354 ART_BUILD_HOST := true
355 ART_BUILD_DEBUG := true
356endif
357
358# Clear locally defined variables that aren't necessary in the rest of the build system.
359ART_DEFAULT_GC_TYPE :=
360ART_DEFAULT_GC_TYPE_CFLAGS :=
361art_cflags :=
Stephen Hines67a43382014-07-17 01:49:18 -0700362art_target_non_debug_cflags :=
363art_host_non_debug_cflags :=
364art_non_debug_cflags :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700365
366endif # ANDROID_COMMON_BUILD_MK