blob: f05ca87f2442649d2cb4099eee2f855d1f393263 [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
Igor Murashkin37743352014-11-13 14:38:00 -080017ifndef ART_ANDROID_COMMON_BUILD_MK
18ART_ANDROID_COMMON_BUILD_MK = true
Ian Rogersafd9acc2014-06-17 08:21:54 -070019
20include art/build/Android.common.mk
Igor Murashkin37743352014-11-13 14:38:00 -080021include art/build/Android.common_utils.mk
Ian Rogersafd9acc2014-06-17 08:21:54 -070022
23# These can be overridden via the environment or by editing to
24# enable/disable certain build configuration.
25#
26# For example, to disable everything but the host debug build you use:
27#
28# (export ART_BUILD_TARGET_NDEBUG=false && export ART_BUILD_TARGET_DEBUG=false && export ART_BUILD_HOST_NDEBUG=false && ...)
29#
30# Beware that tests may use the non-debug build for performance, notable 055-enum-performance
31#
32ART_BUILD_TARGET_NDEBUG ?= true
33ART_BUILD_TARGET_DEBUG ?= true
34ART_BUILD_HOST_NDEBUG ?= true
35ART_BUILD_HOST_DEBUG ?= true
36
37ifeq ($(ART_BUILD_TARGET_NDEBUG),false)
38$(info Disabling ART_BUILD_TARGET_NDEBUG)
39endif
40ifeq ($(ART_BUILD_TARGET_DEBUG),false)
41$(info Disabling ART_BUILD_TARGET_DEBUG)
42endif
43ifeq ($(ART_BUILD_HOST_NDEBUG),false)
44$(info Disabling ART_BUILD_HOST_NDEBUG)
45endif
46ifeq ($(ART_BUILD_HOST_DEBUG),false)
47$(info Disabling ART_BUILD_HOST_DEBUG)
48endif
49
50#
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080051# Used to enable JIT
52#
53ART_JIT := false
54ifneq ($(wildcard art/JIT_ART),)
55$(info Enabling ART_JIT because of existence of art/JIT_ART)
56ART_JIT := true
57endif
58ifeq ($(WITH_ART_JIT), true)
59ART_JIT := true
60endif
61
62#
Ian Rogersafd9acc2014-06-17 08:21:54 -070063# Used to enable smart mode
64#
65ART_SMALL_MODE := false
66ifneq ($(wildcard art/SMALL_ART),)
67$(info Enabling ART_SMALL_MODE because of existence of art/SMALL_ART)
68ART_SMALL_MODE := true
69endif
70ifeq ($(WITH_ART_SMALL_MODE), true)
71ART_SMALL_MODE := true
72endif
73
74#
Ian Rogersafd9acc2014-06-17 08:21:54 -070075# Used to change the default GC. Valid values are CMS, SS, GSS. The default is CMS.
76#
Ian Rogers6f3dbba2014-10-14 17:41:57 -070077art_default_gc_type ?= CMS
78art_default_gc_type_cflags := -DART_DEFAULT_GC_TYPE_IS_$(art_default_gc_type)
Ian Rogersafd9acc2014-06-17 08:21:54 -070079
Andreas Gampeee0ebc82014-10-21 21:07:28 -070080ART_HOST_CFLAGS :=
81ART_TARGET_CFLAGS :=
82
Ian Rogersafd9acc2014-06-17 08:21:54 -070083# Clang build support.
84
85# Host.
86ART_HOST_CLANG := false
87ifneq ($(WITHOUT_HOST_CLANG),true)
88 # By default, host builds use clang for better warnings.
89 ART_HOST_CLANG := true
90endif
91
Sebastien Hertzea521dc2014-06-25 18:50:01 +020092# Clang on the target. Target builds use GCC by default.
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +020093ifneq ($(USE_CLANG_PLATFORM_BUILD),)
94ART_TARGET_CLANG := $(USE_CLANG_PLATFORM_BUILD)
95else
Ian Rogersd642a912014-10-02 09:41:44 -070096ART_TARGET_CLANG := false
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +020097endif
Chih-Hung Hsieh86bb22e2014-12-18 19:25:50 -080098
Andreas Gampe89866b72015-01-13 18:12:36 -080099ifeq ($(TARGET_ARCH)|$(ART_TARGET_CLANG),mips|true)
Chih-Hung Hsieh86bb22e2014-12-18 19:25:50 -0800100 # b/18807290, Clang generated mips assembly code for array.cc
101 # cannot be compiled by gas.
102 # b/18789639, Clang assembler cannot compile inlined assembly code in
103 # valgrind_malloc_space-inl.h:192:5: error: used $at without ".set noat"
104 $(warning Clang is disabled for the mips target)
105endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700106ART_TARGET_CLANG_arm :=
Sebastien Hertzea521dc2014-06-25 18:50:01 +0200107ART_TARGET_CLANG_arm64 :=
Chih-Hung Hsieh86bb22e2014-12-18 19:25:50 -0800108# TODO: Enable clang mips when b/18807290 and b/18789639 are fixed.
109ART_TARGET_CLANG_mips := false
Andreas Gampe1a5c4062015-01-15 12:10:47 -0800110ART_TARGET_CLANG_mips64 := false
Ian Rogersafd9acc2014-06-17 08:21:54 -0700111ART_TARGET_CLANG_x86 :=
112ART_TARGET_CLANG_x86_64 :=
113
114define set-target-local-clang-vars
115 LOCAL_CLANG := $(ART_TARGET_CLANG)
116 $(foreach arch,$(ART_TARGET_SUPPORTED_ARCH),
117 ifneq ($$(ART_TARGET_CLANG_$(arch)),)
118 LOCAL_CLANG_$(arch) := $$(ART_TARGET_CLANG_$(arch))
119 endif)
120endef
121
Ian Rogersafd9acc2014-06-17 08:21:54 -0700122ART_TARGET_CLANG_CFLAGS :=
123ART_TARGET_CLANG_CFLAGS_arm :=
124ART_TARGET_CLANG_CFLAGS_arm64 :=
125ART_TARGET_CLANG_CFLAGS_mips :=
Andreas Gampe1a5c4062015-01-15 12:10:47 -0800126ART_TARGET_CLANG_CFLAGS_mips64 :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700127ART_TARGET_CLANG_CFLAGS_x86 :=
128ART_TARGET_CLANG_CFLAGS_x86_64 :=
129
Ian Rogersd642a912014-10-02 09:41:44 -0700130# These are necessary for Clang ARM64 ART builds. TODO: remove.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700131ART_TARGET_CLANG_CFLAGS_arm64 += \
Andreas Gampe685fbe42015-01-27 14:36:38 -0800132 -DNVALGRIND
Ian Rogersafd9acc2014-06-17 08:21:54 -0700133
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700134# FIXME: upstream LLVM has a vectorizer bug that needs to be fixed
135ART_TARGET_CLANG_CFLAGS_arm64 += \
136 -fno-vectorize
137
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700138# Warn about thread safety violations with clang.
Dan Albert6c7cdc52014-12-02 14:58:06 -0800139art_clang_cflags := -Wthread-safety
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700140
141# Warn if switch fallthroughs aren't annotated.
142art_clang_cflags += -Wimplicit-fallthrough
143
144# Enable float equality warnings.
145art_clang_cflags += -Wfloat-equal
146
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800147# Enable warning of converting ints to void*.
148art_clang_cflags += -Wint-to-void-pointer-cast
149
150# GCC-only warnings.
151art_gcc_cflags := -Wunused-but-set-parameter
152# Suggest const: too many false positives, but good for a trial run.
153# -Wsuggest-attribute=const
154# Useless casts: too many, as we need to be 32/64 agnostic, but the compiler knows.
155# -Wuseless-cast
156# Zero-as-null: Have to convert all NULL and "diagnostic ignore" all includes like libnativehelper
157# that are still stuck pre-C++11.
158# -Wzero-as-null-pointer-constant \
159# Suggest final: Have to move to a more recent GCC.
160# -Wsuggest-final-types
161
Andreas Gampebced67d2015-01-07 14:35:44 -0800162ART_TARGET_CLANG_CFLAGS := $(art_clang_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700163ifeq ($(ART_HOST_CLANG),true)
Ian Rogers4ad5cd32014-11-11 23:08:07 -0800164 # Bug: 15446488. We don't omit the frame pointer to work around
165 # clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
166 ART_HOST_CFLAGS += $(art_clang_cflags) -fno-omit-frame-pointer
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800167else
168 ART_HOST_CFLAGS += $(art_gcc_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700169endif
Andreas Gampebced67d2015-01-07 14:35:44 -0800170ifneq ($(ART_TARGET_CLANG),true)
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800171 ART_TARGET_CFLAGS += $(art_gcc_cflags)
Andreas Gampebced67d2015-01-07 14:35:44 -0800172else
173 # TODO: if we ever want to support GCC/Clang mix for multi-target products, this needs to be
174 # split up.
175 ifeq ($(ART_TARGET_CLANG_$(TARGET_ARCH)),false)
176 ART_TARGET_CFLAGS += $(art_gcc_cflags)
177 endif
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700178endif
179
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800180# Clear local variables now their use has ended.
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700181art_clang_cflags :=
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800182art_gcc_cflags :=
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700183
184ART_CPP_EXTENSION := .cc
185
186ART_C_INCLUDES := \
187 external/gtest/include \
188 external/valgrind/main/include \
189 external/valgrind/main \
190 external/vixl/src \
191 external/zlib \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700192
193# Base set of cflags used by all things ART.
194art_cflags := \
195 -fno-rtti \
196 -std=gnu++11 \
197 -ggdb3 \
198 -Wall \
199 -Werror \
200 -Wextra \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700201 -Wstrict-aliasing \
202 -fstrict-aliasing \
203 -Wunreachable-code \
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800204 -Wredundant-decls \
205 -Wshadow \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700206 -fvisibility=protected \
207 $(art_default_gc_type_cflags)
208
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800209# Missing declarations: too many at the moment, as we use "extern" quite a bit.
210# -Wmissing-declarations \
211
212
Mathieu Chartiercd195fe2014-11-25 18:36:01 -0800213
214ifdef ART_IMT_SIZE
215 art_cflags += -DIMT_SIZE=$(ART_IMT_SIZE)
216else
217 # Default is 64
218 art_cflags += -DIMT_SIZE=64
219endif
220
Ian Rogersafd9acc2014-06-17 08:21:54 -0700221ifeq ($(ART_SMALL_MODE),true)
222 art_cflags += -DART_SMALL_MODE=1
223endif
224
Nicolas Geoffray9bb492a2014-11-25 23:42:00 +0000225ifeq ($(ART_USE_OPTIMIZING_COMPILER),true)
226 art_cflags += -DART_USE_OPTIMIZING_COMPILER=1
227endif
228
Hiroshi Yamauchib0d22f12014-12-08 12:08:46 -0800229ifeq ($(ART_HEAP_POISONING),true)
230 art_cflags += -DART_HEAP_POISONING=1
231endif
232
Hiroshi Yamauchic23f0d82015-01-23 17:23:42 -0800233ifeq ($(ART_USE_READ_BARRIER),true)
234 art_cflags += -DART_USE_READ_BARRIER=1
235endif
236
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700237# Cflags for non-debug ART and ART tools.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700238art_non_debug_cflags := \
239 -O3
240
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700241# Cflags for debug ART and ART tools.
242art_debug_cflags := \
Nicolas Geoffray40e7f0e2015-02-03 10:13:27 +0000243 -O2 \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700244 -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
Serban Constantinescu32f5b4d2014-11-25 20:05:46 +0000245 -DVIXL_DEBUG \
Ian Rogers50fe6da2014-10-17 01:18:08 -0700246 -UNDEBUG
Stephen Hines67a43382014-07-17 01:49:18 -0700247
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700248art_host_non_debug_cflags := $(art_non_debug_cflags)
249art_target_non_debug_cflags := $(art_non_debug_cflags)
Stephen Hines67a43382014-07-17 01:49:18 -0700250
Ian Rogersafd9acc2014-06-17 08:21:54 -0700251ifeq ($(HOST_OS),linux)
Stephen Hines67a43382014-07-17 01:49:18 -0700252 # Larger frame-size for host clang builds today
Dan Albert31fb2602014-09-30 22:10:10 -0700253 ifneq ($(ART_COVERAGE),true)
254 ifneq ($(NATIVE_COVERAGE),true)
255 ifndef SANITIZE_HOST
256 art_host_non_debug_cflags += -Wframe-larger-than=2700
257 endif
258 art_target_non_debug_cflags += -Wframe-larger-than=1728
259 endif
Dan Albert98b8bcf2014-11-14 19:56:21 -0800260 endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700261endif
262
Ying Wanga28ff0f2014-12-08 14:29:34 -0800263ifndef LIBART_IMG_HOST_BASE_ADDRESS
264 $(error LIBART_IMG_HOST_BASE_ADDRESS unset)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700265endif
Ying Wanga28ff0f2014-12-08 14:29:34 -0800266ART_HOST_CFLAGS += $(art_cflags) -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS)
267ART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default
268
269ifndef LIBART_IMG_TARGET_BASE_ADDRESS
270 $(error LIBART_IMG_TARGET_BASE_ADDRESS unset)
271endif
272ART_TARGET_CFLAGS += $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS)
Alex Lighta59dd802014-07-02 16:28:08 -0700273
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700274ART_HOST_NON_DEBUG_CFLAGS := $(art_host_non_debug_cflags)
275ART_TARGET_NON_DEBUG_CFLAGS := $(art_target_non_debug_cflags)
276ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags)
277ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
278
Alex Lighta59dd802014-07-02 16:28:08 -0700279ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA
280 LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA=-0x1000000
281endif
282ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA
283 LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA=0x1000000
284endif
285ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
286ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
287
288ifndef LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA
289 LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA=-0x1000000
290endif
291ifndef LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA
292 LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA=0x1000000
293endif
294ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA)
295ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA)
296
Ian Rogersafd9acc2014-06-17 08:21:54 -0700297# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
298# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
299
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700300# Clear locals now they've served their purpose.
301art_cflags :=
302art_debug_cflags :=
303art_non_debug_cflags :=
304art_host_non_debug_cflags :=
305art_target_non_debug_cflags :=
306art_default_gc_type :=
307art_default_gc_type_cflags :=
308
309ART_HOST_LDLIBS :=
310ifneq ($(ART_HOST_CLANG),true)
311 # GCC lacks libc++ assumed atomic operations, grab via libatomic.
312 ART_HOST_LDLIBS += -latomic
Ian Rogersafd9acc2014-06-17 08:21:54 -0700313endif
314
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700315ART_TARGET_LDFLAGS :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700316
317# $(1): ndebug_or_debug
318define set-target-local-cflags-vars
319 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
320 LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86)
Dehao Chen997660d2014-07-08 10:00:56 -0700321 LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700322 art_target_cflags_ndebug_or_debug := $(1)
323 ifeq ($$(art_target_cflags_ndebug_or_debug),debug)
324 LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
325 else
326 LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
327 endif
328
Andreas Gampebced67d2015-01-07 14:35:44 -0800329 LOCAL_CLANG_CFLAGS := $(ART_TARGET_CLANG_CFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700330 $(foreach arch,$(ART_SUPPORTED_ARCH),
Andreas Gampebced67d2015-01-07 14:35:44 -0800331 LOCAL_CLANG_CFLAGS_$(arch) += $$(ART_TARGET_CLANG_CFLAGS_$(arch)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700332
333 # Clear locally used variables.
334 art_target_cflags_ndebug_or_debug :=
335endef
336
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700337# Support for disabling certain builds.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700338ART_BUILD_TARGET := false
339ART_BUILD_HOST := false
340ART_BUILD_NDEBUG := false
341ART_BUILD_DEBUG := false
342ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
343 ART_BUILD_TARGET := true
344 ART_BUILD_NDEBUG := true
345endif
346ifeq ($(ART_BUILD_TARGET_DEBUG),true)
347 ART_BUILD_TARGET := true
348 ART_BUILD_DEBUG := true
349endif
350ifeq ($(ART_BUILD_HOST_NDEBUG),true)
351 ART_BUILD_HOST := true
352 ART_BUILD_NDEBUG := true
353endif
354ifeq ($(ART_BUILD_HOST_DEBUG),true)
355 ART_BUILD_HOST := true
356 ART_BUILD_DEBUG := true
357endif
358
Igor Murashkin37743352014-11-13 14:38:00 -0800359endif # ART_ANDROID_COMMON_BUILD_MK