blob: 2057679f2e4185707fd498cfdb32076805d0a0c1 [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 Juravle65e069d2015-06-08 10:35:24 +010036ART_BUILD_HOST_STATIC ?= false
Ian Rogersafd9acc2014-06-17 08:21:54 -070037
38ifeq ($(ART_BUILD_TARGET_NDEBUG),false)
39$(info Disabling ART_BUILD_TARGET_NDEBUG)
40endif
41ifeq ($(ART_BUILD_TARGET_DEBUG),false)
42$(info Disabling ART_BUILD_TARGET_DEBUG)
43endif
44ifeq ($(ART_BUILD_HOST_NDEBUG),false)
45$(info Disabling ART_BUILD_HOST_NDEBUG)
46endif
47ifeq ($(ART_BUILD_HOST_DEBUG),false)
48$(info Disabling ART_BUILD_HOST_DEBUG)
49endif
Calin Juravle65e069d2015-06-08 10:35:24 +010050ifeq ($(ART_BUILD_HOST_STATIC),true)
51$(info Enabling ART_BUILD_HOST_STATIC)
52endif
Ian Rogersafd9acc2014-06-17 08:21:54 -070053
54#
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080055# Used to enable JIT
56#
57ART_JIT := false
58ifneq ($(wildcard art/JIT_ART),)
59$(info Enabling ART_JIT because of existence of art/JIT_ART)
60ART_JIT := true
61endif
62ifeq ($(WITH_ART_JIT), true)
63ART_JIT := true
64endif
65
66#
Ian Rogersafd9acc2014-06-17 08:21:54 -070067# Used to change the default GC. Valid values are CMS, SS, GSS. The default is CMS.
68#
Hiroshi Yamauchi3e781622015-02-25 12:52:34 -080069ART_DEFAULT_GC_TYPE ?= CMS
70art_default_gc_type_cflags := -DART_DEFAULT_GC_TYPE_IS_$(ART_DEFAULT_GC_TYPE)
Ian Rogersafd9acc2014-06-17 08:21:54 -070071
Andreas Gampeee0ebc82014-10-21 21:07:28 -070072ART_HOST_CFLAGS :=
73ART_TARGET_CFLAGS :=
74
Roland Levillain12bd7212015-06-04 17:50:27 +010075ART_HOST_ASFLAGS :=
76ART_TARGET_ASFLAGS :=
77
Ian Rogersafd9acc2014-06-17 08:21:54 -070078# Clang build support.
79
80# Host.
81ART_HOST_CLANG := false
82ifneq ($(WITHOUT_HOST_CLANG),true)
83 # By default, host builds use clang for better warnings.
84 ART_HOST_CLANG := true
85endif
86
Sebastien Hertzea521dc2014-06-25 18:50:01 +020087# Clang on the target. Target builds use GCC by default.
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +020088ifneq ($(USE_CLANG_PLATFORM_BUILD),)
89ART_TARGET_CLANG := $(USE_CLANG_PLATFORM_BUILD)
90else
Ian Rogersd642a912014-10-02 09:41:44 -070091ART_TARGET_CLANG := false
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +020092endif
Ian Rogersafd9acc2014-06-17 08:21:54 -070093ART_TARGET_CLANG_arm :=
Sebastien Hertzea521dc2014-06-25 18:50:01 +020094ART_TARGET_CLANG_arm64 :=
Duane Sand91ddd0d2015-05-01 11:34:51 -070095ART_TARGET_CLANG_mips :=
96ART_TARGET_CLANG_mips64 :=
Ian Rogersafd9acc2014-06-17 08:21:54 -070097ART_TARGET_CLANG_x86 :=
98ART_TARGET_CLANG_x86_64 :=
99
100define set-target-local-clang-vars
101 LOCAL_CLANG := $(ART_TARGET_CLANG)
102 $(foreach arch,$(ART_TARGET_SUPPORTED_ARCH),
103 ifneq ($$(ART_TARGET_CLANG_$(arch)),)
104 LOCAL_CLANG_$(arch) := $$(ART_TARGET_CLANG_$(arch))
105 endif)
106endef
107
Ian Rogersafd9acc2014-06-17 08:21:54 -0700108ART_TARGET_CLANG_CFLAGS :=
109ART_TARGET_CLANG_CFLAGS_arm :=
110ART_TARGET_CLANG_CFLAGS_arm64 :=
111ART_TARGET_CLANG_CFLAGS_mips :=
Andreas Gampe1a5c4062015-01-15 12:10:47 -0800112ART_TARGET_CLANG_CFLAGS_mips64 :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700113ART_TARGET_CLANG_CFLAGS_x86 :=
114ART_TARGET_CLANG_CFLAGS_x86_64 :=
115
Ian Rogersd642a912014-10-02 09:41:44 -0700116# These are necessary for Clang ARM64 ART builds. TODO: remove.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700117ART_TARGET_CLANG_CFLAGS_arm64 += \
Andreas Gampe685fbe42015-01-27 14:36:38 -0800118 -DNVALGRIND
Ian Rogersafd9acc2014-06-17 08:21:54 -0700119
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700120# Warn about thread safety violations with clang.
Dan Albert6c7cdc52014-12-02 14:58:06 -0800121art_clang_cflags := -Wthread-safety
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700122
123# Warn if switch fallthroughs aren't annotated.
124art_clang_cflags += -Wimplicit-fallthrough
125
126# Enable float equality warnings.
127art_clang_cflags += -Wfloat-equal
128
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800129# Enable warning of converting ints to void*.
130art_clang_cflags += -Wint-to-void-pointer-cast
131
Andreas Gampeca714582015-04-03 19:41:34 -0700132# Enable warning of wrong unused annotations.
133art_clang_cflags += -Wused-but-marked-unused
134
Andreas Gampe758a8012015-04-03 21:28:42 -0700135# Enable warning for deprecated language features.
136art_clang_cflags += -Wdeprecated
137
Andreas Gampe66222662015-04-06 19:50:46 -0700138# Enable warning for unreachable break & return.
139art_clang_cflags += -Wunreachable-code-break -Wunreachable-code-return
140
141# Enable missing-noreturn only on non-Mac. As lots of things are not implemented for Apple, it's
142# a pain.
143ifneq ($(HOST_OS),darwin)
144 art_clang_cflags += -Wmissing-noreturn
145endif
Andreas Gampe65b798e2015-04-06 09:35:22 -0700146
Andreas Gampeca714582015-04-03 19:41:34 -0700147
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800148# GCC-only warnings.
149art_gcc_cflags := -Wunused-but-set-parameter
150# Suggest const: too many false positives, but good for a trial run.
151# -Wsuggest-attribute=const
152# Useless casts: too many, as we need to be 32/64 agnostic, but the compiler knows.
153# -Wuseless-cast
154# Zero-as-null: Have to convert all NULL and "diagnostic ignore" all includes like libnativehelper
155# that are still stuck pre-C++11.
156# -Wzero-as-null-pointer-constant \
157# Suggest final: Have to move to a more recent GCC.
158# -Wsuggest-final-types
159
Andreas Gampebced67d2015-01-07 14:35:44 -0800160ART_TARGET_CLANG_CFLAGS := $(art_clang_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700161ifeq ($(ART_HOST_CLANG),true)
Ian Rogers4ad5cd32014-11-11 23:08:07 -0800162 # Bug: 15446488. We don't omit the frame pointer to work around
163 # clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
164 ART_HOST_CFLAGS += $(art_clang_cflags) -fno-omit-frame-pointer
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800165else
166 ART_HOST_CFLAGS += $(art_gcc_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700167endif
Andreas Gampebced67d2015-01-07 14:35:44 -0800168ifneq ($(ART_TARGET_CLANG),true)
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800169 ART_TARGET_CFLAGS += $(art_gcc_cflags)
Andreas Gampebced67d2015-01-07 14:35:44 -0800170else
171 # TODO: if we ever want to support GCC/Clang mix for multi-target products, this needs to be
172 # split up.
173 ifeq ($(ART_TARGET_CLANG_$(TARGET_ARCH)),false)
174 ART_TARGET_CFLAGS += $(art_gcc_cflags)
175 endif
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700176endif
177
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800178# Clear local variables now their use has ended.
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700179art_clang_cflags :=
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800180art_gcc_cflags :=
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700181
182ART_CPP_EXTENSION := .cc
183
184ART_C_INCLUDES := \
185 external/gtest/include \
Jeff Hao848f70a2014-01-15 13:49:50 -0800186 external/icu/icu4c/source/common \
Dmitriy Ivanov6130f732015-05-27 15:34:38 -0700187 external/valgrind/include \
188 external/valgrind \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700189 external/vixl/src \
190 external/zlib \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700191
192# Base set of cflags used by all things ART.
193art_cflags := \
194 -fno-rtti \
195 -std=gnu++11 \
196 -ggdb3 \
197 -Wall \
198 -Werror \
199 -Wextra \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700200 -Wstrict-aliasing \
201 -fstrict-aliasing \
202 -Wunreachable-code \
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800203 -Wredundant-decls \
204 -Wshadow \
Andreas Gampe7c3952f2015-02-19 18:21:24 -0800205 -Wunused \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700206 -fvisibility=protected \
207 $(art_default_gc_type_cflags)
208
Roland Levillain12bd7212015-06-04 17:50:27 +0100209# Base set of asflags used by all things ART.
210art_asflags :=
211
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800212# Missing declarations: too many at the moment, as we use "extern" quite a bit.
213# -Wmissing-declarations \
214
215
Mathieu Chartiercd195fe2014-11-25 18:36:01 -0800216
217ifdef ART_IMT_SIZE
218 art_cflags += -DIMT_SIZE=$(ART_IMT_SIZE)
219else
220 # Default is 64
221 art_cflags += -DIMT_SIZE=64
222endif
223
Nicolas Geoffray9bb492a2014-11-25 23:42:00 +0000224ifeq ($(ART_USE_OPTIMIZING_COMPILER),true)
225 art_cflags += -DART_USE_OPTIMIZING_COMPILER=1
226endif
227
Hiroshi Yamauchib0d22f12014-12-08 12:08:46 -0800228ifeq ($(ART_HEAP_POISONING),true)
229 art_cflags += -DART_HEAP_POISONING=1
Roland Levillain12bd7212015-06-04 17:50:27 +0100230 art_asflags += -DART_HEAP_POISONING=1
Hiroshi Yamauchib0d22f12014-12-08 12:08:46 -0800231endif
232
Hiroshi Yamauchic23f0d82015-01-23 17:23:42 -0800233ifeq ($(ART_USE_READ_BARRIER),true)
234 art_cflags += -DART_USE_READ_BARRIER=1
Roland Levillain12bd7212015-06-04 17:50:27 +0100235 art_asflags += -DART_USE_READ_BARRIER=1
Hiroshi Yamauchic23f0d82015-01-23 17:23:42 -0800236endif
237
Hiroshi Yamauchi79bd2bf2015-03-20 10:28:34 -0700238ifeq ($(ART_USE_TLAB),true)
239 art_cflags += -DART_USE_TLAB=1
240endif
241
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700242# Cflags for non-debug ART and ART tools.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700243art_non_debug_cflags := \
244 -O3
245
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700246# Cflags for debug ART and ART tools.
247art_debug_cflags := \
Nicolas Geoffray40e7f0e2015-02-03 10:13:27 +0000248 -O2 \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700249 -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
Serban Constantinescu32f5b4d2014-11-25 20:05:46 +0000250 -DVIXL_DEBUG \
Ian Rogers50fe6da2014-10-17 01:18:08 -0700251 -UNDEBUG
Stephen Hines67a43382014-07-17 01:49:18 -0700252
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700253art_host_non_debug_cflags := $(art_non_debug_cflags)
254art_target_non_debug_cflags := $(art_non_debug_cflags)
Stephen Hines67a43382014-07-17 01:49:18 -0700255
Ian Rogersafd9acc2014-06-17 08:21:54 -0700256ifeq ($(HOST_OS),linux)
Stephen Hines67a43382014-07-17 01:49:18 -0700257 # Larger frame-size for host clang builds today
Dan Albert31fb2602014-09-30 22:10:10 -0700258 ifneq ($(ART_COVERAGE),true)
259 ifneq ($(NATIVE_COVERAGE),true)
260 ifndef SANITIZE_HOST
261 art_host_non_debug_cflags += -Wframe-larger-than=2700
262 endif
Evgenii Stepanove1b6e972015-06-15 15:55:22 -0700263 ifndef SANITIZE_TARGET
264 art_target_non_debug_cflags += -Wframe-larger-than=1728
265 endif
Dan Albert31fb2602014-09-30 22:10:10 -0700266 endif
Dan Albert98b8bcf2014-11-14 19:56:21 -0800267 endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700268endif
269
Ying Wanga28ff0f2014-12-08 14:29:34 -0800270ifndef LIBART_IMG_HOST_BASE_ADDRESS
271 $(error LIBART_IMG_HOST_BASE_ADDRESS unset)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700272endif
Ying Wanga28ff0f2014-12-08 14:29:34 -0800273ART_HOST_CFLAGS += $(art_cflags) -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS)
274ART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default
Roland Levillain12bd7212015-06-04 17:50:27 +0100275ART_HOST_ASFLAGS += $(art_asflags)
Ying Wanga28ff0f2014-12-08 14:29:34 -0800276
277ifndef LIBART_IMG_TARGET_BASE_ADDRESS
278 $(error LIBART_IMG_TARGET_BASE_ADDRESS unset)
279endif
280ART_TARGET_CFLAGS += $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS)
Roland Levillain12bd7212015-06-04 17:50:27 +0100281ART_TARGET_ASFLAGS += $(art_asflags)
Alex Lighta59dd802014-07-02 16:28:08 -0700282
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700283ART_HOST_NON_DEBUG_CFLAGS := $(art_host_non_debug_cflags)
284ART_TARGET_NON_DEBUG_CFLAGS := $(art_target_non_debug_cflags)
285ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags)
286ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
287
Alex Lighta59dd802014-07-02 16:28:08 -0700288ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA
289 LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA=-0x1000000
290endif
291ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA
292 LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA=0x1000000
293endif
294ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
295ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
296
297ifndef LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA
298 LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA=-0x1000000
299endif
300ifndef LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA
301 LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA=0x1000000
302endif
303ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA)
304ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA)
305
Ian Rogersafd9acc2014-06-17 08:21:54 -0700306# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
307# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
308
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700309# Clear locals now they've served their purpose.
310art_cflags :=
Roland Levillain12bd7212015-06-04 17:50:27 +0100311art_asflags :=
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700312art_debug_cflags :=
313art_non_debug_cflags :=
314art_host_non_debug_cflags :=
315art_target_non_debug_cflags :=
316art_default_gc_type :=
317art_default_gc_type_cflags :=
318
319ART_HOST_LDLIBS :=
320ifneq ($(ART_HOST_CLANG),true)
321 # GCC lacks libc++ assumed atomic operations, grab via libatomic.
322 ART_HOST_LDLIBS += -latomic
Ian Rogersafd9acc2014-06-17 08:21:54 -0700323endif
324
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700325ART_TARGET_LDFLAGS :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700326
327# $(1): ndebug_or_debug
328define set-target-local-cflags-vars
329 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
330 LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86)
Roland Levillain12bd7212015-06-04 17:50:27 +0100331 LOCAL_ASFLAGS += $(ART_TARGET_ASFLAGS)
Dehao Chen997660d2014-07-08 10:00:56 -0700332 LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700333 art_target_cflags_ndebug_or_debug := $(1)
334 ifeq ($$(art_target_cflags_ndebug_or_debug),debug)
335 LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
336 else
337 LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
338 endif
339
Andreas Gampebced67d2015-01-07 14:35:44 -0800340 LOCAL_CLANG_CFLAGS := $(ART_TARGET_CLANG_CFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700341 $(foreach arch,$(ART_SUPPORTED_ARCH),
Andreas Gampebced67d2015-01-07 14:35:44 -0800342 LOCAL_CLANG_CFLAGS_$(arch) += $$(ART_TARGET_CLANG_CFLAGS_$(arch)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700343
344 # Clear locally used variables.
345 art_target_cflags_ndebug_or_debug :=
346endef
347
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700348# Support for disabling certain builds.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700349ART_BUILD_TARGET := false
350ART_BUILD_HOST := false
351ART_BUILD_NDEBUG := false
352ART_BUILD_DEBUG := false
353ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
354 ART_BUILD_TARGET := true
355 ART_BUILD_NDEBUG := true
356endif
357ifeq ($(ART_BUILD_TARGET_DEBUG),true)
358 ART_BUILD_TARGET := true
359 ART_BUILD_DEBUG := true
360endif
361ifeq ($(ART_BUILD_HOST_NDEBUG),true)
362 ART_BUILD_HOST := true
363 ART_BUILD_NDEBUG := true
364endif
365ifeq ($(ART_BUILD_HOST_DEBUG),true)
366 ART_BUILD_HOST := true
367 ART_BUILD_DEBUG := true
368endif
369
Igor Murashkin37743352014-11-13 14:38:00 -0800370endif # ART_ANDROID_COMMON_BUILD_MK