Android.common_build.mk revision 67a4338c5cc91ad3a8a3b99f06e1cf03b232d156
1# 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 17ifndef ANDROID_COMMON_BUILD_MK 18ANDROID_COMMON_BUILD_MK = true 19 20include art/build/Android.common.mk 21 22# These can be overridden via the environment or by editing to 23# enable/disable certain build configuration. 24# 25# For example, to disable everything but the host debug build you use: 26# 27# (export ART_BUILD_TARGET_NDEBUG=false && export ART_BUILD_TARGET_DEBUG=false && export ART_BUILD_HOST_NDEBUG=false && ...) 28# 29# Beware that tests may use the non-debug build for performance, notable 055-enum-performance 30# 31ART_BUILD_TARGET_NDEBUG ?= true 32ART_BUILD_TARGET_DEBUG ?= true 33ART_BUILD_HOST_NDEBUG ?= true 34ART_BUILD_HOST_DEBUG ?= true 35 36ifeq ($(ART_BUILD_TARGET_NDEBUG),false) 37$(info Disabling ART_BUILD_TARGET_NDEBUG) 38endif 39ifeq ($(ART_BUILD_TARGET_DEBUG),false) 40$(info Disabling ART_BUILD_TARGET_DEBUG) 41endif 42ifeq ($(ART_BUILD_HOST_NDEBUG),false) 43$(info Disabling ART_BUILD_HOST_NDEBUG) 44endif 45ifeq ($(ART_BUILD_HOST_DEBUG),false) 46$(info Disabling ART_BUILD_HOST_DEBUG) 47endif 48 49# 50# Used to enable smart mode 51# 52ART_SMALL_MODE := false 53ifneq ($(wildcard art/SMALL_ART),) 54$(info Enabling ART_SMALL_MODE because of existence of art/SMALL_ART) 55ART_SMALL_MODE := true 56endif 57ifeq ($(WITH_ART_SMALL_MODE), true) 58ART_SMALL_MODE := true 59endif 60 61# 62# Used to enable SEA mode 63# 64ART_SEA_IR_MODE := false 65ifneq ($(wildcard art/SEA_IR_ART),) 66$(info Enabling ART_SEA_IR_MODE because of existence of art/SEA_IR_ART) 67ART_SEA_IR_MODE := true 68endif 69ifeq ($(WITH_ART_SEA_IR_MODE), true) 70ART_SEA_IR_MODE := true 71endif 72 73# 74# Used to enable portable mode 75# 76ART_USE_PORTABLE_COMPILER := false 77ifneq ($(wildcard art/USE_PORTABLE_COMPILER),) 78$(info Enabling ART_USE_PORTABLE_COMPILER because of existence of art/USE_PORTABLE_COMPILER) 79ART_USE_PORTABLE_COMPILER := true 80endif 81ifeq ($(WITH_ART_USE_PORTABLE_COMPILER),true) 82$(info Enabling ART_USE_PORTABLE_COMPILER because WITH_ART_USE_PORTABLE_COMPILER=true) 83ART_USE_PORTABLE_COMPILER := true 84endif 85 86# 87# Used to enable optimizing compiler 88# 89ART_USE_OPTIMIZING_COMPILER := false 90ifneq ($(wildcard art/USE_OPTIMIZING_COMPILER),) 91$(info Enabling ART_USE_OPTIMIZING_COMPILER because of existence of art/USE_OPTIMIZING_COMPILER) 92ART_USE_OPTIMIZING_COMPILER := true 93endif 94ifeq ($(WITH_ART_USE_OPTIMIZING_COMPILER), true) 95ART_USE_OPTIMIZING_COMPILER := true 96endif 97 98ifeq ($(ART_USE_OPTIMIZING_COMPILER),true) 99DEX2OAT_FLAGS := --compiler-backend=Optimizing 100DALVIKVM_FLAGS += -Xcompiler-option --compiler-backend=Optimizing 101endif 102 103# 104# Used to change the default GC. Valid values are CMS, SS, GSS. The default is CMS. 105# 106ART_DEFAULT_GC_TYPE ?= CMS 107ART_DEFAULT_GC_TYPE_CFLAGS := -DART_DEFAULT_GC_TYPE_IS_$(ART_DEFAULT_GC_TYPE) 108 109ifeq ($(ART_USE_PORTABLE_COMPILER),true) 110 LLVM_ROOT_PATH := external/llvm 111 # Don't fail a dalvik minimal host build. 112 -include $(LLVM_ROOT_PATH)/llvm.mk 113endif 114 115# Clang build support. 116 117# Host. 118ART_HOST_CLANG := false 119ifneq ($(WITHOUT_HOST_CLANG),true) 120 # By default, host builds use clang for better warnings. 121 ART_HOST_CLANG := true 122endif 123 124# Clang on the target. Target builds use GCC by default. 125ART_TARGET_CLANG := 126ART_TARGET_CLANG_arm := 127ART_TARGET_CLANG_arm64 := 128ART_TARGET_CLANG_mips := 129ART_TARGET_CLANG_x86 := 130ART_TARGET_CLANG_x86_64 := 131 132define set-target-local-clang-vars 133 LOCAL_CLANG := $(ART_TARGET_CLANG) 134 $(foreach arch,$(ART_TARGET_SUPPORTED_ARCH), 135 ifneq ($$(ART_TARGET_CLANG_$(arch)),) 136 LOCAL_CLANG_$(arch) := $$(ART_TARGET_CLANG_$(arch)) 137 endif) 138endef 139 140ART_CPP_EXTENSION := .cc 141 142ART_C_INCLUDES := \ 143 external/gtest/include \ 144 external/valgrind/main/include \ 145 external/valgrind/main \ 146 external/vixl/src \ 147 external/zlib \ 148 frameworks/compile/mclinker/include 149 150art_cflags := \ 151 -fno-rtti \ 152 -std=gnu++11 \ 153 -ggdb3 \ 154 -Wall \ 155 -Werror \ 156 -Wextra \ 157 -Wno-sign-promo \ 158 -Wno-unused-parameter \ 159 -Wstrict-aliasing \ 160 -fstrict-aliasing 161 162ART_TARGET_CLANG_CFLAGS := 163ART_TARGET_CLANG_CFLAGS_arm := 164ART_TARGET_CLANG_CFLAGS_arm64 := 165ART_TARGET_CLANG_CFLAGS_mips := 166ART_TARGET_CLANG_CFLAGS_x86 := 167ART_TARGET_CLANG_CFLAGS_x86_64 := 168 169# these are necessary for Clang ARM64 ART builds 170ART_TARGET_CLANG_CFLAGS_arm64 += \ 171 -Wno-implicit-exception-spec-mismatch \ 172 -DNVALGRIND \ 173 -Wno-unused-value 174 175ifeq ($(ART_SMALL_MODE),true) 176 art_cflags += -DART_SMALL_MODE=1 177endif 178 179ifeq ($(ART_SEA_IR_MODE),true) 180 art_cflags += -DART_SEA_IR_MODE=1 181endif 182 183art_non_debug_cflags := \ 184 -O3 185 186art_host_non_debug_cflags := \ 187 $(art_non_debug_cflags) 188 189art_target_non_debug_cflags := \ 190 $(art_non_debug_cflags) 191 192ifeq ($(HOST_OS),linux) 193 # Larger frame-size for host clang builds today 194 art_host_non_debug_cflags += -Wframe-larger-than=2440 195 art_target_non_debug_cflags += -Wframe-larger-than=1728 196endif 197 198# FIXME: upstream LLVM has a vectorizer bug that needs to be fixed 199ART_TARGET_CLANG_CFLAGS_arm64 += \ 200 -fno-vectorize 201 202art_debug_cflags := \ 203 -O1 \ 204 -DDYNAMIC_ANNOTATIONS_ENABLED=1 \ 205 -UNDEBUG 206 207ifndef LIBART_IMG_HOST_BASE_ADDRESS 208 $(error LIBART_IMG_HOST_BASE_ADDRESS unset) 209endif 210ART_HOST_CFLAGS := $(art_cflags) -DANDROID_SMP=1 -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS) 211ART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default 212ART_HOST_CFLAGS += $(ART_DEFAULT_GC_TYPE_CFLAGS) 213 214ifndef LIBART_IMG_TARGET_BASE_ADDRESS 215 $(error LIBART_IMG_TARGET_BASE_ADDRESS unset) 216endif 217ART_TARGET_CFLAGS := $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS) 218ART_TARGET_LDFLAGS := 219ifeq ($(TARGET_CPU_SMP),true) 220 ART_TARGET_CFLAGS += -DANDROID_SMP=1 221else 222 ifeq ($(TARGET_CPU_SMP),false) 223 ART_TARGET_CFLAGS += -DANDROID_SMP=0 224 else 225 $(warning TARGET_CPU_SMP should be (true|false), found $(TARGET_CPU_SMP)) 226 # Make sure we emit barriers for the worst case. 227 ART_TARGET_CFLAGS += -DANDROID_SMP=1 228 endif 229endif 230ART_TARGET_CFLAGS += $(ART_DEFAULT_GC_TYPE_CFLAGS) 231ifdef PGO_GEN 232 ART_TARGET_CFLAGS += -fprofile-generate=$(PGO_GEN) 233 ART_TARGET_LDFLAGS += -fprofile-generate=$(PGO_GEN) 234endif 235ifdef PGO_USE 236 ART_TARGET_CFLAGS += -fprofile-use=$(PGO_USE) 237 ART_TARGET_CFLAGS += -fprofile-correction -Wno-error 238endif 239 240# DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES is set in ../build/core/dex_preopt.mk based on 241# the TARGET_CPU_VARIANT 242ifeq ($(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),) 243$(error Required DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES is not set) 244endif 245ART_TARGET_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) 246 247# Enable thread-safety for GCC 4.6, and clang, but not for GCC 4.7 or later where this feature was 248# removed. Warn when -Wthread-safety is not used. 249ifneq ($(filter 4.6 4.6.%, $(TARGET_GCC_VERSION)),) 250 ART_TARGET_CFLAGS += -Wthread-safety 251else 252 # FIXME: add -Wthread-safety when the problem is fixed 253 ifeq ($(ART_TARGET_CLANG),true) 254 ART_TARGET_CFLAGS += 255 else 256 # Warn if -Wthread-safety is not supported and not doing a top-level or 'mma' build. 257 ifneq ($(ONE_SHOT_MAKEFILE),) 258 # Enable target GCC 4.6 with: export TARGET_GCC_VERSION_EXP=4.6 259 $(info Using target GCC $(TARGET_GCC_VERSION) disables thread-safety checks.) 260 endif 261 endif 262endif 263# We compile with GCC 4.6 or clang on the host, both of which support -Wthread-safety. 264ART_HOST_CFLAGS += -Wthread-safety 265 266# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16" 267# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs 268 269# Addition CPU specific CFLAGS. 270ifeq ($(TARGET_ARCH),arm) 271 ifneq ($(filter cortex-a15, $(TARGET_CPU_VARIANT)),) 272 # Fake a ARM feature for LPAE support. 273 ART_TARGET_CFLAGS += -D__ARM_FEATURE_LPAE=1 274 endif 275endif 276 277ART_HOST_NON_DEBUG_CFLAGS := $(art_host_non_debug_cflags) 278ART_TARGET_NON_DEBUG_CFLAGS := $(art_target_non_debug_cflags) 279 280# TODO: move -fkeep-inline-functions to art_debug_cflags when target gcc > 4.4 (and -lsupc++) 281ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags) -fkeep-inline-functions 282ART_HOST_DEBUG_LDLIBS := -lsupc++ 283 284ifneq ($(HOST_OS),linux) 285 # Some Mac OS pthread header files are broken with -fkeep-inline-functions. 286 ART_HOST_DEBUG_CFLAGS := $(filter-out -fkeep-inline-functions,$(ART_HOST_DEBUG_CFLAGS)) 287 # Mac OS doesn't have libsupc++. 288 ART_HOST_DEBUG_LDLIBS := $(filter-out -lsupc++,$(ART_HOST_DEBUG_LDLIBS)) 289endif 290 291ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags) 292 293# $(1): ndebug_or_debug 294define set-target-local-cflags-vars 295 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS) 296 LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86) 297 LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS) 298 art_target_cflags_ndebug_or_debug := $(1) 299 ifeq ($$(art_target_cflags_ndebug_or_debug),debug) 300 LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS) 301 else 302 LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS) 303 endif 304 305 # TODO: Also set when ART_TARGET_CLANG_$(arch)!=false and ART_TARGET_CLANG==true 306 $(foreach arch,$(ART_SUPPORTED_ARCH), 307 ifeq ($$(ART_TARGET_CLANG_$(arch)),true) 308 LOCAL_CFLAGS_$(arch) += $$(ART_TARGET_CLANG_CFLAGS_$(arch)) 309 endif) 310 311 # Clear locally used variables. 312 art_target_cflags_ndebug_or_debug := 313endef 314 315ART_BUILD_TARGET := false 316ART_BUILD_HOST := false 317ART_BUILD_NDEBUG := false 318ART_BUILD_DEBUG := false 319ifeq ($(ART_BUILD_TARGET_NDEBUG),true) 320 ART_BUILD_TARGET := true 321 ART_BUILD_NDEBUG := true 322endif 323ifeq ($(ART_BUILD_TARGET_DEBUG),true) 324 ART_BUILD_TARGET := true 325 ART_BUILD_DEBUG := true 326endif 327ifeq ($(ART_BUILD_HOST_NDEBUG),true) 328 ART_BUILD_HOST := true 329 ART_BUILD_NDEBUG := true 330endif 331ifeq ($(ART_BUILD_HOST_DEBUG),true) 332 ART_BUILD_HOST := true 333 ART_BUILD_DEBUG := true 334endif 335 336# Clear locally defined variables that aren't necessary in the rest of the build system. 337ART_DEFAULT_GC_TYPE := 338ART_DEFAULT_GC_TYPE_CFLAGS := 339art_cflags := 340art_target_non_debug_cflags := 341art_host_non_debug_cflags := 342art_non_debug_cflags := 343 344endif # ANDROID_COMMON_BUILD_MK 345