blob: 68f5ed703dd15ee4134626971c0e57c81bdada38 [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
Ian Rogersafd9acc2014-06-17 08:21:54 -070086ART_TARGET_CLANG_arm :=
Sebastien Hertzea521dc2014-06-25 18:50:01 +020087ART_TARGET_CLANG_arm64 :=
Ian Rogersafd9acc2014-06-17 08:21:54 -070088ART_TARGET_CLANG_mips :=
89ART_TARGET_CLANG_x86 :=
90ART_TARGET_CLANG_x86_64 :=
91
92define set-target-local-clang-vars
93 LOCAL_CLANG := $(ART_TARGET_CLANG)
94 $(foreach arch,$(ART_TARGET_SUPPORTED_ARCH),
95 ifneq ($$(ART_TARGET_CLANG_$(arch)),)
96 LOCAL_CLANG_$(arch) := $$(ART_TARGET_CLANG_$(arch))
97 endif)
98endef
99
Ian Rogersafd9acc2014-06-17 08:21:54 -0700100ART_TARGET_CLANG_CFLAGS :=
101ART_TARGET_CLANG_CFLAGS_arm :=
102ART_TARGET_CLANG_CFLAGS_arm64 :=
103ART_TARGET_CLANG_CFLAGS_mips :=
104ART_TARGET_CLANG_CFLAGS_x86 :=
105ART_TARGET_CLANG_CFLAGS_x86_64 :=
106
Ian Rogersd642a912014-10-02 09:41:44 -0700107# These are necessary for Clang ARM64 ART builds. TODO: remove.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700108ART_TARGET_CLANG_CFLAGS_arm64 += \
109 -Wno-implicit-exception-spec-mismatch \
110 -DNVALGRIND \
111 -Wno-unused-value
112
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
129# GCC-only warnings.
130art_gcc_cflags := -Wunused-but-set-parameter
131# Suggest const: too many false positives, but good for a trial run.
132# -Wsuggest-attribute=const
133# Useless casts: too many, as we need to be 32/64 agnostic, but the compiler knows.
134# -Wuseless-cast
135# Zero-as-null: Have to convert all NULL and "diagnostic ignore" all includes like libnativehelper
136# that are still stuck pre-C++11.
137# -Wzero-as-null-pointer-constant \
138# Suggest final: Have to move to a more recent GCC.
139# -Wsuggest-final-types
140
141
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700142ifeq ($(ART_HOST_CLANG),true)
Ian Rogers4ad5cd32014-11-11 23:08:07 -0800143 # Bug: 15446488. We don't omit the frame pointer to work around
144 # clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
145 ART_HOST_CFLAGS += $(art_clang_cflags) -fno-omit-frame-pointer
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800146else
147 ART_HOST_CFLAGS += $(art_gcc_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700148endif
149ifeq ($(ART_TARGET_CLANG),true)
150 ART_TARGET_CFLAGS += $(art_clang_cflags)
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800151else
152 ART_TARGET_CFLAGS += $(art_gcc_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700153endif
154
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800155# Clear local variables now their use has ended.
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700156art_clang_cflags :=
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800157art_gcc_cflags :=
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700158
159ART_CPP_EXTENSION := .cc
160
161ART_C_INCLUDES := \
162 external/gtest/include \
163 external/valgrind/main/include \
164 external/valgrind/main \
165 external/vixl/src \
166 external/zlib \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700167
168# Base set of cflags used by all things ART.
169art_cflags := \
170 -fno-rtti \
171 -std=gnu++11 \
172 -ggdb3 \
173 -Wall \
174 -Werror \
175 -Wextra \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700176 -Wstrict-aliasing \
177 -fstrict-aliasing \
178 -Wunreachable-code \
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800179 -Wno-conversion-null \
180 -Wredundant-decls \
181 -Wshadow \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700182 -fvisibility=protected \
183 $(art_default_gc_type_cflags)
184
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800185# Missing declarations: too many at the moment, as we use "extern" quite a bit.
186# -Wmissing-declarations \
187
188
Mathieu Chartiercd195fe2014-11-25 18:36:01 -0800189
190ifdef ART_IMT_SIZE
191 art_cflags += -DIMT_SIZE=$(ART_IMT_SIZE)
192else
193 # Default is 64
194 art_cflags += -DIMT_SIZE=64
195endif
196
Ian Rogersafd9acc2014-06-17 08:21:54 -0700197ifeq ($(ART_SMALL_MODE),true)
198 art_cflags += -DART_SMALL_MODE=1
199endif
200
Nicolas Geoffray9bb492a2014-11-25 23:42:00 +0000201ifeq ($(ART_USE_OPTIMIZING_COMPILER),true)
202 art_cflags += -DART_USE_OPTIMIZING_COMPILER=1
203endif
204
Hiroshi Yamauchib0d22f12014-12-08 12:08:46 -0800205ifeq ($(ART_HEAP_POISONING),true)
206 art_cflags += -DART_HEAP_POISONING=1
207endif
208
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700209# Cflags for non-debug ART and ART tools.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700210art_non_debug_cflags := \
211 -O3
212
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700213# Cflags for debug ART and ART tools.
214art_debug_cflags := \
215 -O2 \
216 -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
Serban Constantinescu32f5b4d2014-11-25 20:05:46 +0000217 -DVIXL_DEBUG \
Ian Rogers50fe6da2014-10-17 01:18:08 -0700218 -UNDEBUG
Stephen Hines67a43382014-07-17 01:49:18 -0700219
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700220art_host_non_debug_cflags := $(art_non_debug_cflags)
221art_target_non_debug_cflags := $(art_non_debug_cflags)
Stephen Hines67a43382014-07-17 01:49:18 -0700222
Ian Rogersafd9acc2014-06-17 08:21:54 -0700223ifeq ($(HOST_OS),linux)
Stephen Hines67a43382014-07-17 01:49:18 -0700224 # Larger frame-size for host clang builds today
Dan Albert98b8bcf2014-11-14 19:56:21 -0800225 ifndef SANITIZE_HOST
Mathieu Chartier88f21ca2014-11-18 14:13:58 -0800226 art_host_non_debug_cflags += -Wframe-larger-than=2700
Dan Albert98b8bcf2014-11-14 19:56:21 -0800227 endif
Stephen Hines67a43382014-07-17 01:49:18 -0700228 art_target_non_debug_cflags += -Wframe-larger-than=1728
Ian Rogersafd9acc2014-06-17 08:21:54 -0700229endif
230
Ying Wanga28ff0f2014-12-08 14:29:34 -0800231ifndef LIBART_IMG_HOST_BASE_ADDRESS
232 $(error LIBART_IMG_HOST_BASE_ADDRESS unset)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700233endif
Ying Wanga28ff0f2014-12-08 14:29:34 -0800234ART_HOST_CFLAGS += $(art_cflags) -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS)
235ART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default
236
237ifndef LIBART_IMG_TARGET_BASE_ADDRESS
238 $(error LIBART_IMG_TARGET_BASE_ADDRESS unset)
239endif
240ART_TARGET_CFLAGS += $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS)
Alex Lighta59dd802014-07-02 16:28:08 -0700241
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700242ART_HOST_NON_DEBUG_CFLAGS := $(art_host_non_debug_cflags)
243ART_TARGET_NON_DEBUG_CFLAGS := $(art_target_non_debug_cflags)
244ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags)
245ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
246
Alex Lighta59dd802014-07-02 16:28:08 -0700247ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA
248 LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA=-0x1000000
249endif
250ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA
251 LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA=0x1000000
252endif
253ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
254ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
255
256ifndef LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA
257 LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA=-0x1000000
258endif
259ifndef LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA
260 LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA=0x1000000
261endif
262ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA)
263ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA)
264
Ian Rogersafd9acc2014-06-17 08:21:54 -0700265# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
266# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
267
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700268# Clear locals now they've served their purpose.
269art_cflags :=
270art_debug_cflags :=
271art_non_debug_cflags :=
272art_host_non_debug_cflags :=
273art_target_non_debug_cflags :=
274art_default_gc_type :=
275art_default_gc_type_cflags :=
276
277ART_HOST_LDLIBS :=
278ifneq ($(ART_HOST_CLANG),true)
279 # GCC lacks libc++ assumed atomic operations, grab via libatomic.
280 ART_HOST_LDLIBS += -latomic
Ian Rogersafd9acc2014-06-17 08:21:54 -0700281endif
282
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700283ART_TARGET_LDFLAGS :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700284
285# $(1): ndebug_or_debug
286define set-target-local-cflags-vars
287 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
288 LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86)
Dehao Chen997660d2014-07-08 10:00:56 -0700289 LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700290 art_target_cflags_ndebug_or_debug := $(1)
291 ifeq ($$(art_target_cflags_ndebug_or_debug),debug)
292 LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
293 else
294 LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
295 endif
296
297 # TODO: Also set when ART_TARGET_CLANG_$(arch)!=false and ART_TARGET_CLANG==true
298 $(foreach arch,$(ART_SUPPORTED_ARCH),
299 ifeq ($$(ART_TARGET_CLANG_$(arch)),true)
300 LOCAL_CFLAGS_$(arch) += $$(ART_TARGET_CLANG_CFLAGS_$(arch))
301 endif)
302
303 # Clear locally used variables.
304 art_target_cflags_ndebug_or_debug :=
305endef
306
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700307# Support for disabling certain builds.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700308ART_BUILD_TARGET := false
309ART_BUILD_HOST := false
310ART_BUILD_NDEBUG := false
311ART_BUILD_DEBUG := false
312ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
313 ART_BUILD_TARGET := true
314 ART_BUILD_NDEBUG := true
315endif
316ifeq ($(ART_BUILD_TARGET_DEBUG),true)
317 ART_BUILD_TARGET := true
318 ART_BUILD_DEBUG := true
319endif
320ifeq ($(ART_BUILD_HOST_NDEBUG),true)
321 ART_BUILD_HOST := true
322 ART_BUILD_NDEBUG := true
323endif
324ifeq ($(ART_BUILD_HOST_DEBUG),true)
325 ART_BUILD_HOST := true
326 ART_BUILD_DEBUG := true
327endif
328
Igor Murashkin37743352014-11-13 14:38:00 -0800329endif # ART_ANDROID_COMMON_BUILD_MK