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