blob: 1e074305d30d40c8b8c088aabf9566c0b2484309 [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
87ifeq ($(TARGET_ARCH),mips)
88 # 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
Ian Rogersafd9acc2014-06-17 08:21:54 -070098ART_TARGET_CLANG_x86 :=
99ART_TARGET_CLANG_x86_64 :=
100
101define set-target-local-clang-vars
102 LOCAL_CLANG := $(ART_TARGET_CLANG)
103 $(foreach arch,$(ART_TARGET_SUPPORTED_ARCH),
104 ifneq ($$(ART_TARGET_CLANG_$(arch)),)
105 LOCAL_CLANG_$(arch) := $$(ART_TARGET_CLANG_$(arch))
106 endif)
107endef
108
Ian Rogersafd9acc2014-06-17 08:21:54 -0700109ART_TARGET_CLANG_CFLAGS :=
110ART_TARGET_CLANG_CFLAGS_arm :=
111ART_TARGET_CLANG_CFLAGS_arm64 :=
112ART_TARGET_CLANG_CFLAGS_mips :=
113ART_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 += \
118 -Wno-implicit-exception-spec-mismatch \
119 -DNVALGRIND \
120 -Wno-unused-value
121
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700122# FIXME: upstream LLVM has a vectorizer bug that needs to be fixed
123ART_TARGET_CLANG_CFLAGS_arm64 += \
124 -fno-vectorize
125
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700126# Warn about thread safety violations with clang.
Dan Albert6c7cdc52014-12-02 14:58:06 -0800127art_clang_cflags := -Wthread-safety
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700128
129# Warn if switch fallthroughs aren't annotated.
130art_clang_cflags += -Wimplicit-fallthrough
131
132# Enable float equality warnings.
133art_clang_cflags += -Wfloat-equal
134
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800135# Enable warning of converting ints to void*.
136art_clang_cflags += -Wint-to-void-pointer-cast
137
138# GCC-only warnings.
139art_gcc_cflags := -Wunused-but-set-parameter
140# Suggest const: too many false positives, but good for a trial run.
141# -Wsuggest-attribute=const
142# Useless casts: too many, as we need to be 32/64 agnostic, but the compiler knows.
143# -Wuseless-cast
144# Zero-as-null: Have to convert all NULL and "diagnostic ignore" all includes like libnativehelper
145# that are still stuck pre-C++11.
146# -Wzero-as-null-pointer-constant \
147# Suggest final: Have to move to a more recent GCC.
148# -Wsuggest-final-types
149
Andreas Gampebced67d2015-01-07 14:35:44 -0800150ART_TARGET_CLANG_CFLAGS := $(art_clang_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700151ifeq ($(ART_HOST_CLANG),true)
Ian Rogers4ad5cd32014-11-11 23:08:07 -0800152 # Bug: 15446488. We don't omit the frame pointer to work around
153 # clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
154 ART_HOST_CFLAGS += $(art_clang_cflags) -fno-omit-frame-pointer
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800155else
156 ART_HOST_CFLAGS += $(art_gcc_cflags)
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700157endif
Andreas Gampebced67d2015-01-07 14:35:44 -0800158ifneq ($(ART_TARGET_CLANG),true)
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800159 ART_TARGET_CFLAGS += $(art_gcc_cflags)
Andreas Gampebced67d2015-01-07 14:35:44 -0800160else
161 # TODO: if we ever want to support GCC/Clang mix for multi-target products, this needs to be
162 # split up.
163 ifeq ($(ART_TARGET_CLANG_$(TARGET_ARCH)),false)
164 ART_TARGET_CFLAGS += $(art_gcc_cflags)
165 endif
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700166endif
167
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800168# Clear local variables now their use has ended.
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700169art_clang_cflags :=
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800170art_gcc_cflags :=
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700171
172ART_CPP_EXTENSION := .cc
173
174ART_C_INCLUDES := \
175 external/gtest/include \
176 external/valgrind/main/include \
177 external/valgrind/main \
178 external/vixl/src \
179 external/zlib \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700180
181# Base set of cflags used by all things ART.
182art_cflags := \
183 -fno-rtti \
184 -std=gnu++11 \
185 -ggdb3 \
186 -Wall \
187 -Werror \
188 -Wextra \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700189 -Wstrict-aliasing \
190 -fstrict-aliasing \
191 -Wunreachable-code \
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800192 -Wno-conversion-null \
193 -Wredundant-decls \
194 -Wshadow \
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700195 -fvisibility=protected \
196 $(art_default_gc_type_cflags)
197
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800198# Missing declarations: too many at the moment, as we use "extern" quite a bit.
199# -Wmissing-declarations \
200
201
Mathieu Chartiercd195fe2014-11-25 18:36:01 -0800202
203ifdef ART_IMT_SIZE
204 art_cflags += -DIMT_SIZE=$(ART_IMT_SIZE)
205else
206 # Default is 64
207 art_cflags += -DIMT_SIZE=64
208endif
209
Ian Rogersafd9acc2014-06-17 08:21:54 -0700210ifeq ($(ART_SMALL_MODE),true)
211 art_cflags += -DART_SMALL_MODE=1
212endif
213
Nicolas Geoffray9bb492a2014-11-25 23:42:00 +0000214ifeq ($(ART_USE_OPTIMIZING_COMPILER),true)
215 art_cflags += -DART_USE_OPTIMIZING_COMPILER=1
216endif
217
Hiroshi Yamauchib0d22f12014-12-08 12:08:46 -0800218ifeq ($(ART_HEAP_POISONING),true)
219 art_cflags += -DART_HEAP_POISONING=1
220endif
221
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700222# Cflags for non-debug ART and ART tools.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700223art_non_debug_cflags := \
224 -O3
225
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700226# Cflags for debug ART and ART tools.
227art_debug_cflags := \
228 -O2 \
229 -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
Serban Constantinescu32f5b4d2014-11-25 20:05:46 +0000230 -DVIXL_DEBUG \
Ian Rogers50fe6da2014-10-17 01:18:08 -0700231 -UNDEBUG
Stephen Hines67a43382014-07-17 01:49:18 -0700232
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700233art_host_non_debug_cflags := $(art_non_debug_cflags)
234art_target_non_debug_cflags := $(art_non_debug_cflags)
Stephen Hines67a43382014-07-17 01:49:18 -0700235
Ian Rogersafd9acc2014-06-17 08:21:54 -0700236ifeq ($(HOST_OS),linux)
Stephen Hines67a43382014-07-17 01:49:18 -0700237 # Larger frame-size for host clang builds today
Dan Albert98b8bcf2014-11-14 19:56:21 -0800238 ifndef SANITIZE_HOST
Mathieu Chartier88f21ca2014-11-18 14:13:58 -0800239 art_host_non_debug_cflags += -Wframe-larger-than=2700
Dan Albert98b8bcf2014-11-14 19:56:21 -0800240 endif
Stephen Hines67a43382014-07-17 01:49:18 -0700241 art_target_non_debug_cflags += -Wframe-larger-than=1728
Ian Rogersafd9acc2014-06-17 08:21:54 -0700242endif
243
Ying Wanga28ff0f2014-12-08 14:29:34 -0800244ifndef LIBART_IMG_HOST_BASE_ADDRESS
245 $(error LIBART_IMG_HOST_BASE_ADDRESS unset)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700246endif
Ying Wanga28ff0f2014-12-08 14:29:34 -0800247ART_HOST_CFLAGS += $(art_cflags) -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS)
248ART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default
249
250ifndef LIBART_IMG_TARGET_BASE_ADDRESS
251 $(error LIBART_IMG_TARGET_BASE_ADDRESS unset)
252endif
253ART_TARGET_CFLAGS += $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS)
Alex Lighta59dd802014-07-02 16:28:08 -0700254
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700255ART_HOST_NON_DEBUG_CFLAGS := $(art_host_non_debug_cflags)
256ART_TARGET_NON_DEBUG_CFLAGS := $(art_target_non_debug_cflags)
257ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags)
258ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
259
Alex Lighta59dd802014-07-02 16:28:08 -0700260ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA
261 LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA=-0x1000000
262endif
263ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA
264 LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA=0x1000000
265endif
266ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
267ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
268
269ifndef LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA
270 LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA=-0x1000000
271endif
272ifndef LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA
273 LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA=0x1000000
274endif
275ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA)
276ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA)
277
Ian Rogersafd9acc2014-06-17 08:21:54 -0700278# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
279# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
280
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700281# Clear locals now they've served their purpose.
282art_cflags :=
283art_debug_cflags :=
284art_non_debug_cflags :=
285art_host_non_debug_cflags :=
286art_target_non_debug_cflags :=
287art_default_gc_type :=
288art_default_gc_type_cflags :=
289
290ART_HOST_LDLIBS :=
291ifneq ($(ART_HOST_CLANG),true)
292 # GCC lacks libc++ assumed atomic operations, grab via libatomic.
293 ART_HOST_LDLIBS += -latomic
Ian Rogersafd9acc2014-06-17 08:21:54 -0700294endif
295
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700296ART_TARGET_LDFLAGS :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700297
298# $(1): ndebug_or_debug
299define set-target-local-cflags-vars
300 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
301 LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86)
Dehao Chen997660d2014-07-08 10:00:56 -0700302 LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700303 art_target_cflags_ndebug_or_debug := $(1)
304 ifeq ($$(art_target_cflags_ndebug_or_debug),debug)
305 LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
306 else
307 LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
308 endif
309
Andreas Gampebced67d2015-01-07 14:35:44 -0800310 LOCAL_CLANG_CFLAGS := $(ART_TARGET_CLANG_CFLAGS)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700311 $(foreach arch,$(ART_SUPPORTED_ARCH),
Andreas Gampebced67d2015-01-07 14:35:44 -0800312 LOCAL_CLANG_CFLAGS_$(arch) += $$(ART_TARGET_CLANG_CFLAGS_$(arch)))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700313
314 # Clear locally used variables.
315 art_target_cflags_ndebug_or_debug :=
316endef
317
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700318# Support for disabling certain builds.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700319ART_BUILD_TARGET := false
320ART_BUILD_HOST := false
321ART_BUILD_NDEBUG := false
322ART_BUILD_DEBUG := false
323ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
324 ART_BUILD_TARGET := true
325 ART_BUILD_NDEBUG := true
326endif
327ifeq ($(ART_BUILD_TARGET_DEBUG),true)
328 ART_BUILD_TARGET := true
329 ART_BUILD_DEBUG := true
330endif
331ifeq ($(ART_BUILD_HOST_NDEBUG),true)
332 ART_BUILD_HOST := true
333 ART_BUILD_NDEBUG := true
334endif
335ifeq ($(ART_BUILD_HOST_DEBUG),true)
336 ART_BUILD_HOST := true
337 ART_BUILD_DEBUG := true
338endif
339
Igor Murashkin37743352014-11-13 14:38:00 -0800340endif # ART_ANDROID_COMMON_BUILD_MK