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 24 include art/build/Android.common_build.mk 25 26 LOCAL_DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION := 27 ifeq ($(DEX2OAT_HOST_INSTRUCTION_SET_FEATURES),) 28 LOCAL_DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION := --instruction-set-features=default 29 else 30 LOCAL_DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION := --instruction-set-features=$(DEX2OAT_HOST_INSTRUCTION_SET_FEATURES) 31 endif 32 LOCAL_$(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION := 33 ifeq ($($(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 35 else 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) 37 endif 38 39 # Use dex2oat debug version for better error reporting 40 # $(1): compiler - optimizing, interpreter or interp-ac (interpreter-access-checks). 41 # $(2): 2ND_ or undefined, 2ND_ for 32-bit host builds. 42 define create-core-oat-host-rules 43 core_compile_options := 44 core_image_name := 45 core_oat_name := 46 core_infix := 47 core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY) 48 49 ifeq ($(1),optimizing) 50 core_compile_options += --compiler-backend=Optimizing 51 core_dex2oat_dependency := $(DEX2OAT) 52 endif 53 ifeq ($(1),interpreter) 54 core_compile_options += --compiler-filter=quicken 55 core_infix := -interpreter 56 endif 57 ifeq ($(1),interp-ac) 58 core_compile_options += --compiler-filter=extract --runtime-arg -Xverify:softfail 59 core_infix := -interp-ac 60 endif 61 ifneq ($(filter-out interpreter interp-ac optimizing,$(1)),) 62 #Technically this test is not precise, but hopefully good enough. 63 $$(error found $(1) expected interpreter, interp-ac, or optimizing) 64 endif 65 66 core_image_name := $($(2)HOST_CORE_IMG_OUT_BASE)$$(core_infix)$(CORE_IMG_SUFFIX) 67 core_oat_name := $($(2)HOST_CORE_OAT_OUT_BASE)$$(core_infix)$(CORE_OAT_SUFFIX) 68 69 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk. 70 ifeq ($(2),) 71 HOST_CORE_IMAGE_$(1)_64 := $$(core_image_name) 72 else 73 HOST_CORE_IMAGE_$(1)_32 := $$(core_image_name) 74 endif 75 HOST_CORE_IMG_OUTS += $$(core_image_name) 76 HOST_CORE_OAT_OUTS += $$(core_oat_name) 77 78 $$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options) 79 $$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name) 80 $$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name) 81 $$(core_image_name): $$(HOST_CORE_IMG_DEX_LOCATIONS) $$(core_dex2oat_dependency) 82 @echo "host dex2oat: $$@" 83 @mkdir -p $$(dir $$@) 84 $$(hide) ANDROID_LOG_TAGS="*:e" $$(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \ 85 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \ 86 --image-classes=$$(PRELOADED_CLASSES) \ 87 $$(addprefix --dex-file=,$$(HOST_CORE_IMG_DEX_FILES)) \ 88 $$(addprefix --dex-location=,$$(HOST_CORE_IMG_DEX_LOCATIONS)) \ 89 --oat-file=$$(PRIVATE_CORE_OAT_NAME) \ 90 --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \ 91 --base=$$(LIBART_IMG_HOST_BASE_ADDRESS) --instruction-set=$$($(2)ART_HOST_ARCH) \ 92 $$(LOCAL_$(2)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION) \ 93 --host --android-root=$$(HOST_OUT) \ 94 --generate-debug-info --generate-build-id \ 95 --runtime-arg -XX:SlowDebug=true \ 96 --no-inline-from=core-oj-hostdex.jar \ 97 $$(PRIVATE_CORE_COMPILE_OPTIONS) 98 99 $$(core_oat_name): $$(core_image_name) 100 101 # Clean up locally used variables. 102 core_dex2oat_dependency := 103 core_compile_options := 104 core_image_name := 105 core_oat_name := 106 core_infix := 107 endef # create-core-oat-host-rules 108 109 # $(1): compiler - optimizing, interpreter or interp-ac (interpreter-access-checks). 110 define create-core-oat-host-rule-combination 111 $(call create-core-oat-host-rules,$(1),) 112 113 ifneq ($(HOST_PREFER_32_BIT),true) 114 $(call create-core-oat-host-rules,$(1),2ND_) 115 endif 116 endef 117 118 $(eval $(call create-core-oat-host-rule-combination,optimizing)) 119 $(eval $(call create-core-oat-host-rule-combination,interpreter)) 120 $(eval $(call create-core-oat-host-rule-combination,interp-ac)) 121 122 .PHONY: test-art-host-dex2oat-host 123 test-art-host-dex2oat-host: $(HOST_CORE_IMG_OUTS) 124 125 # $(1): compiler - optimizing, interpreter or interp-ac (interpreter-access-checks). 126 # $(2): 2ND_ or undefined 127 define create-core-oat-target-rules 128 core_compile_options := 129 core_image_name := 130 core_oat_name := 131 core_infix := 132 core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY) 133 134 ifeq ($(1),optimizing) 135 core_compile_options += --compiler-backend=Optimizing 136 # With the optimizing compiler, we want to rerun dex2oat whenever there is 137 # a dex2oat change to catch regressions early. 138 core_dex2oat_dependency := $(DEX2OAT) 139 endif 140 ifeq ($(1),interpreter) 141 core_compile_options += --compiler-filter=quicken 142 core_infix := -interpreter 143 endif 144 ifeq ($(1),interp-ac) 145 core_compile_options += --compiler-filter=extract --runtime-arg -Xverify:softfail 146 core_infix := -interp-ac 147 endif 148 ifneq ($(filter-out interpreter interp-ac optimizing,$(1)),) 149 # Technically this test is not precise, but hopefully good enough. 150 $$(error found $(1) expected interpreter, interp-ac, or optimizing) 151 endif 152 153 core_image_name := $($(2)TARGET_CORE_IMG_OUT_BASE)$$(core_infix)$(CORE_IMG_SUFFIX) 154 core_oat_name := $($(2)TARGET_CORE_OAT_OUT_BASE)$$(core_infix)$(CORE_OAT_SUFFIX) 155 156 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk. 157 ifeq ($(2),) 158 ifdef TARGET_2ND_ARCH 159 TARGET_CORE_IMAGE_$(1)_64 := $$(core_image_name) 160 else 161 TARGET_CORE_IMAGE_$(1)_32 := $$(core_image_name) 162 endif 163 else 164 TARGET_CORE_IMAGE_$(1)_32 := $$(core_image_name) 165 endif 166 TARGET_CORE_IMG_OUTS += $$(core_image_name) 167 TARGET_CORE_OAT_OUTS += $$(core_oat_name) 168 169 $$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options) 170 $$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name) 171 $$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name) 172 $$(core_image_name): $$(TARGET_CORE_IMG_DEX_FILES) $$(core_dex2oat_dependency) 173 @echo "target dex2oat: $$@" 174 @mkdir -p $$(dir $$@) 175 $$(hide) $$(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \ 176 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \ 177 --image-classes=$$(PRELOADED_CLASSES) \ 178 $$(addprefix --dex-file=,$$(TARGET_CORE_IMG_DEX_FILES)) \ 179 $$(addprefix --dex-location=,$$(TARGET_CORE_IMG_DEX_LOCATIONS)) \ 180 --oat-file=$$(PRIVATE_CORE_OAT_NAME) \ 181 --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \ 182 --base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) --instruction-set=$$($(2)TARGET_ARCH) \ 183 --instruction-set-variant=$$($(2)DEX2OAT_TARGET_CPU_VARIANT) \ 184 --instruction-set-features=$$($(2)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \ 185 --android-root=$$(PRODUCT_OUT)/system \ 186 --generate-debug-info --generate-build-id \ 187 --runtime-arg -XX:SlowDebug=true \ 188 $$(PRIVATE_CORE_COMPILE_OPTIONS) || (rm $$(PRIVATE_CORE_OAT_NAME); exit 1) 189 190 $$(core_oat_name): $$(core_image_name) 191 192 # Clean up locally used variables. 193 core_dex2oat_dependency := 194 core_compile_options := 195 core_image_name := 196 core_oat_name := 197 core_infix := 198 endef # create-core-oat-target-rules 199 200 # $(1): compiler - optimizing, interpreter or interp-ac (interpreter-access-checks). 201 define create-core-oat-target-rule-combination 202 $(call create-core-oat-target-rules,$(1),) 203 204 ifdef TARGET_2ND_ARCH 205 $(call create-core-oat-target-rules,$(1),2ND_) 206 endif 207 endef 208 209 $(eval $(call create-core-oat-target-rule-combination,optimizing)) 210 $(eval $(call create-core-oat-target-rule-combination,interpreter)) 211 $(eval $(call create-core-oat-target-rule-combination,interp-ac)) 212 213 # Define a default core image that can be used for things like gtests that 214 # need some image to run, but don't otherwise care which image is used. 215 HOST_CORE_IMAGE_DEFAULT_32 := $(HOST_CORE_IMAGE_optimizing_32) 216 HOST_CORE_IMAGE_DEFAULT_64 := $(HOST_CORE_IMAGE_optimizing_64) 217 TARGET_CORE_IMAGE_DEFAULT_32 := $(TARGET_CORE_IMAGE_optimizing_32) 218 TARGET_CORE_IMAGE_DEFAULT_64 := $(TARGET_CORE_IMAGE_optimizing_64) 219