blob: c7925367425148dc84399a595331c907bea8c00b [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#
51# Used to enable smart mode
52#
53ART_SMALL_MODE := false
54ifneq ($(wildcard art/SMALL_ART),)
55$(info Enabling ART_SMALL_MODE because of existence of art/SMALL_ART)
56ART_SMALL_MODE := true
57endif
58ifeq ($(WITH_ART_SMALL_MODE), true)
59ART_SMALL_MODE := 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#
Ian Rogers6f3dbba2014-10-14 17:41:57 -070065art_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
Chih-Hung Hsieh86bb22e2014-12-18 19:25:50 -080086
Andreas Gampe89866b72015-01-13 18:12:36 -080087ifeq ($(TARGET_ARCH)|$(ART_TARGET_CLANG),mips|true)
Chih-Hung Hsieh86bb22e2014-12-18 19:25:50 -080088 # b/18807290, Clang generated mips assembly code for array.cc
89 # cannot be compiled by gas.
90 # b/18789639, Clang assembler cannot compile inlined assembly code in
91 # valgrind_malloc_space-inl.h:192:5: error: used $at without ".set noat"
92 $(warning Clang is disabled for the mips target)
93endif
Ian Rogersafd9acc2014-06-17 08:21:54 -070094ART_TARGET_CLANG_arm :=
Sebastien Hertzea521dc2014-06-25 18:50:01 +020095ART_TARGET_CLANG_arm64 :=
Chih-Hung Hsieh86bb22e2014-12-18 19:25:50 -080096# TODO: Enable clang mips when b/18807290 and b/18789639 are fixed.
97ART_TARGET_CLANG_mips := false
Andreas Gampe1a5c4062015-01-15 12:10:47 -080098ART_TARGET_CLANG_mips64 := false
Ian Rogersafd9acc2014-06-17 08:21:54 -070099ART_TARGET_CLANG_x86 :=
100ART_TARGET_CLANG_x86_64 :=
101
102define set-target-local-clang-vars
103 LOCAL_CLANG := $(ART_TARGET_CLANG)
104 $(foreach arch,$(ART_TARGET_SUPPORTED_ARCH),
105 ifneq ($$(ART_TARGET_CLANG_$(arch)),)
106 LOCAL_CLANG_$(arch) := $$(ART_TARGET_CLANG_$(arch))
107 endif)
108endef
109
Ian Rogersafd9acc2014-06-17 08:21:54 -0700110ART_TARGET_CLANG_CFLAGS :=
111ART_TARGET_CLANG_CFLAGS_arm :=
112ART_TARGET_CLANG_CFLAGS_arm64 :=
113ART_TARGET_CLANG_CFLAGS_mips :=
Andreas Gampe1a5c4062015-01-15 12:10:47 -0800114ART_TARGET_CLANG_CFLAGS_mips64 :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700115ART_TARGET_CLANG_CFLAGS_x86 :=
116ART_TARGET_CLANG_CFLAGS_x86_64 :=
117
Ian Rogersd642a912014-10-02 09:41:44 -0700118# These are necessary for Clang ARM64 ART builds. TODO: remove.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700119ART_TARGET_CLANG_CFLAGS_arm64 += \
120 -Wno-implicit-exception-spec-mismatch \
121 -DNVALGRIND \
122 -Wno-unused-value
123
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700124# FIXME: upstream LLVM has a vectorizer bug that needs to be fixed
125ART_TARGET_CLANG_CFLAGS_arm64 += \
126 -fno-vectorize
127
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700128# Warn about thread safety violations with clang.
Dan Albert6c7cdc52014-12-02 14:58:06 -0800129art_clang_cflags := -Wthread-safety
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700130
131# Warn if switch fallthroughs aren't annotated.
132art_clang_cflags += -Wimplicit-fallthrough
133
134# Enable float equality warnings.
135art_clang_cflags += -Wfloat-equal
136
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800137# Enable warning of converting ints to void*.
138art_clang_cflags += -Wint-to-void-pointer-cast
139
140# GCC-only warnings.
141art_gcc_cflags := -Wunused-but-set-parameter
142# Suggest const: too many false positives, but good for a trial run.
143# -Wsuggest-attribute=const
144# Useless casts: too many, as we need to be 32/64 agnostic, but the compiler knows.
145# -Wuseless-cast
146# Zero-as-null: Have to convert all NULL and "diagnostic ignore" all includes like libnativehelper
147# that are still stuck pre-C++11.
148# -Wzero-as-null-pointer-constant \
149# Suggest final: Have to move to a more recent GCC.
150# -Wsuggest-final-types
151
Andreas Gampebced67d2015-01-07 14:35:44 -0800152ART_TARGET_CLANG_CFLAGS := $(art_clang_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700153ifeq ($(ART_HOST_CLANG),true)
Ian Rogers4ad5cd32014-11-11 23:08:07 -0800154 # Bug: 15446488. We don't omit the frame pointer to work around
155 # clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
156 ART_HOST_CFLAGS += $(art_clang_cflags) -fno-omit-frame-pointer
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800157else
158 ART_HOST_CFLAGS += $(art_gcc_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700159endif
Andreas Gampebced67d2015-01-07 14:35:44 -0800160ifneq ($(ART_TARGET_CLANG),true)
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800161 ART_TARGET_CFLAGS += $(art_gcc_cflags)
Andreas Gampebced67d2015-01-07 14:35:44 -0800162else
163 # TODO: if we ever want to support GCC/Clang mix for multi-target products, this needs to be
164 # split up.
165 ifeq ($(ART_TARGET_CLANG_$(TARGET_ARCH)),false)
166 ART_TARGET_CFLAGS += $(art_gcc_cflags)
167 endif
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700168endif
169
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800170# Clear local variables now their use has ended.
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700171art_clang_cflags :=
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800172art_gcc_cflags :=
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700173
174ART_CPP_EXTENSION := .cc
175
176ART_C_INCLUDES := \
177 external/gtest/include \
178 external/valgrind/main/include \
179 external/valgrind/main \
180 external/vixl/src \
181 external/zlib \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700182
183# Base set of cflags used by all things ART.
184art_cflags := \
185 -fno-rtti \
186 -std=gnu++11 \
187 -ggdb3 \
188 -Wall \
189 -Werror \
190 -Wextra \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700191 -Wstrict-aliasing \
192 -fstrict-aliasing \
193 -Wunreachable-code \
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800194 -Wno-conversion-null \
195 -Wredundant-decls \
196 -Wshadow \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700197 -fvisibility=protected \
198 $(art_default_gc_type_cflags)
199
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800200# Missing declarations: too many at the moment, as we use "extern" quite a bit.
201# -Wmissing-declarations \
202
203
Mathieu Chartiercd195fe2014-11-25 18:36:01 -0800204
205ifdef ART_IMT_SIZE
206 art_cflags += -DIMT_SIZE=$(ART_IMT_SIZE)
207else
208 # Default is 64
209 art_cflags += -DIMT_SIZE=64
210endif
211
Ian Rogersafd9acc2014-06-17 08:21:54 -0700212ifeq ($(ART_SMALL_MODE),true)
213 art_cflags += -DART_SMALL_MODE=1
214endif
215
Nicolas Geoffray9bb492a2014-11-25 23:42:00 +0000216ifeq ($(ART_USE_OPTIMIZING_COMPILER),true)
217 art_cflags += -DART_USE_OPTIMIZING_COMPILER=1
218endif
219
Hiroshi Yamauchib0d22f12014-12-08 12:08:46 -0800220ifeq ($(ART_HEAP_POISONING),true)
221 art_cflags += -DART_HEAP_POISONING=1
222endif
223
Hiroshi Yamauchic23f0d82015-01-23 17:23:42 -0800224ifeq ($(ART_USE_READ_BARRIER),true)
225 art_cflags += -DART_USE_READ_BARRIER=1
226endif
227
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700228# Cflags for non-debug ART and ART tools.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700229art_non_debug_cflags := \
230 -O3
231
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700232# Cflags for debug ART and ART tools.
233art_debug_cflags := \
234 -O2 \
235 -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
Serban Constantinescu32f5b4d2014-11-25 20:05:46 +0000236 -DVIXL_DEBUG \
Ian Rogers50fe6da2014-10-17 01:18:08 -0700237 -UNDEBUG
Stephen Hines67a43382014-07-17 01:49:18 -0700238
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700239art_host_non_debug_cflags := $(art_non_debug_cflags)
240art_target_non_debug_cflags := $(art_non_debug_cflags)
Stephen Hines67a43382014-07-17 01:49:18 -0700241
Ian Rogersafd9acc2014-06-17 08:21:54 -0700242ifeq ($(HOST_OS),linux)
Stephen Hines67a43382014-07-17 01:49:18 -0700243 # Larger frame-size for host clang builds today
Dan Albert98b8bcf2014-11-14 19:56:21 -0800244 ifndef SANITIZE_HOST
Mathieu Chartier88f21ca2014-11-18 14:13:58 -0800245 art_host_non_debug_cflags += -Wframe-larger-than=2700
Dan Albert98b8bcf2014-11-14 19:56:21 -0800246 endif
Stephen Hines67a43382014-07-17 01:49:18 -0700247 art_target_non_debug_cflags += -Wframe-larger-than=1728
Ian Rogersafd9acc2014-06-17 08:21:54 -0700248endif
249
Ying Wanga28ff0f2014-12-08 14:29:34 -0800250ifndef LIBART_IMG_HOST_BASE_ADDRESS
251 $(error LIBART_IMG_HOST_BASE_ADDRESS unset)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700252endif
Ying Wanga28ff0f2014-12-08 14:29:34 -0800253ART_HOST_CFLAGS += $(art_cflags) -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS)
254ART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default
255
256ifndef LIBART_IMG_TARGET_BASE_ADDRESS
257 $(error LIBART_IMG_TARGET_BASE_ADDRESS unset)
258endif
259ART_TARGET_CFLAGS += $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS)
Alex Lighta59dd802014-07-02 16:28:08 -0700260
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700261ART_HOST_NON_DEBUG_CFLAGS := $(art_host_non_debug_cflags)
262ART_TARGET_NON_DEBUG_CFLAGS := $(art_target_non_debug_cflags)
263ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags)
264ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
265
Alex Lighta59dd802014-07-02 16:28:08 -0700266ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA
267 LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA=-0x1000000
268endif
269ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA
270 LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA=0x1000000
271endif
272ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
273ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
274
275ifndef LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA
276 LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA=-0x1000000
277endif
278ifndef LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA
279 LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA=0x1000000
280endif
281ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA)
282ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA)
283
Ian Rogersafd9acc2014-06-17 08:21:54 -0700284# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
285# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
286
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700287# Clear locals now they've served their purpose.
288art_cflags :=
289art_debug_cflags :=
290art_non_debug_cflags :=
291art_host_non_debug_cflags :=
292art_target_non_debug_cflags :=
293art_default_gc_type :=
294art_default_gc_type_cflags :=
295
296ART_HOST_LDLIBS :=
297ifneq ($(ART_HOST_CLANG),true)
298 # GCC lacks libc++ assumed atomic operations, grab via libatomic.
299 ART_HOST_LDLIBS += -latomic
Ian Rogersafd9acc2014-06-17 08:21:54 -0700300endif
301
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700302ART_TARGET_LDFLAGS :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700303
304# $(1): ndebug_or_debug
305define set-target-local-cflags-vars
306 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
307 LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86)
Dehao Chen997660d2014-07-08 10:00:56 -0700308 LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700309 art_target_cflags_ndebug_or_debug := $(1)
310 ifeq ($$(art_target_cflags_ndebug_or_debug),debug)
311 LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
312 else
313 LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
314 endif
315
Andreas Gampebced67d2015-01-07 14:35:44 -0800316 LOCAL_CLANG_CFLAGS := $(ART_TARGET_CLANG_CFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700317 $(foreach arch,$(ART_SUPPORTED_ARCH),
Andreas Gampebced67d2015-01-07 14:35:44 -0800318 LOCAL_CLANG_CFLAGS_$(arch) += $$(ART_TARGET_CLANG_CFLAGS_$(arch)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700319
320 # Clear locally used variables.
321 art_target_cflags_ndebug_or_debug :=
322endef
323
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700324# Support for disabling certain builds.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700325ART_BUILD_TARGET := false
326ART_BUILD_HOST := false
327ART_BUILD_NDEBUG := false
328ART_BUILD_DEBUG := false
329ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
330 ART_BUILD_TARGET := true
331 ART_BUILD_NDEBUG := true
332endif
333ifeq ($(ART_BUILD_TARGET_DEBUG),true)
334 ART_BUILD_TARGET := true
335 ART_BUILD_DEBUG := true
336endif
337ifeq ($(ART_BUILD_HOST_NDEBUG),true)
338 ART_BUILD_HOST := true
339 ART_BUILD_NDEBUG := true
340endif
341ifeq ($(ART_BUILD_HOST_DEBUG),true)
342 ART_BUILD_HOST := true
343 ART_BUILD_DEBUG := true
344endif
345
Igor Murashkin37743352014-11-13 14:38:00 -0800346endif # ART_ANDROID_COMMON_BUILD_MK