Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -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 | |
Brian Carlstrom | 27ec961 | 2011-09-19 20:20:38 -0700 | [diff] [blame] | 17 | ######################################################################## |
Brian Carlstrom | 7ab763c | 2013-12-09 00:38:02 -0800 | [diff] [blame] | 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 |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 23 | |
Nicolas Geoffray | 611e1db | 2014-10-09 17:34:45 +0100 | [diff] [blame] | 24 | include art/build/Android.common_build.mk |
Dave Allison | 7020278 | 2013-10-22 17:52:19 -0700 | [diff] [blame] | 25 | |
Ian Rogers | d582fa4 | 2014-11-05 23:46:43 -0800 | [diff] [blame] | 26 | ifeq ($(DEX2OAT_HOST_INSTRUCTION_SET_FEATURES),) |
| 27 | DEX2OAT_HOST_INSTRUCTION_SET_FEATURES := default |
| 28 | endif |
| 29 | ifeq ($($(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES),) |
| 30 | $(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES := default |
| 31 | endif |
| 32 | |
Nicolas Geoffray | 1db132d | 2014-03-26 10:56:24 +0000 | [diff] [blame] | 33 | # Use dex2oat debug version for better error reporting |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 34 | # $(1): compiler - default, optimizing or interpreter. |
| 35 | # $(2): pic/no-pic |
| 36 | # $(3): 2ND_ or undefined, 2ND_ for 32-bit host builds. |
Alex Light | 1ef4ce8 | 2014-08-27 11:13:47 -0700 | [diff] [blame] | 37 | # NB depending on HOST_CORE_DEX_LOCATIONS so we are sure to have the dex files in frameworks for |
| 38 | # run-test --no-image |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 39 | define create-core-oat-host-rules |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 40 | core_compile_options := |
| 41 | core_image_name := |
| 42 | core_oat_name := |
| 43 | core_infix := |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 44 | core_pic_infix := |
Nicolas Geoffray | a136ab5 | 2014-10-31 10:48:25 +0000 | [diff] [blame] | 45 | core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY) |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 46 | |
Nicolas Geoffray | 5d672a6 | 2014-12-04 14:39:31 +0000 | [diff] [blame^] | 47 | # With the optimizing compiler, we want to rerun dex2oat whenever there is |
| 48 | # a dex2oat change to catch regressions early. |
| 49 | ifeq ($(ART_USE_OPTIMIZING_COMPILER), true) |
| 50 | core_dex2oat_dependency := $(DEX2OAT) |
Nicolas Geoffray | c9338b9 | 2014-12-03 13:36:10 +0000 | [diff] [blame] | 51 | endif |
Nicolas Geoffray | 5d672a6 | 2014-12-04 14:39:31 +0000 | [diff] [blame^] | 52 | |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 53 | ifeq ($(1),optimizing) |
Nicolas Geoffray | a136ab5 | 2014-10-31 10:48:25 +0000 | [diff] [blame] | 54 | core_compile_options += --compiler-backend=Optimizing |
Nicolas Geoffray | a136ab5 | 2014-10-31 10:48:25 +0000 | [diff] [blame] | 55 | core_dex2oat_dependency := $(DEX2OAT) |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 56 | core_infix := -optimizing |
| 57 | endif |
| 58 | ifeq ($(1),interpreter) |
| 59 | core_compile_options += --compiler-filter=interpret-only |
| 60 | core_infix := -interpreter |
| 61 | endif |
| 62 | ifeq ($(1),default) |
| 63 | # Default has no infix, no compile options. |
| 64 | endif |
| 65 | ifneq ($(filter-out default interpreter optimizing,$(1)),) |
| 66 | #Technically this test is not precise, but hopefully good enough. |
| 67 | $$(error found $(1) expected default, interpreter or optimizing) |
| 68 | endif |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 69 | |
| 70 | ifeq ($(2),pic) |
| 71 | core_compile_options += --compile-pic |
| 72 | core_pic_infix := -pic |
| 73 | endif |
| 74 | ifeq ($(2),no-pic) |
| 75 | # No change for non-pic |
| 76 | endif |
| 77 | ifneq ($(filter-out pic no-pic,$(2)),) |
| 78 | # Technically this test is not precise, but hopefully good enough. |
| 79 | $$(error found $(2) expected pic or no-pic) |
| 80 | endif |
| 81 | |
| 82 | core_image_name := $($(3)HOST_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(CORE_IMG_SUFFIX) |
| 83 | core_oat_name := $($(3)HOST_CORE_OAT_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(CORE_OAT_SUFFIX) |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 84 | |
| 85 | # Using the bitness suffix makes it easier to add as a dependency for the run-test mk. |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 86 | ifeq ($(3),) |
| 87 | HOST_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name) |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 88 | else |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 89 | HOST_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name) |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 90 | endif |
| 91 | HOST_CORE_IMG_OUTS += $$(core_image_name) |
| 92 | HOST_CORE_OAT_OUTS += $$(core_oat_name) |
| 93 | |
| 94 | $$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options) |
| 95 | $$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name) |
| 96 | $$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name) |
Nicolas Geoffray | a136ab5 | 2014-10-31 10:48:25 +0000 | [diff] [blame] | 97 | $$(core_image_name): $$(HOST_CORE_DEX_LOCATIONS) $$(core_dex2oat_dependency) |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 98 | @echo "host dex2oat: $$@ ($$?)" |
| 99 | @mkdir -p $$(dir $$@) |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 100 | $$(hide) $$(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \ |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 101 | --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(HOST_CORE_DEX_FILES)) \ |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 102 | $$(addprefix --dex-location=,$$(HOST_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \ |
| 103 | --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \ |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 104 | --base=$$(LIBART_IMG_HOST_BASE_ADDRESS) --instruction-set=$$($(3)ART_HOST_ARCH) \ |
Ian Rogers | d582fa4 | 2014-11-05 23:46:43 -0800 | [diff] [blame] | 105 | --instruction-set-features=$$($(3)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES) \ |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 106 | --host --android-root=$$(HOST_OUT) --include-patch-information \ |
| 107 | $$(PRIVATE_CORE_COMPILE_OPTIONS) |
Brian Carlstrom | 27ec961 | 2011-09-19 20:20:38 -0700 | [diff] [blame] | 108 | |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 109 | $$(core_oat_name): $$(core_image_name) |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 110 | |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 111 | # Clean up locally used variables. |
Nicolas Geoffray | a136ab5 | 2014-10-31 10:48:25 +0000 | [diff] [blame] | 112 | core_dex2oat_dependency := |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 113 | core_compile_options := |
| 114 | core_image_name := |
| 115 | core_oat_name := |
| 116 | core_infix := |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 117 | core_pic_infix := |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 118 | endef # create-core-oat-host-rules |
| 119 | |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 120 | # $(1): compiler - default, optimizing or interpreter. |
| 121 | define create-core-oat-host-rule-combination |
| 122 | $(call create-core-oat-host-rules,$(1),no-pic,) |
| 123 | $(call create-core-oat-host-rules,$(1),pic,) |
| 124 | |
| 125 | ifneq ($(HOST_PREFER_32_BIT),true) |
| 126 | $(call create-core-oat-host-rules,$(1),no-pic,2ND_) |
| 127 | $(call create-core-oat-host-rules,$(1),pic,2ND_) |
| 128 | endif |
| 129 | endef |
| 130 | |
| 131 | $(eval $(call create-core-oat-host-rule-combination,default)) |
| 132 | $(eval $(call create-core-oat-host-rule-combination,optimizing)) |
| 133 | $(eval $(call create-core-oat-host-rule-combination,interpreter)) |
| 134 | |
Brian Carlstrom | 2b7cdf4 | 2011-10-13 11:18:28 -0700 | [diff] [blame] | 135 | |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 136 | define create-core-oat-target-rules |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 137 | core_compile_options := |
| 138 | core_image_name := |
| 139 | core_oat_name := |
| 140 | core_infix := |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 141 | core_pic_infix := |
Nicolas Geoffray | a136ab5 | 2014-10-31 10:48:25 +0000 | [diff] [blame] | 142 | core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY) |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 143 | |
Nicolas Geoffray | 5d672a6 | 2014-12-04 14:39:31 +0000 | [diff] [blame^] | 144 | # With the optimizing compiler, we want to rerun dex2oat whenever there is |
| 145 | # a dex2oat change to catch regressions early. |
| 146 | ifeq ($(ART_USE_OPTIMIZING_COMPILER), true) |
| 147 | core_dex2oat_dependency := $(DEX2OAT) |
Nicolas Geoffray | c9338b9 | 2014-12-03 13:36:10 +0000 | [diff] [blame] | 148 | endif |
Nicolas Geoffray | 5d672a6 | 2014-12-04 14:39:31 +0000 | [diff] [blame^] | 149 | |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 150 | ifeq ($(1),optimizing) |
Nicolas Geoffray | 08d5e28 | 2014-11-03 14:39:21 +0000 | [diff] [blame] | 151 | ifeq ($($(3)TARGET_ARCH),arm64) |
Nicolas Geoffray | a136ab5 | 2014-10-31 10:48:25 +0000 | [diff] [blame] | 152 | # TODO: Enable image generation on arm64 once the backend |
| 153 | # is on par with other architectures. |
| 154 | core_compile_options += --compiler-backend=Quick |
| 155 | else |
| 156 | core_compile_options += --compiler-backend=Optimizing |
Nicolas Geoffray | a136ab5 | 2014-10-31 10:48:25 +0000 | [diff] [blame] | 157 | core_dex2oat_dependency := $(DEX2OAT) |
| 158 | endif |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 159 | core_infix := -optimizing |
| 160 | endif |
| 161 | ifeq ($(1),interpreter) |
| 162 | core_compile_options += --compiler-filter=interpret-only |
| 163 | core_infix := -interpreter |
| 164 | endif |
| 165 | ifeq ($(1),default) |
| 166 | # Default has no infix, no compile options. |
| 167 | endif |
| 168 | ifneq ($(filter-out default interpreter optimizing,$(1)),) |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 169 | # Technically this test is not precise, but hopefully good enough. |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 170 | $$(error found $(1) expected default, interpreter or optimizing) |
| 171 | endif |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 172 | |
| 173 | ifeq ($(2),pic) |
| 174 | core_compile_options += --compile-pic |
| 175 | core_pic_infix := -pic |
| 176 | endif |
| 177 | ifeq ($(2),no-pic) |
| 178 | # No change for non-pic |
| 179 | endif |
| 180 | ifneq ($(filter-out pic no-pic,$(2)),) |
| 181 | #Technically this test is not precise, but hopefully good enough. |
| 182 | $$(error found $(2) expected pic or no-pic) |
| 183 | endif |
| 184 | |
| 185 | core_image_name := $($(3)TARGET_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(CORE_IMG_SUFFIX) |
| 186 | core_oat_name := $($(3)TARGET_CORE_OAT_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(CORE_OAT_SUFFIX) |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 187 | |
| 188 | # Using the bitness suffix makes it easier to add as a dependency for the run-test mk. |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 189 | ifeq ($(3),) |
| 190 | ifdef TARGET_2ND_ARCH |
| 191 | TARGET_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name) |
| 192 | else |
| 193 | TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name) |
| 194 | endif |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 195 | else |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 196 | TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name) |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 197 | endif |
| 198 | TARGET_CORE_IMG_OUTS += $$(core_image_name) |
| 199 | TARGET_CORE_OAT_OUTS += $$(core_oat_name) |
| 200 | |
| 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) |
Nicolas Geoffray | a136ab5 | 2014-10-31 10:48:25 +0000 | [diff] [blame] | 204 | $$(core_image_name): $$(TARGET_CORE_DEX_FILES) $$(core_dex2oat_dependency) |
Andreas Gampe | afbaa1a | 2014-03-25 18:09:32 -0700 | [diff] [blame] | 205 | @echo "target dex2oat: $$@ ($$?)" |
| 206 | @mkdir -p $$(dir $$@) |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 207 | $$(hide) $$(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \ |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 208 | --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(TARGET_CORE_DEX_FILES)) \ |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 209 | $$(addprefix --dex-location=,$$(TARGET_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \ |
| 210 | --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \ |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 211 | --base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) --instruction-set=$$($(3)TARGET_ARCH) \ |
Ian Rogers | d582fa4 | 2014-11-05 23:46:43 -0800 | [diff] [blame] | 212 | --instruction-set-features=$$($(3)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \ |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 213 | --android-root=$$(PRODUCT_OUT)/system --include-patch-information \ |
Nicolas Geoffray | 130bd1b | 2014-11-03 16:23:48 +0000 | [diff] [blame] | 214 | $$(PRIVATE_CORE_COMPILE_OPTIONS) || (rm $$(PRIVATE_CORE_OAT_NAME); exit 1) |
Andreas Gampe | afbaa1a | 2014-03-25 18:09:32 -0700 | [diff] [blame] | 215 | |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 216 | $$(core_oat_name): $$(core_image_name) |
Andreas Gampe | 2fe0792 | 2014-04-21 07:50:39 -0700 | [diff] [blame] | 217 | |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 218 | # Clean up locally used variables. |
Nicolas Geoffray | a136ab5 | 2014-10-31 10:48:25 +0000 | [diff] [blame] | 219 | core_dex2oat_dependency := |
Andreas Gampe | 63fc30e | 2014-10-24 21:58:16 -0700 | [diff] [blame] | 220 | core_compile_options := |
| 221 | core_image_name := |
| 222 | core_oat_name := |
| 223 | core_infix := |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 224 | core_pic_infix := |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 225 | endef # create-core-oat-target-rules |
Andreas Gampe | afbaa1a | 2014-03-25 18:09:32 -0700 | [diff] [blame] | 226 | |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 227 | # $(1): compiler - default, optimizing or interpreter. |
| 228 | define create-core-oat-target-rule-combination |
| 229 | $(call create-core-oat-target-rules,$(1),no-pic,) |
| 230 | $(call create-core-oat-target-rules,$(1),pic,) |
| 231 | |
| 232 | ifdef TARGET_2ND_ARCH |
| 233 | $(call create-core-oat-target-rules,$(1),no-pic,2ND_) |
| 234 | $(call create-core-oat-target-rules,$(1),pic,2ND_) |
| 235 | endif |
| 236 | endef |
| 237 | |
| 238 | $(eval $(call create-core-oat-target-rule-combination,default)) |
| 239 | $(eval $(call create-core-oat-target-rule-combination,optimizing)) |
| 240 | $(eval $(call create-core-oat-target-rule-combination,interpreter)) |