blob: d1724ccfcbdd338506a612b3659cc08eab948a68 [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 change the default GC. Valid values are CMS, SS, GSS. The default is CMS.
64#
Hiroshi Yamauchi3e781622015-02-25 12:52:34 -080065ART_DEFAULT_GC_TYPE ?= CMS
66art_default_gc_type_cflags := -DART_DEFAULT_GC_TYPE_IS_$(ART_DEFAULT_GC_TYPE)
Ian Rogersafd9acc2014-06-17 08:21:54 -070067
Andreas Gampeee0ebc82014-10-21 21:07:28 -070068ART_HOST_CFLAGS :=
69ART_TARGET_CFLAGS :=
70
Ian Rogersafd9acc2014-06-17 08:21:54 -070071# Clang build support.
72
73# Host.
74ART_HOST_CLANG := false
75ifneq ($(WITHOUT_HOST_CLANG),true)
76 # By default, host builds use clang for better warnings.
77 ART_HOST_CLANG := true
78endif
79
Sebastien Hertzea521dc2014-06-25 18:50:01 +020080# Clang on the target. Target builds use GCC by default.
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +020081ifneq ($(USE_CLANG_PLATFORM_BUILD),)
82ART_TARGET_CLANG := $(USE_CLANG_PLATFORM_BUILD)
83else
Ian Rogersd642a912014-10-02 09:41:44 -070084ART_TARGET_CLANG := false
Bernhard Rosenkraenzer88c05692014-10-04 19:02:06 +020085endif
Ian Rogersafd9acc2014-06-17 08:21:54 -070086ART_TARGET_CLANG_arm :=
Sebastien Hertzea521dc2014-06-25 18:50:01 +020087ART_TARGET_CLANG_arm64 :=
Duane Sand91ddd0d2015-05-01 11:34:51 -070088ART_TARGET_CLANG_mips :=
89ART_TARGET_CLANG_mips64 :=
Ian Rogersafd9acc2014-06-17 08:21:54 -070090ART_TARGET_CLANG_x86 :=
91ART_TARGET_CLANG_x86_64 :=
92
93define set-target-local-clang-vars
94 LOCAL_CLANG := $(ART_TARGET_CLANG)
95 $(foreach arch,$(ART_TARGET_SUPPORTED_ARCH),
96 ifneq ($$(ART_TARGET_CLANG_$(arch)),)
97 LOCAL_CLANG_$(arch) := $$(ART_TARGET_CLANG_$(arch))
98 endif)
99endef
100
Ian Rogersafd9acc2014-06-17 08:21:54 -0700101ART_TARGET_CLANG_CFLAGS :=
102ART_TARGET_CLANG_CFLAGS_arm :=
103ART_TARGET_CLANG_CFLAGS_arm64 :=
104ART_TARGET_CLANG_CFLAGS_mips :=
Andreas Gampe1a5c4062015-01-15 12:10:47 -0800105ART_TARGET_CLANG_CFLAGS_mips64 :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700106ART_TARGET_CLANG_CFLAGS_x86 :=
107ART_TARGET_CLANG_CFLAGS_x86_64 :=
108
Ian Rogersd642a912014-10-02 09:41:44 -0700109# These are necessary for Clang ARM64 ART builds. TODO: remove.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700110ART_TARGET_CLANG_CFLAGS_arm64 += \
Andreas Gampe685fbe42015-01-27 14:36:38 -0800111 -DNVALGRIND
Ian Rogersafd9acc2014-06-17 08:21:54 -0700112
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700113# FIXME: upstream LLVM has a vectorizer bug that needs to be fixed
114ART_TARGET_CLANG_CFLAGS_arm64 += \
115 -fno-vectorize
116
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700117# Warn about thread safety violations with clang.
Dan Albert6c7cdc52014-12-02 14:58:06 -0800118art_clang_cflags := -Wthread-safety
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700119
120# Warn if switch fallthroughs aren't annotated.
121art_clang_cflags += -Wimplicit-fallthrough
122
123# Enable float equality warnings.
124art_clang_cflags += -Wfloat-equal
125
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800126# Enable warning of converting ints to void*.
127art_clang_cflags += -Wint-to-void-pointer-cast
128
Andreas Gampeca714582015-04-03 19:41:34 -0700129# Enable warning of wrong unused annotations.
130art_clang_cflags += -Wused-but-marked-unused
131
Andreas Gampe758a8012015-04-03 21:28:42 -0700132# Enable warning for deprecated language features.
133art_clang_cflags += -Wdeprecated
134
Andreas Gampe66222662015-04-06 19:50:46 -0700135# Enable warning for unreachable break & return.
136art_clang_cflags += -Wunreachable-code-break -Wunreachable-code-return
137
138# Enable missing-noreturn only on non-Mac. As lots of things are not implemented for Apple, it's
139# a pain.
140ifneq ($(HOST_OS),darwin)
141 art_clang_cflags += -Wmissing-noreturn
142endif
Andreas Gampe65b798e2015-04-06 09:35:22 -0700143
Andreas Gampeca714582015-04-03 19:41:34 -0700144
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800145# GCC-only warnings.
146art_gcc_cflags := -Wunused-but-set-parameter
147# Suggest const: too many false positives, but good for a trial run.
148# -Wsuggest-attribute=const
149# Useless casts: too many, as we need to be 32/64 agnostic, but the compiler knows.
150# -Wuseless-cast
151# Zero-as-null: Have to convert all NULL and "diagnostic ignore" all includes like libnativehelper
152# that are still stuck pre-C++11.
153# -Wzero-as-null-pointer-constant \
154# Suggest final: Have to move to a more recent GCC.
155# -Wsuggest-final-types
156
Andreas Gampebced67d2015-01-07 14:35:44 -0800157ART_TARGET_CLANG_CFLAGS := $(art_clang_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700158ifeq ($(ART_HOST_CLANG),true)
Ian Rogers4ad5cd32014-11-11 23:08:07 -0800159 # Bug: 15446488. We don't omit the frame pointer to work around
160 # clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
161 ART_HOST_CFLAGS += $(art_clang_cflags) -fno-omit-frame-pointer
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800162else
163 ART_HOST_CFLAGS += $(art_gcc_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700164endif
Andreas Gampebced67d2015-01-07 14:35:44 -0800165ifneq ($(ART_TARGET_CLANG),true)
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800166 ART_TARGET_CFLAGS += $(art_gcc_cflags)
Andreas Gampebced67d2015-01-07 14:35:44 -0800167else
168 # TODO: if we ever want to support GCC/Clang mix for multi-target products, this needs to be
169 # split up.
170 ifeq ($(ART_TARGET_CLANG_$(TARGET_ARCH)),false)
171 ART_TARGET_CFLAGS += $(art_gcc_cflags)
172 endif
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700173endif
174
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800175# Clear local variables now their use has ended.
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700176art_clang_cflags :=
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800177art_gcc_cflags :=
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700178
179ART_CPP_EXTENSION := .cc
180
181ART_C_INCLUDES := \
182 external/gtest/include \
Jeff Hao848f70a2014-01-15 13:49:50 -0800183 external/icu/icu4c/source/common \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700184 external/valgrind/main/include \
185 external/valgrind/main \
186 external/vixl/src \
187 external/zlib \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700188
189# Base set of cflags used by all things ART.
190art_cflags := \
191 -fno-rtti \
192 -std=gnu++11 \
193 -ggdb3 \
194 -Wall \
195 -Werror \
196 -Wextra \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700197 -Wstrict-aliasing \
198 -fstrict-aliasing \
199 -Wunreachable-code \
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800200 -Wredundant-decls \
201 -Wshadow \
Andreas Gampe7c3952f2015-02-19 18:21:24 -0800202 -Wunused \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700203 -fvisibility=protected \
204 $(art_default_gc_type_cflags)
205
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800206# Missing declarations: too many at the moment, as we use "extern" quite a bit.
207# -Wmissing-declarations \
208
209
Mathieu Chartiercd195fe2014-11-25 18:36:01 -0800210
211ifdef ART_IMT_SIZE
212 art_cflags += -DIMT_SIZE=$(ART_IMT_SIZE)
213else
214 # Default is 64
215 art_cflags += -DIMT_SIZE=64
216endif
217
Nicolas Geoffray9bb492a2014-11-25 23:42:00 +0000218ifeq ($(ART_USE_OPTIMIZING_COMPILER),true)
219 art_cflags += -DART_USE_OPTIMIZING_COMPILER=1
220endif
221
Hiroshi Yamauchib0d22f12014-12-08 12:08:46 -0800222ifeq ($(ART_HEAP_POISONING),true)
223 art_cflags += -DART_HEAP_POISONING=1
224endif
225
Hiroshi Yamauchic23f0d82015-01-23 17:23:42 -0800226ifeq ($(ART_USE_READ_BARRIER),true)
227 art_cflags += -DART_USE_READ_BARRIER=1
228endif
229
Hiroshi Yamauchi79bd2bf2015-03-20 10:28:34 -0700230ifeq ($(ART_USE_TLAB),true)
231 art_cflags += -DART_USE_TLAB=1
232endif
233
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700234# Cflags for non-debug ART and ART tools.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700235art_non_debug_cflags := \
236 -O3
237
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700238# Cflags for debug ART and ART tools.
239art_debug_cflags := \
Nicolas Geoffray40e7f0e2015-02-03 10:13:27 +0000240 -O2 \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700241 -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
Serban Constantinescu32f5b4d2014-11-25 20:05:46 +0000242 -DVIXL_DEBUG \
Ian Rogers50fe6da2014-10-17 01:18:08 -0700243 -UNDEBUG
Stephen Hines67a43382014-07-17 01:49:18 -0700244
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700245art_host_non_debug_cflags := $(art_non_debug_cflags)
246art_target_non_debug_cflags := $(art_non_debug_cflags)
Stephen Hines67a43382014-07-17 01:49:18 -0700247
Ian Rogersafd9acc2014-06-17 08:21:54 -0700248ifeq ($(HOST_OS),linux)
Stephen Hines67a43382014-07-17 01:49:18 -0700249 # Larger frame-size for host clang builds today
Dan Albert31fb2602014-09-30 22:10:10 -0700250 ifneq ($(ART_COVERAGE),true)
251 ifneq ($(NATIVE_COVERAGE),true)
252 ifndef SANITIZE_HOST
253 art_host_non_debug_cflags += -Wframe-larger-than=2700
254 endif
255 art_target_non_debug_cflags += -Wframe-larger-than=1728
256 endif
Dan Albert98b8bcf2014-11-14 19:56:21 -0800257 endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700258endif
259
Ying Wanga28ff0f2014-12-08 14:29:34 -0800260ifndef LIBART_IMG_HOST_BASE_ADDRESS
261 $(error LIBART_IMG_HOST_BASE_ADDRESS unset)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700262endif
Ying Wanga28ff0f2014-12-08 14:29:34 -0800263ART_HOST_CFLAGS += $(art_cflags) -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS)
264ART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default
265
266ifndef LIBART_IMG_TARGET_BASE_ADDRESS
267 $(error LIBART_IMG_TARGET_BASE_ADDRESS unset)
268endif
269ART_TARGET_CFLAGS += $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS)
Alex Lighta59dd802014-07-02 16:28:08 -0700270
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700271ART_HOST_NON_DEBUG_CFLAGS := $(art_host_non_debug_cflags)
272ART_TARGET_NON_DEBUG_CFLAGS := $(art_target_non_debug_cflags)
273ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags)
274ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
275
Alex Lighta59dd802014-07-02 16:28:08 -0700276ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA
277 LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA=-0x1000000
278endif
279ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA
280 LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA=0x1000000
281endif
282ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
283ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
284
285ifndef LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA
286 LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA=-0x1000000
287endif
288ifndef LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA
289 LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA=0x1000000
290endif
291ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA)
292ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA)
293
Ian Rogersafd9acc2014-06-17 08:21:54 -0700294# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
295# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
296
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700297# Clear locals now they've served their purpose.
298art_cflags :=
299art_debug_cflags :=
300art_non_debug_cflags :=
301art_host_non_debug_cflags :=
302art_target_non_debug_cflags :=
303art_default_gc_type :=
304art_default_gc_type_cflags :=
305
306ART_HOST_LDLIBS :=
307ifneq ($(ART_HOST_CLANG),true)
308 # GCC lacks libc++ assumed atomic operations, grab via libatomic.
309 ART_HOST_LDLIBS += -latomic
Ian Rogersafd9acc2014-06-17 08:21:54 -0700310endif
311
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700312ART_TARGET_LDFLAGS :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700313
314# $(1): ndebug_or_debug
315define set-target-local-cflags-vars
316 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
317 LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86)
Dehao Chen997660d2014-07-08 10:00:56 -0700318 LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700319 art_target_cflags_ndebug_or_debug := $(1)
320 ifeq ($$(art_target_cflags_ndebug_or_debug),debug)
321 LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
322 else
323 LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
324 endif
325
Andreas Gampebced67d2015-01-07 14:35:44 -0800326 LOCAL_CLANG_CFLAGS := $(ART_TARGET_CLANG_CFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700327 $(foreach arch,$(ART_SUPPORTED_ARCH),
Andreas Gampebced67d2015-01-07 14:35:44 -0800328 LOCAL_CLANG_CFLAGS_$(arch) += $$(ART_TARGET_CLANG_CFLAGS_$(arch)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700329
330 # Clear locally used variables.
331 art_target_cflags_ndebug_or_debug :=
332endef
333
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700334# Support for disabling certain builds.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700335ART_BUILD_TARGET := false
336ART_BUILD_HOST := false
337ART_BUILD_NDEBUG := false
338ART_BUILD_DEBUG := false
339ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
340 ART_BUILD_TARGET := true
341 ART_BUILD_NDEBUG := true
342endif
343ifeq ($(ART_BUILD_TARGET_DEBUG),true)
344 ART_BUILD_TARGET := true
345 ART_BUILD_DEBUG := true
346endif
347ifeq ($(ART_BUILD_HOST_NDEBUG),true)
348 ART_BUILD_HOST := true
349 ART_BUILD_NDEBUG := true
350endif
351ifeq ($(ART_BUILD_HOST_DEBUG),true)
352 ART_BUILD_HOST := true
353 ART_BUILD_DEBUG := true
354endif
355
Igor Murashkin37743352014-11-13 14:38:00 -0800356endif # ART_ANDROID_COMMON_BUILD_MK