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######################################################################## 18# Rules to build a smaller "core" image to support core libraries 19# (that is, non-Android frameworks) testing on the host and target 20# 21# The main rules to build the default "boot" image are in 22# build/core/dex_preopt_libart.mk 23 24include art/build/Android.common_build.mk 25 26LOCAL_DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION := 27ifeq ($(DEX2OAT_HOST_INSTRUCTION_SET_FEATURES),) 28 LOCAL_DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION := --instruction-set-features=default 29else 30 LOCAL_DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION := --instruction-set-features=$(DEX2OAT_HOST_INSTRUCTION_SET_FEATURES) 31endif 32LOCAL_$(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION := 33ifeq ($($(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES),) 34 LOCAL_$(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION := --instruction-set-features=default 35else 36 LOCAL_$(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION := --instruction-set-features=$($(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES) 37endif 38 39# Use dex2oat debug version for better error reporting 40# $(1): compiler - optimizing, interpreter or interpreter-access-checks. 41# $(2): 2ND_ or undefined, 2ND_ for 32-bit host builds. 42# $(3): wrapper, e.g., valgrind. 43# $(4): dex2oat suffix, e.g, valgrind requires 32 right now. 44# $(5): multi-image. 45# NB depending on HOST_CORE_DEX_LOCATIONS so we are sure to have the dex files in frameworks for 46# run-test --no-image 47define create-core-oat-host-rules 48 core_compile_options := 49 core_image_name := 50 core_oat_name := 51 core_infix := 52 core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY) 53 54 ifeq ($(1),optimizing) 55 core_compile_options += --compiler-backend=Optimizing 56 core_dex2oat_dependency := $(DEX2OAT) 57 endif 58 ifeq ($(1),interpreter) 59 core_compile_options += --compiler-filter=quicken 60 core_infix := -interpreter 61 endif 62 ifeq ($(1),interp-ac) 63 core_compile_options += --compiler-filter=extract --runtime-arg -Xverify:softfail 64 core_infix := -interp-ac 65 endif 66 ifneq ($(filter-out interpreter interp-ac optimizing,$(1)),) 67 #Technically this test is not precise, but hopefully good enough. 68 $$(error found $(1) expected interpreter, interpreter-access-checks, or optimizing) 69 endif 70 71 # If $(5) is true, generate a multi-image. 72 ifeq ($(5),true) 73 core_multi_infix := -multi 74 core_multi_param := --multi-image --no-inline-from=core-oj-hostdex.jar 75 core_multi_group := _multi 76 else 77 core_multi_infix := 78 core_multi_param := 79 core_multi_group := 80 endif 81 82 core_image_name := $($(2)HOST_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_multi_infix)$(3)$(CORE_IMG_SUFFIX) 83 core_oat_name := $($(2)HOST_CORE_OAT_OUT_BASE)$$(core_infix)$$(core_multi_infix)$(3)$(CORE_OAT_SUFFIX) 84 85 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk. 86 ifeq ($(2),) 87 $(3)HOST_CORE_IMAGE_$(1)$$(core_multi_group)_64 := $$(core_image_name) 88 else 89 $(3)HOST_CORE_IMAGE_$(1)$$(core_multi_group)_32 := $$(core_image_name) 90 endif 91 $(3)HOST_CORE_IMG_OUTS += $$(core_image_name) 92 $(3)HOST_CORE_OAT_OUTS += $$(core_oat_name) 93 94 # If we have a wrapper, make the target phony. 95 ifneq ($(3),) 96.PHONY: $$(core_image_name) 97 endif 98$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options) 99$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name) 100$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name) 101$$(core_image_name): PRIVATE_CORE_MULTI_PARAM := $$(core_multi_param) 102$$(core_image_name): $$(HOST_CORE_DEX_LOCATIONS) $$(core_dex2oat_dependency) 103 @echo "host dex2oat: $$@" 104 @mkdir -p $$(dir $$@) 105 $$(hide) $(3) $$(DEX2OAT)$(4) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \ 106 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \ 107 --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(HOST_CORE_DEX_FILES)) \ 108 $$(addprefix --dex-location=,$$(HOST_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \ 109 --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \ 110 --base=$$(LIBART_IMG_HOST_BASE_ADDRESS) --instruction-set=$$($(2)ART_HOST_ARCH) \ 111 $$(LOCAL_$(2)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION) \ 112 --host --android-root=$$(HOST_OUT) \ 113 --generate-debug-info --generate-build-id --compile-pic \ 114 $$(PRIVATE_CORE_MULTI_PARAM) $$(PRIVATE_CORE_COMPILE_OPTIONS) 115 116$$(core_oat_name): $$(core_image_name) 117 118 # Clean up locally used variables. 119 core_dex2oat_dependency := 120 core_compile_options := 121 core_image_name := 122 core_oat_name := 123 core_infix := 124endef # create-core-oat-host-rules 125 126# $(1): compiler - optimizing, interpreter or interpreter-access-checks. 127# $(2): wrapper. 128# $(3): dex2oat suffix. 129# $(4): multi-image. 130define create-core-oat-host-rule-combination 131 $(call create-core-oat-host-rules,$(1),,$(2),$(3),$(4)) 132 133 ifneq ($(HOST_PREFER_32_BIT),true) 134 $(call create-core-oat-host-rules,$(1),2ND_,$(2),$(3),$(4)) 135 endif 136endef 137 138$(eval $(call create-core-oat-host-rule-combination,optimizing,,,false)) 139$(eval $(call create-core-oat-host-rule-combination,interpreter,,,false)) 140$(eval $(call create-core-oat-host-rule-combination,interp-ac,,,false)) 141$(eval $(call create-core-oat-host-rule-combination,optimizing,,,true)) 142$(eval $(call create-core-oat-host-rule-combination,interpreter,,,true)) 143$(eval $(call create-core-oat-host-rule-combination,interp-ac,,,true)) 144 145valgrindHOST_CORE_IMG_OUTS := 146valgrindHOST_CORE_OAT_OUTS := 147$(eval $(call create-core-oat-host-rule-combination,optimizing,valgrind,32,false)) 148$(eval $(call create-core-oat-host-rule-combination,interpreter,valgrind,32,false)) 149$(eval $(call create-core-oat-host-rule-combination,interp-ac,valgrind,32,false)) 150 151valgrind-test-art-host-dex2oat-host: $(valgrindHOST_CORE_IMG_OUTS) 152 153test-art-host-dex2oat-host: $(HOST_CORE_IMG_OUTS) 154 155define create-core-oat-target-rules 156 core_compile_options := 157 core_image_name := 158 core_oat_name := 159 core_infix := 160 core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY) 161 162 ifeq ($(1),optimizing) 163 core_compile_options += --compiler-backend=Optimizing 164 # With the optimizing compiler, we want to rerun dex2oat whenever there is 165 # a dex2oat change to catch regressions early. 166 core_dex2oat_dependency := $(DEX2OAT) 167 endif 168 ifeq ($(1),interpreter) 169 core_compile_options += --compiler-filter=quicken 170 core_infix := -interpreter 171 endif 172 ifeq ($(1),interp-ac) 173 core_compile_options += --compiler-filter=extract --runtime-arg -Xverify:softfail 174 core_infix := -interp-ac 175 endif 176 ifneq ($(filter-out interpreter interp-ac optimizing,$(1)),) 177 # Technically this test is not precise, but hopefully good enough. 178 $$(error found $(1) expected interpreter, interpreter-access-checks, or optimizing) 179 endif 180 181 core_image_name := $($(2)TARGET_CORE_IMG_OUT_BASE)$$(core_infix)$(3)$(CORE_IMG_SUFFIX) 182 core_oat_name := $($(2)TARGET_CORE_OAT_OUT_BASE)$$(core_infix)$(3)$(CORE_OAT_SUFFIX) 183 184 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk. 185 ifeq ($(2),) 186 ifdef TARGET_2ND_ARCH 187 $(3)TARGET_CORE_IMAGE_$(1)_64 := $$(core_image_name) 188 else 189 $(3)TARGET_CORE_IMAGE_$(1)_32 := $$(core_image_name) 190 endif 191 else 192 $(3)TARGET_CORE_IMAGE_$(1)_32 := $$(core_image_name) 193 endif 194 $(3)TARGET_CORE_IMG_OUTS += $$(core_image_name) 195 $(3)TARGET_CORE_OAT_OUTS += $$(core_oat_name) 196 197 # If we have a wrapper, make the target phony. 198 ifneq ($(3),) 199.PHONY: $$(core_image_name) 200 endif 201$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options) 202$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name) 203$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name) 204$$(core_image_name): $$(TARGET_CORE_DEX_FILES) $$(core_dex2oat_dependency) 205 @echo "target dex2oat: $$@" 206 @mkdir -p $$(dir $$@) 207 $$(hide) $(4) $$(DEX2OAT)$(5) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \ 208 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \ 209 --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(TARGET_CORE_DEX_FILES)) \ 210 $$(addprefix --dex-location=,$$(TARGET_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \ 211 --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \ 212 --base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) --instruction-set=$$($(2)TARGET_ARCH) \ 213 --instruction-set-variant=$$($(2)DEX2OAT_TARGET_CPU_VARIANT) \ 214 --instruction-set-features=$$($(2)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \ 215 --android-root=$$(PRODUCT_OUT)/system \ 216 --generate-debug-info --generate-build-id --compile-pic \ 217 $$(PRIVATE_CORE_COMPILE_OPTIONS) || (rm $$(PRIVATE_CORE_OAT_NAME); exit 1) 218 219$$(core_oat_name): $$(core_image_name) 220 221 # Clean up locally used variables. 222 core_dex2oat_dependency := 223 core_compile_options := 224 core_image_name := 225 core_oat_name := 226 core_infix := 227endef # create-core-oat-target-rules 228 229# $(1): compiler - optimizing, interpreter or interpreter-access-checks. 230# $(2): wrapper. 231# $(3): dex2oat suffix. 232define create-core-oat-target-rule-combination 233 $(call create-core-oat-target-rules,$(1),,$(2),$(3)) 234 235 ifdef TARGET_2ND_ARCH 236 $(call create-core-oat-target-rules,$(1),2ND_,$(2),$(3)) 237 endif 238endef 239 240$(eval $(call create-core-oat-target-rule-combination,optimizing,,)) 241$(eval $(call create-core-oat-target-rule-combination,interpreter,,)) 242$(eval $(call create-core-oat-target-rule-combination,interp-ac,,)) 243 244valgrindTARGET_CORE_IMG_OUTS := 245valgrindTARGET_CORE_OAT_OUTS := 246$(eval $(call create-core-oat-target-rule-combination,optimizing,valgrind,32)) 247$(eval $(call create-core-oat-target-rule-combination,interpreter,valgrind,32)) 248$(eval $(call create-core-oat-target-rule-combination,interp-ac,valgrind,32)) 249 250valgrind-test-art-host-dex2oat-target: $(valgrindTARGET_CORE_IMG_OUTS) 251 252valgrind-test-art-host-dex2oat: valgrind-test-art-host-dex2oat-host valgrind-test-art-host-dex2oat-target 253 254# Define a default core image that can be used for things like gtests that 255# need some image to run, but don't otherwise care which image is used. 256HOST_CORE_IMAGE_DEFAULT_32 := $(HOST_CORE_IMAGE_optimizing_32) 257HOST_CORE_IMAGE_DEFAULT_64 := $(HOST_CORE_IMAGE_optimizing_64) 258TARGET_CORE_IMAGE_DEFAULT_32 := $(TARGET_CORE_IMAGE_optimizing_32) 259TARGET_CORE_IMAGE_DEFAULT_64 := $(TARGET_CORE_IMAGE_optimizing_64) 260