blob: 77f39c49e9c2f7b8d40b9a7f06b9373e72d9ec41 [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
Calin Juravledc561612015-07-02 11:51:22 +010036ART_BUILD_HOST_STATIC ?= true
Ian Rogersafd9acc2014-06-17 08:21:54 -070037
Calin Juravle4895ea42015-07-02 18:21:14 +010038# Asan does not support static linkage
39ifdef SANITIZE_HOST
40 ART_BUILD_HOST_STATIC := false
41endif
42
43ifneq ($$(HOST_OS),linux)
44 ART_BUILD_HOST_STATIC := false
45endif
46
Ian Rogersafd9acc2014-06-17 08:21:54 -070047ifeq ($(ART_BUILD_TARGET_NDEBUG),false)
48$(info Disabling ART_BUILD_TARGET_NDEBUG)
49endif
50ifeq ($(ART_BUILD_TARGET_DEBUG),false)
51$(info Disabling ART_BUILD_TARGET_DEBUG)
52endif
53ifeq ($(ART_BUILD_HOST_NDEBUG),false)
54$(info Disabling ART_BUILD_HOST_NDEBUG)
55endif
56ifeq ($(ART_BUILD_HOST_DEBUG),false)
57$(info Disabling ART_BUILD_HOST_DEBUG)
58endif
Calin Juravle65e069d2015-06-08 10:35:24 +010059ifeq ($(ART_BUILD_HOST_STATIC),true)
60$(info Enabling ART_BUILD_HOST_STATIC)
61endif
Ian Rogersafd9acc2014-06-17 08:21:54 -070062
63#
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080064# Used to enable JIT
65#
66ART_JIT := false
67ifneq ($(wildcard art/JIT_ART),)
68$(info Enabling ART_JIT because of existence of art/JIT_ART)
69ART_JIT := true
70endif
71ifeq ($(WITH_ART_JIT), true)
72ART_JIT := true
73endif
74
75#
Ian Rogersafd9acc2014-06-17 08:21:54 -070076# Used to change the default GC. Valid values are CMS, SS, GSS. The default is CMS.
77#
Hiroshi Yamauchi3e781622015-02-25 12:52:34 -080078ART_DEFAULT_GC_TYPE ?= CMS
79art_default_gc_type_cflags := -DART_DEFAULT_GC_TYPE_IS_$(ART_DEFAULT_GC_TYPE)
Ian Rogersafd9acc2014-06-17 08:21:54 -070080
Andreas Gampeee0ebc82014-10-21 21:07:28 -070081ART_HOST_CFLAGS :=
82ART_TARGET_CFLAGS :=
83
Roland Levillain12bd7212015-06-04 17:50:27 +010084ART_HOST_ASFLAGS :=
85ART_TARGET_ASFLAGS :=
86
Ian Rogersafd9acc2014-06-17 08:21:54 -070087# Clang build support.
88
89# Host.
90ART_HOST_CLANG := false
91ifneq ($(WITHOUT_HOST_CLANG),true)
92 # By default, host builds use clang for better warnings.
93 ART_HOST_CLANG := true
94endif
95
Sebastien Hertzea521dc2014-06-25 18:50:01 +020096# Clang on the target. Target builds use GCC by default.
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +020097ifneq ($(USE_CLANG_PLATFORM_BUILD),)
98ART_TARGET_CLANG := $(USE_CLANG_PLATFORM_BUILD)
99else
Ian Rogersd642a912014-10-02 09:41:44 -0700100ART_TARGET_CLANG := false
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +0200101endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700102ART_TARGET_CLANG_arm :=
Sebastien Hertzea521dc2014-06-25 18:50:01 +0200103ART_TARGET_CLANG_arm64 :=
Duane Sand91ddd0d2015-05-01 11:34:51 -0700104ART_TARGET_CLANG_mips :=
105ART_TARGET_CLANG_mips64 :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700106ART_TARGET_CLANG_x86 :=
107ART_TARGET_CLANG_x86_64 :=
108
109define set-target-local-clang-vars
110 LOCAL_CLANG := $(ART_TARGET_CLANG)
111 $(foreach arch,$(ART_TARGET_SUPPORTED_ARCH),
112 ifneq ($$(ART_TARGET_CLANG_$(arch)),)
113 LOCAL_CLANG_$(arch) := $$(ART_TARGET_CLANG_$(arch))
114 endif)
115endef
116
Ian Rogersafd9acc2014-06-17 08:21:54 -0700117ART_TARGET_CLANG_CFLAGS :=
118ART_TARGET_CLANG_CFLAGS_arm :=
119ART_TARGET_CLANG_CFLAGS_arm64 :=
120ART_TARGET_CLANG_CFLAGS_mips :=
Andreas Gampe1a5c4062015-01-15 12:10:47 -0800121ART_TARGET_CLANG_CFLAGS_mips64 :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700122ART_TARGET_CLANG_CFLAGS_x86 :=
123ART_TARGET_CLANG_CFLAGS_x86_64 :=
124
Ian Rogersd642a912014-10-02 09:41:44 -0700125# These are necessary for Clang ARM64 ART builds. TODO: remove.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700126ART_TARGET_CLANG_CFLAGS_arm64 += \
Andreas Gampe685fbe42015-01-27 14:36:38 -0800127 -DNVALGRIND
Ian Rogersafd9acc2014-06-17 08:21:54 -0700128
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700129# Warn about thread safety violations with clang.
Dan Albert6c7cdc52014-12-02 14:58:06 -0800130art_clang_cflags := -Wthread-safety
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700131
132# Warn if switch fallthroughs aren't annotated.
133art_clang_cflags += -Wimplicit-fallthrough
134
135# Enable float equality warnings.
136art_clang_cflags += -Wfloat-equal
137
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800138# Enable warning of converting ints to void*.
139art_clang_cflags += -Wint-to-void-pointer-cast
140
Andreas Gampeca714582015-04-03 19:41:34 -0700141# Enable warning of wrong unused annotations.
142art_clang_cflags += -Wused-but-marked-unused
143
Andreas Gampe758a8012015-04-03 21:28:42 -0700144# Enable warning for deprecated language features.
145art_clang_cflags += -Wdeprecated
146
Andreas Gampe66222662015-04-06 19:50:46 -0700147# Enable warning for unreachable break & return.
148art_clang_cflags += -Wunreachable-code-break -Wunreachable-code-return
149
150# Enable missing-noreturn only on non-Mac. As lots of things are not implemented for Apple, it's
151# a pain.
152ifneq ($(HOST_OS),darwin)
153 art_clang_cflags += -Wmissing-noreturn
154endif
Andreas Gampe65b798e2015-04-06 09:35:22 -0700155
Andreas Gampeca714582015-04-03 19:41:34 -0700156
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800157# GCC-only warnings.
158art_gcc_cflags := -Wunused-but-set-parameter
159# Suggest const: too many false positives, but good for a trial run.
160# -Wsuggest-attribute=const
161# Useless casts: too many, as we need to be 32/64 agnostic, but the compiler knows.
162# -Wuseless-cast
163# Zero-as-null: Have to convert all NULL and "diagnostic ignore" all includes like libnativehelper
164# that are still stuck pre-C++11.
165# -Wzero-as-null-pointer-constant \
166# Suggest final: Have to move to a more recent GCC.
167# -Wsuggest-final-types
168
Andreas Gampebced67d2015-01-07 14:35:44 -0800169ART_TARGET_CLANG_CFLAGS := $(art_clang_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700170ifeq ($(ART_HOST_CLANG),true)
Ian Rogers4ad5cd32014-11-11 23:08:07 -0800171 # Bug: 15446488. We don't omit the frame pointer to work around
172 # clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
173 ART_HOST_CFLAGS += $(art_clang_cflags) -fno-omit-frame-pointer
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800174else
175 ART_HOST_CFLAGS += $(art_gcc_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700176endif
Andreas Gampebced67d2015-01-07 14:35:44 -0800177ifneq ($(ART_TARGET_CLANG),true)
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800178 ART_TARGET_CFLAGS += $(art_gcc_cflags)
Andreas Gampebced67d2015-01-07 14:35:44 -0800179else
180 # TODO: if we ever want to support GCC/Clang mix for multi-target products, this needs to be
181 # split up.
182 ifeq ($(ART_TARGET_CLANG_$(TARGET_ARCH)),false)
183 ART_TARGET_CFLAGS += $(art_gcc_cflags)
184 endif
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700185endif
186
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800187# Clear local variables now their use has ended.
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700188art_clang_cflags :=
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800189art_gcc_cflags :=
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700190
191ART_CPP_EXTENSION := .cc
192
193ART_C_INCLUDES := \
194 external/gtest/include \
Jeff Hao848f70a2014-01-15 13:49:50 -0800195 external/icu/icu4c/source/common \
Dmitriy Ivanov6130f732015-05-27 15:34:38 -0700196 external/valgrind/include \
197 external/valgrind \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700198 external/vixl/src \
199 external/zlib \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700200
201# Base set of cflags used by all things ART.
202art_cflags := \
203 -fno-rtti \
204 -std=gnu++11 \
205 -ggdb3 \
206 -Wall \
207 -Werror \
208 -Wextra \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700209 -Wstrict-aliasing \
210 -fstrict-aliasing \
211 -Wunreachable-code \
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800212 -Wredundant-decls \
213 -Wshadow \
Andreas Gampe7c3952f2015-02-19 18:21:24 -0800214 -Wunused \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700215 -fvisibility=protected \
216 $(art_default_gc_type_cflags)
217
Roland Levillain12bd7212015-06-04 17:50:27 +0100218# Base set of asflags used by all things ART.
219art_asflags :=
220
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800221# Missing declarations: too many at the moment, as we use "extern" quite a bit.
222# -Wmissing-declarations \
223
224
Mathieu Chartiercd195fe2014-11-25 18:36:01 -0800225
226ifdef ART_IMT_SIZE
227 art_cflags += -DIMT_SIZE=$(ART_IMT_SIZE)
228else
229 # Default is 64
230 art_cflags += -DIMT_SIZE=64
231endif
232
Nicolas Geoffray9bb492a2014-11-25 23:42:00 +0000233ifeq ($(ART_USE_OPTIMIZING_COMPILER),true)
234 art_cflags += -DART_USE_OPTIMIZING_COMPILER=1
235endif
236
Hiroshi Yamauchib0d22f12014-12-08 12:08:46 -0800237ifeq ($(ART_HEAP_POISONING),true)
238 art_cflags += -DART_HEAP_POISONING=1
Roland Levillain12bd7212015-06-04 17:50:27 +0100239 art_asflags += -DART_HEAP_POISONING=1
Hiroshi Yamauchib0d22f12014-12-08 12:08:46 -0800240endif
241
Hiroshi Yamauchic23f0d82015-01-23 17:23:42 -0800242ifeq ($(ART_USE_READ_BARRIER),true)
243 art_cflags += -DART_USE_READ_BARRIER=1
Roland Levillain12bd7212015-06-04 17:50:27 +0100244 art_asflags += -DART_USE_READ_BARRIER=1
Hiroshi Yamauchic23f0d82015-01-23 17:23:42 -0800245endif
246
Hiroshi Yamauchi79bd2bf2015-03-20 10:28:34 -0700247ifeq ($(ART_USE_TLAB),true)
248 art_cflags += -DART_USE_TLAB=1
249endif
250
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700251# Cflags for non-debug ART and ART tools.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700252art_non_debug_cflags := \
253 -O3
254
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700255# Cflags for debug ART and ART tools.
256art_debug_cflags := \
Nicolas Geoffray40e7f0e2015-02-03 10:13:27 +0000257 -O2 \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700258 -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
Serban Constantinescu32f5b4d2014-11-25 20:05:46 +0000259 -DVIXL_DEBUG \
Ian Rogers50fe6da2014-10-17 01:18:08 -0700260 -UNDEBUG
Stephen Hines67a43382014-07-17 01:49:18 -0700261
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700262art_host_non_debug_cflags := $(art_non_debug_cflags)
263art_target_non_debug_cflags := $(art_non_debug_cflags)
Stephen Hines67a43382014-07-17 01:49:18 -0700264
Ian Rogersafd9acc2014-06-17 08:21:54 -0700265ifeq ($(HOST_OS),linux)
Stephen Hines67a43382014-07-17 01:49:18 -0700266 # Larger frame-size for host clang builds today
Dan Albert31fb2602014-09-30 22:10:10 -0700267 ifneq ($(ART_COVERAGE),true)
268 ifneq ($(NATIVE_COVERAGE),true)
269 ifndef SANITIZE_HOST
270 art_host_non_debug_cflags += -Wframe-larger-than=2700
271 endif
Evgenii Stepanove1b6e972015-06-15 15:55:22 -0700272 ifndef SANITIZE_TARGET
273 art_target_non_debug_cflags += -Wframe-larger-than=1728
274 endif
Dan Albert31fb2602014-09-30 22:10:10 -0700275 endif
Dan Albert98b8bcf2014-11-14 19:56:21 -0800276 endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700277endif
278
Ying Wanga28ff0f2014-12-08 14:29:34 -0800279ifndef LIBART_IMG_HOST_BASE_ADDRESS
280 $(error LIBART_IMG_HOST_BASE_ADDRESS unset)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700281endif
Ying Wanga28ff0f2014-12-08 14:29:34 -0800282ART_HOST_CFLAGS += $(art_cflags) -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS)
283ART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default
Roland Levillain12bd7212015-06-04 17:50:27 +0100284ART_HOST_ASFLAGS += $(art_asflags)
Ying Wanga28ff0f2014-12-08 14:29:34 -0800285
286ifndef LIBART_IMG_TARGET_BASE_ADDRESS
287 $(error LIBART_IMG_TARGET_BASE_ADDRESS unset)
288endif
289ART_TARGET_CFLAGS += $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS)
Roland Levillain12bd7212015-06-04 17:50:27 +0100290ART_TARGET_ASFLAGS += $(art_asflags)
Alex Lighta59dd802014-07-02 16:28:08 -0700291
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700292ART_HOST_NON_DEBUG_CFLAGS := $(art_host_non_debug_cflags)
293ART_TARGET_NON_DEBUG_CFLAGS := $(art_target_non_debug_cflags)
294ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags)
295ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
296
Alex Lighta59dd802014-07-02 16:28:08 -0700297ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA
298 LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA=-0x1000000
299endif
300ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA
301 LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA=0x1000000
302endif
303ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
304ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
305
306ifndef LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA
307 LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA=-0x1000000
308endif
309ifndef LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA
310 LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA=0x1000000
311endif
312ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA)
313ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA)
314
Ian Rogersafd9acc2014-06-17 08:21:54 -0700315# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
316# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
317
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700318# Clear locals now they've served their purpose.
319art_cflags :=
Roland Levillain12bd7212015-06-04 17:50:27 +0100320art_asflags :=
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700321art_debug_cflags :=
322art_non_debug_cflags :=
323art_host_non_debug_cflags :=
324art_target_non_debug_cflags :=
325art_default_gc_type :=
326art_default_gc_type_cflags :=
327
328ART_HOST_LDLIBS :=
329ifneq ($(ART_HOST_CLANG),true)
330 # GCC lacks libc++ assumed atomic operations, grab via libatomic.
331 ART_HOST_LDLIBS += -latomic
Ian Rogersafd9acc2014-06-17 08:21:54 -0700332endif
333
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700334ART_TARGET_LDFLAGS :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700335
336# $(1): ndebug_or_debug
337define set-target-local-cflags-vars
338 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
339 LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86)
Roland Levillain12bd7212015-06-04 17:50:27 +0100340 LOCAL_ASFLAGS += $(ART_TARGET_ASFLAGS)
Dehao Chen997660d2014-07-08 10:00:56 -0700341 LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700342 art_target_cflags_ndebug_or_debug := $(1)
343 ifeq ($$(art_target_cflags_ndebug_or_debug),debug)
344 LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
345 else
346 LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
347 endif
348
Andreas Gampebced67d2015-01-07 14:35:44 -0800349 LOCAL_CLANG_CFLAGS := $(ART_TARGET_CLANG_CFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700350 $(foreach arch,$(ART_SUPPORTED_ARCH),
Andreas Gampebced67d2015-01-07 14:35:44 -0800351 LOCAL_CLANG_CFLAGS_$(arch) += $$(ART_TARGET_CLANG_CFLAGS_$(arch)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700352
353 # Clear locally used variables.
354 art_target_cflags_ndebug_or_debug :=
355endef
356
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700357# Support for disabling certain builds.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700358ART_BUILD_TARGET := false
359ART_BUILD_HOST := false
360ART_BUILD_NDEBUG := false
361ART_BUILD_DEBUG := false
362ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
363 ART_BUILD_TARGET := true
364 ART_BUILD_NDEBUG := true
365endif
366ifeq ($(ART_BUILD_TARGET_DEBUG),true)
367 ART_BUILD_TARGET := true
368 ART_BUILD_DEBUG := true
369endif
370ifeq ($(ART_BUILD_HOST_NDEBUG),true)
371 ART_BUILD_HOST := true
372 ART_BUILD_NDEBUG := true
373endif
374ifeq ($(ART_BUILD_HOST_DEBUG),true)
375 ART_BUILD_HOST := true
376 ART_BUILD_DEBUG := true
377endif
378
Igor Murashkin37743352014-11-13 14:38:00 -0800379endif # ART_ANDROID_COMMON_BUILD_MK