Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 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 | # |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 89 | ifeq ($(ART_USE_OPTIMIZING_COMPILER),true) |
| 90 | DEX2OAT_FLAGS := --compiler-backend=Optimizing |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 91 | endif |
| 92 | |
| 93 | # |
| 94 | # Used to change the default GC. Valid values are CMS, SS, GSS. The default is CMS. |
| 95 | # |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 96 | art_default_gc_type ?= CMS |
| 97 | art_default_gc_type_cflags := -DART_DEFAULT_GC_TYPE_IS_$(art_default_gc_type) |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 98 | |
| 99 | ifeq ($(ART_USE_PORTABLE_COMPILER),true) |
| 100 | LLVM_ROOT_PATH := external/llvm |
| 101 | # Don't fail a dalvik minimal host build. |
| 102 | -include $(LLVM_ROOT_PATH)/llvm.mk |
| 103 | endif |
| 104 | |
| 105 | # Clang build support. |
| 106 | |
| 107 | # Host. |
| 108 | ART_HOST_CLANG := false |
| 109 | ifneq ($(WITHOUT_HOST_CLANG),true) |
| 110 | # By default, host builds use clang for better warnings. |
| 111 | ART_HOST_CLANG := true |
| 112 | endif |
| 113 | |
Sebastien Hertz | ea521dc | 2014-06-25 18:50:01 +0200 | [diff] [blame] | 114 | # Clang on the target. Target builds use GCC by default. |
Bernhard Rosenkraenzer | 88c0569 | 2014-10-04 19:02:06 +0200 | [diff] [blame] | 115 | ifneq ($(USE_CLANG_PLATFORM_BUILD),) |
| 116 | ART_TARGET_CLANG := $(USE_CLANG_PLATFORM_BUILD) |
| 117 | else |
Ian Rogers | d642a91 | 2014-10-02 09:41:44 -0700 | [diff] [blame] | 118 | ART_TARGET_CLANG := false |
Bernhard Rosenkraenzer | 88c0569 | 2014-10-04 19:02:06 +0200 | [diff] [blame] | 119 | endif |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 120 | ART_TARGET_CLANG_arm := |
Sebastien Hertz | ea521dc | 2014-06-25 18:50:01 +0200 | [diff] [blame] | 121 | ART_TARGET_CLANG_arm64 := |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 122 | ART_TARGET_CLANG_mips := |
| 123 | ART_TARGET_CLANG_x86 := |
| 124 | ART_TARGET_CLANG_x86_64 := |
| 125 | |
| 126 | define set-target-local-clang-vars |
| 127 | LOCAL_CLANG := $(ART_TARGET_CLANG) |
| 128 | $(foreach arch,$(ART_TARGET_SUPPORTED_ARCH), |
| 129 | ifneq ($$(ART_TARGET_CLANG_$(arch)),) |
| 130 | LOCAL_CLANG_$(arch) := $$(ART_TARGET_CLANG_$(arch)) |
| 131 | endif) |
| 132 | endef |
| 133 | |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 134 | ART_TARGET_CLANG_CFLAGS := |
| 135 | ART_TARGET_CLANG_CFLAGS_arm := |
| 136 | ART_TARGET_CLANG_CFLAGS_arm64 := |
| 137 | ART_TARGET_CLANG_CFLAGS_mips := |
| 138 | ART_TARGET_CLANG_CFLAGS_x86 := |
| 139 | ART_TARGET_CLANG_CFLAGS_x86_64 := |
| 140 | |
Ian Rogers | d642a91 | 2014-10-02 09:41:44 -0700 | [diff] [blame] | 141 | # These are necessary for Clang ARM64 ART builds. TODO: remove. |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 142 | ART_TARGET_CLANG_CFLAGS_arm64 += \ |
| 143 | -Wno-implicit-exception-spec-mismatch \ |
| 144 | -DNVALGRIND \ |
| 145 | -Wno-unused-value |
| 146 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 147 | # FIXME: upstream LLVM has a vectorizer bug that needs to be fixed |
| 148 | ART_TARGET_CLANG_CFLAGS_arm64 += \ |
| 149 | -fno-vectorize |
| 150 | |
| 151 | # Colorize clang compiler warnings. |
| 152 | art_clang_cflags := -fcolor-diagnostics |
| 153 | |
| 154 | # Warn about thread safety violations with clang. |
| 155 | art_clang_cflags += -Wthread-safety |
| 156 | |
| 157 | # Warn if switch fallthroughs aren't annotated. |
| 158 | art_clang_cflags += -Wimplicit-fallthrough |
| 159 | |
| 160 | # Enable float equality warnings. |
| 161 | art_clang_cflags += -Wfloat-equal |
| 162 | |
| 163 | ifeq ($(ART_HOST_CLANG),true) |
| 164 | ART_HOST_CFLAGS += $(art_clang_cflags) |
| 165 | endif |
| 166 | ifeq ($(ART_TARGET_CLANG),true) |
| 167 | ART_TARGET_CFLAGS += $(art_clang_cflags) |
| 168 | endif |
| 169 | |
| 170 | # Clear local variable now its use has ended. |
| 171 | art_clang_cflags := |
| 172 | |
| 173 | ART_CPP_EXTENSION := .cc |
| 174 | |
| 175 | ART_C_INCLUDES := \ |
| 176 | external/gtest/include \ |
| 177 | external/valgrind/main/include \ |
| 178 | external/valgrind/main \ |
| 179 | external/vixl/src \ |
| 180 | external/zlib \ |
| 181 | frameworks/compile/mclinker/include |
| 182 | |
| 183 | # Base set of cflags used by all things ART. |
| 184 | art_cflags := \ |
| 185 | -fno-rtti \ |
| 186 | -std=gnu++11 \ |
| 187 | -ggdb3 \ |
| 188 | -Wall \ |
| 189 | -Werror \ |
| 190 | -Wextra \ |
| 191 | -Wno-sign-promo \ |
| 192 | -Wno-unused-parameter \ |
| 193 | -Wstrict-aliasing \ |
| 194 | -fstrict-aliasing \ |
| 195 | -Wunreachable-code \ |
| 196 | -fvisibility=protected \ |
| 197 | $(art_default_gc_type_cflags) |
| 198 | |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 199 | ifeq ($(ART_SMALL_MODE),true) |
| 200 | art_cflags += -DART_SMALL_MODE=1 |
| 201 | endif |
| 202 | |
| 203 | ifeq ($(ART_SEA_IR_MODE),true) |
| 204 | art_cflags += -DART_SEA_IR_MODE=1 |
| 205 | endif |
| 206 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 207 | # Cflags for non-debug ART and ART tools. |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 208 | art_non_debug_cflags := \ |
| 209 | -O3 |
| 210 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 211 | # Cflags for debug ART and ART tools. |
| 212 | art_debug_cflags := \ |
| 213 | -O2 \ |
| 214 | -DDYNAMIC_ANNOTATIONS_ENABLED=1 \ |
| 215 | -UNDEBUG \ |
| 216 | -fkeep-inline-functions |
Stephen Hines | 67a4338 | 2014-07-17 01:49:18 -0700 | [diff] [blame] | 217 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 218 | art_host_non_debug_cflags := $(art_non_debug_cflags) |
| 219 | art_target_non_debug_cflags := $(art_non_debug_cflags) |
Stephen Hines | 67a4338 | 2014-07-17 01:49:18 -0700 | [diff] [blame] | 220 | |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 221 | ifeq ($(HOST_OS),linux) |
Stephen Hines | 67a4338 | 2014-07-17 01:49:18 -0700 | [diff] [blame] | 222 | # Larger frame-size for host clang builds today |
Stephen Hines | 1159727 | 2014-07-23 19:47:35 -0700 | [diff] [blame] | 223 | art_host_non_debug_cflags += -Wframe-larger-than=2600 |
Stephen Hines | 67a4338 | 2014-07-17 01:49:18 -0700 | [diff] [blame] | 224 | art_target_non_debug_cflags += -Wframe-larger-than=1728 |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 225 | endif |
| 226 | |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 227 | ifndef LIBART_IMG_HOST_BASE_ADDRESS |
| 228 | $(error LIBART_IMG_HOST_BASE_ADDRESS unset) |
| 229 | endif |
| 230 | ART_HOST_CFLAGS := $(art_cflags) -DANDROID_SMP=1 -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS) |
| 231 | ART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 232 | |
| 233 | ifndef LIBART_IMG_TARGET_BASE_ADDRESS |
| 234 | $(error LIBART_IMG_TARGET_BASE_ADDRESS unset) |
| 235 | endif |
| 236 | ART_TARGET_CFLAGS := $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS) |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 237 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 238 | ART_HOST_NON_DEBUG_CFLAGS := $(art_host_non_debug_cflags) |
| 239 | ART_TARGET_NON_DEBUG_CFLAGS := $(art_target_non_debug_cflags) |
| 240 | ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags) |
| 241 | ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags) |
| 242 | |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 243 | ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA |
| 244 | LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA=-0x1000000 |
| 245 | endif |
| 246 | ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA |
| 247 | LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA=0x1000000 |
| 248 | endif |
| 249 | ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA) |
| 250 | ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA) |
| 251 | |
| 252 | ifndef LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA |
| 253 | LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA=-0x1000000 |
| 254 | endif |
| 255 | ifndef LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA |
| 256 | LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA=0x1000000 |
| 257 | endif |
| 258 | ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA) |
| 259 | ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA) |
| 260 | |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 261 | ifeq ($(TARGET_CPU_SMP),true) |
| 262 | ART_TARGET_CFLAGS += -DANDROID_SMP=1 |
| 263 | else |
| 264 | ifeq ($(TARGET_CPU_SMP),false) |
| 265 | ART_TARGET_CFLAGS += -DANDROID_SMP=0 |
| 266 | else |
| 267 | $(warning TARGET_CPU_SMP should be (true|false), found $(TARGET_CPU_SMP)) |
| 268 | # Make sure we emit barriers for the worst case. |
| 269 | ART_TARGET_CFLAGS += -DANDROID_SMP=1 |
| 270 | endif |
| 271 | endif |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 272 | |
| 273 | # To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16" |
| 274 | # ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs |
| 275 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 276 | # Clear locals now they've served their purpose. |
| 277 | art_cflags := |
| 278 | art_debug_cflags := |
| 279 | art_non_debug_cflags := |
| 280 | art_host_non_debug_cflags := |
| 281 | art_target_non_debug_cflags := |
| 282 | art_default_gc_type := |
| 283 | art_default_gc_type_cflags := |
| 284 | |
| 285 | ART_HOST_LDLIBS := |
| 286 | ifneq ($(ART_HOST_CLANG),true) |
| 287 | # GCC lacks libc++ assumed atomic operations, grab via libatomic. |
| 288 | ART_HOST_LDLIBS += -latomic |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 289 | endif |
| 290 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 291 | ART_TARGET_LDFLAGS := |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 292 | |
| 293 | # $(1): ndebug_or_debug |
| 294 | define set-target-local-cflags-vars |
| 295 | LOCAL_CFLAGS += $(ART_TARGET_CFLAGS) |
| 296 | LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86) |
Dehao Chen | 997660d | 2014-07-08 10:00:56 -0700 | [diff] [blame] | 297 | LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS) |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 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 := |
| 313 | endef |
| 314 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 315 | # Support for disabling certain builds. |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 316 | ART_BUILD_TARGET := false |
| 317 | ART_BUILD_HOST := false |
| 318 | ART_BUILD_NDEBUG := false |
| 319 | ART_BUILD_DEBUG := false |
| 320 | ifeq ($(ART_BUILD_TARGET_NDEBUG),true) |
| 321 | ART_BUILD_TARGET := true |
| 322 | ART_BUILD_NDEBUG := true |
| 323 | endif |
| 324 | ifeq ($(ART_BUILD_TARGET_DEBUG),true) |
| 325 | ART_BUILD_TARGET := true |
| 326 | ART_BUILD_DEBUG := true |
| 327 | endif |
| 328 | ifeq ($(ART_BUILD_HOST_NDEBUG),true) |
| 329 | ART_BUILD_HOST := true |
| 330 | ART_BUILD_NDEBUG := true |
| 331 | endif |
| 332 | ifeq ($(ART_BUILD_HOST_DEBUG),true) |
| 333 | ART_BUILD_HOST := true |
| 334 | ART_BUILD_DEBUG := true |
| 335 | endif |
| 336 | |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 337 | endif # ANDROID_COMMON_BUILD_MK |