blob: 34b692fe3952590722e60b66c7e54a04f4e00867 [file] [log] [blame]
Carl Shapiro7b216702011-06-17 15:09:26 -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
Dragos Sbirlea37c19bc2013-07-29 09:38:31 -070017ifndef ANDROID_COMMON_MK
18ANDROID_COMMON_MK = true
19
Colin Crossdc781a12014-02-04 16:22:03 -080020ART_SUPPORTED_ARCH := arm mips x86 x86_64
21
22ifeq (,$(filter $(TARGET_ARCH),$(ART_SUPPORTED_ARCH)))
23$(warning unsupported TARGET_ARCH=$(TARGET_ARCH))
24endif
25
Brian Carlstrom7940e442013-07-12 13:46:57 -070026# These can be overridden via the environment or by editing to
27# enable/disable certain build configuration.
28#
29# For example, to disable everything but the host debug build you use:
30#
31# (export ART_BUILD_TARGET_NDEBUG=false && export ART_BUILD_TARGET_DEBUG=false && export ART_BUILD_HOST_NDEBUG=false && ...)
32#
33# Beware that tests may use the non-debug build for performance, notable 055-enum-performance
34#
35ART_BUILD_TARGET_NDEBUG ?= true
36ART_BUILD_TARGET_DEBUG ?= true
Brian Carlstrom19e776c2013-07-23 12:16:44 -070037ART_BUILD_HOST_NDEBUG ?= $(WITH_HOST_DALVIK)
38ART_BUILD_HOST_DEBUG ?= $(WITH_HOST_DALVIK)
Brian Carlstrom7940e442013-07-12 13:46:57 -070039
40ifeq ($(ART_BUILD_TARGET_NDEBUG),false)
41$(info Disabling ART_BUILD_TARGET_NDEBUG)
42endif
43ifeq ($(ART_BUILD_TARGET_DEBUG),false)
44$(info Disabling ART_BUILD_TARGET_DEBUG)
45endif
46ifeq ($(ART_BUILD_HOST_NDEBUG),false)
47$(info Disabling ART_BUILD_HOST_NDEBUG)
48endif
49ifeq ($(ART_BUILD_HOST_DEBUG),false)
50$(info Disabling ART_BUILD_HOST_DEBUG)
51endif
52
53#
54# Used to enable smart mode
55#
Anwar Ghuloum8447d842013-04-30 17:27:40 -070056ART_SMALL_MODE := false
57ifneq ($(wildcard art/SMALL_ART),)
58$(info Enabling ART_SMALL_MODE because of existence of art/SMALL_ART)
59ART_SMALL_MODE := true
Ian Rogersf3e98552013-03-20 15:49:49 -070060endif
Anwar Ghulouma72dd8b2013-06-03 17:01:15 -070061ifeq ($(WITH_ART_SMALL_MODE), true)
62ART_SMALL_MODE := true
63endif
Ian Rogersf3e98552013-03-20 15:49:49 -070064
Brian Carlstrom7940e442013-07-12 13:46:57 -070065#
66# Used to enable SEA mode
67#
Dragos Sbirlea7467ee02013-06-21 09:20:34 -070068ART_SEA_IR_MODE := false
69ifneq ($(wildcard art/SEA_IR_ART),)
70$(info Enabling ART_SEA_IR_MODE because of existence of art/SEA_IR_ART)
71ART_SEA_IR_MODE := true
72endif
73ifeq ($(WITH_ART_SEA_IR_MODE), true)
74ART_SEA_IR_MODE := true
75endif
76
Brian Carlstrom7940e442013-07-12 13:46:57 -070077#
78# Used to enable portable mode
79#
Brian Carlstrom06809ed2012-09-17 14:19:20 -070080ART_USE_PORTABLE_COMPILER := false
81ifneq ($(wildcard art/USE_PORTABLE_COMPILER),)
82$(info Enabling ART_USE_PORTABLE_COMPILER because of existence of art/USE_PORTABLE_COMPILER)
83ART_USE_PORTABLE_COMPILER := true
84endif
85ifeq ($(WITH_ART_USE_PORTABLE_COMPILER),true)
86$(info Enabling ART_USE_PORTABLE_COMPILER because WITH_ART_USE_PORTABLE_COMPILER=true)
87ART_USE_PORTABLE_COMPILER := true
88endif
Shih-wei Liaod1fec812012-02-13 09:51:10 -080089
Shih-wei Liaod1fec812012-02-13 09:51:10 -080090LLVM_ROOT_PATH := external/llvm
Ying Wangd9101722013-09-18 09:36:27 -070091# Don't fail a dalvik minimal host build.
92-include $(LLVM_ROOT_PATH)/llvm.mk
Shih-wei Liaod1fec812012-02-13 09:51:10 -080093
Ian Rogers35df1f32014-03-08 23:48:23 -080094# Clang build support. By default, host builds use clang for better warnings.
95# Target builds use GCC by default.
96# TODO: work out why arm64 target builds need GCC on the host.
Ian Rogersb48b9eb2014-02-28 16:20:21 -080097ART_TARGET_CLANG := false
Ian Rogers35df1f32014-03-08 23:48:23 -080098ifneq ($(TARGET_ARCH),arm64)
99 ART_HOST_CLANG := true
100else
101 ART_HOST_CLANG := false
102endif
Ian Rogerscd5d0422013-05-17 15:54:01 -0700103
Brian Carlstromb32a3ad2014-01-20 14:48:07 -0800104# directory used for dalvik-cache on device
105ART_DALVIK_CACHE_DIR := /data/dalvik-cache
106
Brian Carlstrom32b4b2a2012-01-31 16:21:40 -0800107# directory used for gtests on device
108ART_NATIVETEST_DIR := /data/nativetest/art
109ART_NATIVETEST_OUT := $(TARGET_OUT_DATA_NATIVE_TESTS)/art
110
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700111# directory used for tests on device
112ART_TEST_DIR := /data/art-test
113ART_TEST_OUT := $(TARGET_OUT_DATA)/art-test
114
Brian Carlstromcdc8de42011-07-19 14:23:17 -0700115ART_CPP_EXTENSION := .cc
Carl Shapiro9bf84fd2011-06-17 17:05:25 -0700116
Brian Carlstrom7940e442013-07-12 13:46:57 -0700117ART_HOST_SHLIB_EXTENSION := $(HOST_SHLIB_SUFFIX)
118ART_HOST_SHLIB_EXTENSION ?= .so
119
Elliott Hughes0af55432011-08-17 18:37:28 -0700120ART_C_INCLUDES := \
121 external/gtest/include \
Ian Rogers1d54e732013-05-02 21:10:01 -0700122 external/valgrind/main/include \
Mathieu Chartier75165d02013-09-12 14:00:31 -0700123 external/valgrind/main \
Serban Constantinescued8dd492014-02-11 14:15:10 +0000124 external/vixl/src \
buzbeec143c552011-08-20 17:38:58 -0700125 external/zlib \
Brian Carlstrom7940e442013-07-12 13:46:57 -0700126 frameworks/compile/mclinker/include
Brian Carlstromb0460ea2011-07-29 10:08:05 -0700127
Elliott Hughes1d3f1142011-09-13 12:00:00 -0700128art_cflags := \
Ian Rogers637c65b2013-05-31 11:46:00 -0700129 -fno-rtti \
Mathieu Chartier9b3c3cd2013-08-12 17:41:54 -0700130 -std=gnu++11 \
Carl Shapiro1fb86202011-06-27 17:43:13 -0700131 -ggdb3 \
132 -Wall \
133 -Werror \
134 -Wextra \
Nicolas Geoffrayf3e2cc42014-02-18 18:37:26 +0000135 -Wno-sign-promo \
136 -Wno-unused-parameter \
Mark Mendell3f2d0312014-01-20 17:20:27 -0800137 -Wstrict-aliasing \
Carl Shapiro1fb86202011-06-27 17:43:13 -0700138 -fstrict-aliasing
139
Anwar Ghuloumc44f68f2013-05-10 13:24:54 -0700140ifeq ($(ART_SMALL_MODE),true)
141 art_cflags += -DART_SMALL_MODE=1
Ian Rogersf3e98552013-03-20 15:49:49 -0700142endif
143
Dragos Sbirlea7467ee02013-06-21 09:20:34 -0700144ifeq ($(ART_SEA_IR_MODE),true)
145 art_cflags += -DART_SEA_IR_MODE=1
146endif
147
Brian Carlstrom69d7a6b2011-12-15 17:31:21 -0800148ifeq ($(HOST_OS),linux)
Shih-wei Liao24782c62012-01-08 12:46:11 -0800149 art_non_debug_cflags := \
Elliott Hughes3b6baaa2011-10-14 19:13:56 -0700150 -Wframe-larger-than=1728
Brian Carlstrom69d7a6b2011-12-15 17:31:21 -0800151endif
Elliott Hughes3b6baaa2011-10-14 19:13:56 -0700152
Ian Rogers8d11af52013-08-15 14:24:29 -0700153art_non_debug_cflags := \
154 -O3
155
Elliott Hughes3b6baaa2011-10-14 19:13:56 -0700156art_debug_cflags := \
Ian Rogers8d11af52013-08-15 14:24:29 -0700157 -O1 \
Elliott Hughes06e3ad42012-02-07 14:51:57 -0800158 -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
Elliott Hughes3b6baaa2011-10-14 19:13:56 -0700159 -UNDEBUG
160
Brian Carlstrom7ab763c2013-12-09 00:38:02 -0800161ART_HOST_CFLAGS := $(art_cflags) -DANDROID_SMP=1 -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS)
Brian Carlstrom1bd2ceb2013-11-06 00:29:48 -0800162ART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default
Elliott Hughes1d3f1142011-09-13 12:00:00 -0700163
Brian Carlstrom7ab763c2013-12-09 00:38:02 -0800164ART_TARGET_CFLAGS := $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS)
Elliott Hughes1d3f1142011-09-13 12:00:00 -0700165ifeq ($(TARGET_CPU_SMP),true)
166 ART_TARGET_CFLAGS += -DANDROID_SMP=1
167else
168 ART_TARGET_CFLAGS += -DANDROID_SMP=0
169endif
170
Brian Carlstrom1bd2ceb2013-11-06 00:29:48 -0800171# DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES is set in ../build/core/dex_preopt.mk based on
172# the TARGET_CPU_VARIANT
173ifeq ($(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
174$(error Required DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES is not set)
175endif
176ART_TARGET_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
177
Ian Rogers719d1a32014-03-06 12:13:39 -0800178# Enable thread-safety for GCC 4.6, and clang, but not for GCC 4.7 or later where this feature was
179# removed. Warn when -Wthread-safety is not used.
Ian Rogersba3ce9a2013-05-17 18:50:09 -0700180ifneq ($(filter 4.6 4.6.%, $(TARGET_GCC_VERSION)),)
181 ART_TARGET_CFLAGS += -Wthread-safety
182else
Ian Rogers719d1a32014-03-06 12:13:39 -0800183 ifeq ($(ART_TARGET_CLANG),true)
184 ART_TARGET_CFLAGS += -Wthread-safety
185 else
186 # Warn if -Wthread-safety is not suport and not doing a top-level or 'mma' build.
187 ifneq ($(ONE_SHOT_MAKEFILE),)
188 # Enable target GCC 4.6 with: export TARGET_GCC_VERSION_EXP=4.6
189 $(info Using target GCC $(TARGET_GCC_VERSION) disables thread-safety checks.)
190 endif
Ian Rogersba3ce9a2013-05-17 18:50:09 -0700191 endif
192endif
Ian Rogers719d1a32014-03-06 12:13:39 -0800193# We compile with GCC 4.6 or clang on the host, both of which support -Wthread-safety.
Ian Rogersba3ce9a2013-05-17 18:50:09 -0700194ART_HOST_CFLAGS += -Wthread-safety
195
Brian Carlstrom89521892011-12-07 22:05:07 -0800196# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
197# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
198
Elliott Hughes3b6baaa2011-10-14 19:13:56 -0700199ART_HOST_NON_DEBUG_CFLAGS := $(art_non_debug_cflags)
200ART_TARGET_NON_DEBUG_CFLAGS := $(art_non_debug_cflags)
201
Brian Carlstromfd2ec542012-05-02 15:08:57 -0700202# TODO: move -fkeep-inline-functions to art_debug_cflags when target gcc > 4.4 (and -lsupc++)
Elliott Hughes1ba27142012-01-20 15:32:00 -0800203ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags) -fkeep-inline-functions
Brian Carlstromfd2ec542012-05-02 15:08:57 -0700204ART_HOST_DEBUG_LDLIBS := -lsupc++
Elliott Hughesad6c9c32012-01-19 17:39:12 -0800205
206ifneq ($(HOST_OS),linux)
207 # Some Mac OS pthread header files are broken with -fkeep-inline-functions.
Elliott Hughes34cf5142012-01-20 16:39:13 -0800208 ART_HOST_DEBUG_CFLAGS := $(filter-out -fkeep-inline-functions,$(ART_HOST_DEBUG_CFLAGS))
Elliott Hughes60234562012-06-01 12:25:59 -0700209 # Mac OS doesn't have libsupc++.
210 ART_HOST_DEBUG_LDLIBS := $(filter-out -lsupc++,$(ART_HOST_DEBUG_LDLIBS))
Elliott Hughesad6c9c32012-01-19 17:39:12 -0800211endif
212
Brian Carlstrom86927212011-09-15 11:31:11 -0700213ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
Elliott Hughes1d3f1142011-09-13 12:00:00 -0700214
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700215ART_BUILD_TARGET := false
216ART_BUILD_HOST := false
Brian Carlstrom265091e2013-01-30 14:08:26 -0800217ART_BUILD_NDEBUG := false
218ART_BUILD_DEBUG := false
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700219ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
220 ART_BUILD_TARGET := true
Brian Carlstrom265091e2013-01-30 14:08:26 -0800221 ART_BUILD_NDEBUG := true
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700222endif
223ifeq ($(ART_BUILD_TARGET_DEBUG),true)
224 ART_BUILD_TARGET := true
Brian Carlstrom265091e2013-01-30 14:08:26 -0800225 ART_BUILD_DEBUG := true
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700226endif
227ifeq ($(ART_BUILD_HOST_NDEBUG),true)
228 ART_BUILD_HOST := true
Brian Carlstrom265091e2013-01-30 14:08:26 -0800229 ART_BUILD_NDEBUG := true
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700230endif
231ifeq ($(ART_BUILD_HOST_DEBUG),true)
232 ART_BUILD_HOST := true
Brian Carlstrom265091e2013-01-30 14:08:26 -0800233 ART_BUILD_DEBUG := true
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700234endif
Dragos Sbirlea37c19bc2013-07-29 09:38:31 -0700235
236endif # ANDROID_COMMON_MK