blob: c29cd299eac6939af44b0bce374f58e4908b988f [file] [log] [blame]
Brian Carlstrom16192862011-09-12 17:50:06 -07001#
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 Carlstrom27ec9612011-09-19 20:20:38 -070017########################################################################
Brian Carlstrom7ab763c2013-12-09 00:38:02 -080018# 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 Carlstrom16192862011-09-12 17:50:06 -070023
Nicolas Geoffray611e1db2014-10-09 17:34:45 +010024include art/build/Android.common_build.mk
Dave Allison70202782013-10-22 17:52:19 -070025
Andreas Gampe4d2ef332015-08-05 09:24:45 -070026LOCAL_DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION :=
Ian Rogersd582fa42014-11-05 23:46:43 -080027ifeq ($(DEX2OAT_HOST_INSTRUCTION_SET_FEATURES),)
Andreas Gampe4d2ef332015-08-05 09:24:45 -070028 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)
Ian Rogersd582fa42014-11-05 23:46:43 -080031endif
Andreas Gampe4d2ef332015-08-05 09:24:45 -070032LOCAL_$(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION :=
Ian Rogersd582fa42014-11-05 23:46:43 -080033ifeq ($($(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES),)
Andreas Gampe4d2ef332015-08-05 09:24:45 -070034 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)
Ian Rogersd582fa42014-11-05 23:46:43 -080037endif
38
Nicolas Geoffray1db132d2014-03-26 10:56:24 +000039# Use dex2oat debug version for better error reporting
Roland Levillain05e34f42018-05-24 13:19:05 +000040# $(1): compiler - optimizing, interpreter or interp-ac (interpreter-access-checks).
Richard Uhlerbb00f812017-02-16 14:21:10 +000041# $(2): 2ND_ or undefined, 2ND_ for 32-bit host builds.
Ian Rogersafd9acc2014-06-17 08:21:54 -070042define create-core-oat-host-rules
Andreas Gampe63fc30e2014-10-24 21:58:16 -070043 core_compile_options :=
44 core_image_name :=
45 core_oat_name :=
46 core_infix :=
Nicolas Geoffraya136ab52014-10-31 10:48:25 +000047 core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070048
49 ifeq ($(1),optimizing)
Nicolas Geoffraya136ab52014-10-31 10:48:25 +000050 core_compile_options += --compiler-backend=Optimizing
Nicolas Geoffrayc13f13a2015-10-06 12:39:17 +010051 core_dex2oat_dependency := $(DEX2OAT)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070052 endif
53 ifeq ($(1),interpreter)
Nicolas Geoffray49cda062017-04-21 13:08:25 +010054 core_compile_options += --compiler-filter=quicken
Andreas Gampe63fc30e2014-10-24 21:58:16 -070055 core_infix := -interpreter
56 endif
Andreas Gampe825570c2015-07-26 10:26:03 -070057 ifeq ($(1),interp-ac)
Nicolas Geoffray49cda062017-04-21 13:08:25 +010058 core_compile_options += --compiler-filter=extract --runtime-arg -Xverify:softfail
Andreas Gampe825570c2015-07-26 10:26:03 -070059 core_infix := -interp-ac
Igor Murashkin7617abd2015-07-10 18:27:47 -070060 endif
Nicolas Geoffrayb76bc782016-09-14 12:33:34 +000061 ifneq ($(filter-out interpreter interp-ac optimizing,$(1)),)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070062 #Technically this test is not precise, but hopefully good enough.
Roland Levillain05e34f42018-05-24 13:19:05 +000063 $$(error found $(1) expected interpreter, interp-ac, or optimizing)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070064 endif
Andreas Gampec23c9c92014-10-28 14:47:25 -070065
Vladimir Marko4519b9d2018-10-10 15:21:21 +010066 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)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070068
69 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
Richard Uhlerbb00f812017-02-16 14:21:10 +000070 ifeq ($(2),)
Vladimir Marko4519b9d2018-10-10 15:21:21 +010071 HOST_CORE_IMAGE_$(1)_64 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070072 else
Vladimir Marko4519b9d2018-10-10 15:21:21 +010073 HOST_CORE_IMAGE_$(1)_32 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070074 endif
Roland Levillain05e34f42018-05-24 13:19:05 +000075 HOST_CORE_IMG_OUTS += $$(core_image_name)
76 HOST_CORE_OAT_OUTS += $$(core_oat_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070077
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)
Vladimir Marko0ace5632018-12-14 11:11:47 +000081$$(core_image_name): $$(HOST_CORE_IMG_DEX_LOCATIONS) $$(core_dex2oat_dependency)
Shinichiro Hamajic5d29052015-12-18 15:51:51 +090082 @echo "host dex2oat: $$@"
Ian Rogersafd9acc2014-06-17 08:21:54 -070083 @mkdir -p $$(dir $$@)
Andreas Gampe206f4a12018-06-19 11:08:32 -070084 $$(hide) ANDROID_LOG_TAGS="*:e" $$(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
Andreas Gampe088b16e2014-12-03 21:59:27 -080085 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
Vladimir Marko0ace5632018-12-14 11:11:47 +000086 $$(addprefix --dex-file=,$$(HOST_CORE_IMG_DEX_FILES)) \
87 $$(addprefix --dex-location=,$$(HOST_CORE_IMG_DEX_LOCATIONS)) \
88 --oat-file=$$(PRIVATE_CORE_OAT_NAME) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -070089 --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \
Richard Uhlerbb00f812017-02-16 14:21:10 +000090 --base=$$(LIBART_IMG_HOST_BASE_ADDRESS) --instruction-set=$$($(2)ART_HOST_ARCH) \
91 $$(LOCAL_$(2)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION) \
Richard Uhler556cba02017-02-28 17:06:29 +000092 --host --android-root=$$(HOST_OUT) \
Vladimir Markoa2da9b92018-10-10 14:21:55 +010093 --generate-debug-info --generate-build-id \
Andreas Gampee8f74ca2018-01-02 09:26:16 -080094 --runtime-arg -XX:SlowDebug=true \
Vladimir Marko4519b9d2018-10-10 15:21:21 +010095 --no-inline-from=core-oj-hostdex.jar \
96 $$(PRIVATE_CORE_COMPILE_OPTIONS)
Brian Carlstrom27ec9612011-09-19 20:20:38 -070097
Andreas Gampe63fc30e2014-10-24 21:58:16 -070098$$(core_oat_name): $$(core_image_name)
Ian Rogersafd9acc2014-06-17 08:21:54 -070099
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700100 # Clean up locally used variables.
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000101 core_dex2oat_dependency :=
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700102 core_compile_options :=
103 core_image_name :=
104 core_oat_name :=
105 core_infix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700106endef # create-core-oat-host-rules
107
Roland Levillain05e34f42018-05-24 13:19:05 +0000108# $(1): compiler - optimizing, interpreter or interp-ac (interpreter-access-checks).
Andreas Gampec23c9c92014-10-28 14:47:25 -0700109define create-core-oat-host-rule-combination
Vladimir Marko4519b9d2018-10-10 15:21:21 +0100110 $(call create-core-oat-host-rules,$(1),)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700111
112 ifneq ($(HOST_PREFER_32_BIT),true)
Vladimir Marko4519b9d2018-10-10 15:21:21 +0100113 $(call create-core-oat-host-rules,$(1),2ND_)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700114 endif
115endef
116
Vladimir Marko4519b9d2018-10-10 15:21:21 +0100117$(eval $(call create-core-oat-host-rule-combination,optimizing))
118$(eval $(call create-core-oat-host-rule-combination,interpreter))
119$(eval $(call create-core-oat-host-rule-combination,interp-ac))
Brian Carlstrom2b7cdf42011-10-13 11:18:28 -0700120
Dan Willemsend60f5a22018-07-24 14:45:33 -0700121.PHONY: test-art-host-dex2oat-host
Jeff Haodcdc85b2015-12-04 14:06:18 -0800122test-art-host-dex2oat-host: $(HOST_CORE_IMG_OUTS)
123
Roland Levillain05e34f42018-05-24 13:19:05 +0000124# $(1): compiler - optimizing, interpreter or interp-ac (interpreter-access-checks).
125# $(2): 2ND_ or undefined
Ian Rogersafd9acc2014-06-17 08:21:54 -0700126define create-core-oat-target-rules
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700127 core_compile_options :=
128 core_image_name :=
129 core_oat_name :=
130 core_infix :=
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000131 core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700132
133 ifeq ($(1),optimizing)
Serban Constantinescu010cf912014-12-04 18:12:21 +0000134 core_compile_options += --compiler-backend=Optimizing
Nicolas Geoffray7701d102015-10-05 09:51:36 +0100135 # With the optimizing compiler, we want to rerun dex2oat whenever there is
136 # a dex2oat change to catch regressions early.
137 core_dex2oat_dependency := $(DEX2OAT)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700138 endif
139 ifeq ($(1),interpreter)
Nicolas Geoffray49cda062017-04-21 13:08:25 +0100140 core_compile_options += --compiler-filter=quicken
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700141 core_infix := -interpreter
142 endif
Andreas Gampe825570c2015-07-26 10:26:03 -0700143 ifeq ($(1),interp-ac)
Nicolas Geoffray49cda062017-04-21 13:08:25 +0100144 core_compile_options += --compiler-filter=extract --runtime-arg -Xverify:softfail
Andreas Gampe825570c2015-07-26 10:26:03 -0700145 core_infix := -interp-ac
Igor Murashkin7617abd2015-07-10 18:27:47 -0700146 endif
Nicolas Geoffrayb76bc782016-09-14 12:33:34 +0000147 ifneq ($(filter-out interpreter interp-ac optimizing,$(1)),)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700148 # Technically this test is not precise, but hopefully good enough.
Roland Levillain05e34f42018-05-24 13:19:05 +0000149 $$(error found $(1) expected interpreter, interp-ac, or optimizing)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700150 endif
Andreas Gampec23c9c92014-10-28 14:47:25 -0700151
Roland Levillain05e34f42018-05-24 13:19:05 +0000152 core_image_name := $($(2)TARGET_CORE_IMG_OUT_BASE)$$(core_infix)$(CORE_IMG_SUFFIX)
153 core_oat_name := $($(2)TARGET_CORE_OAT_OUT_BASE)$$(core_infix)$(CORE_OAT_SUFFIX)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700154
155 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
Richard Uhlerbb00f812017-02-16 14:21:10 +0000156 ifeq ($(2),)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700157 ifdef TARGET_2ND_ARCH
Roland Levillain05e34f42018-05-24 13:19:05 +0000158 TARGET_CORE_IMAGE_$(1)_64 := $$(core_image_name)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700159 else
Roland Levillain05e34f42018-05-24 13:19:05 +0000160 TARGET_CORE_IMAGE_$(1)_32 := $$(core_image_name)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700161 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700162 else
Roland Levillain05e34f42018-05-24 13:19:05 +0000163 TARGET_CORE_IMAGE_$(1)_32 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700164 endif
Roland Levillain05e34f42018-05-24 13:19:05 +0000165 TARGET_CORE_IMG_OUTS += $$(core_image_name)
166 TARGET_CORE_OAT_OUTS += $$(core_oat_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700167
168$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options)
169$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name)
170$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name)
Vladimir Marko0ace5632018-12-14 11:11:47 +0000171$$(core_image_name): $$(TARGET_CORE_IMG_DEX_FILES) $$(core_dex2oat_dependency)
Shinichiro Hamajic5d29052015-12-18 15:51:51 +0900172 @echo "target dex2oat: $$@"
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700173 @mkdir -p $$(dir $$@)
Roland Levillain05e34f42018-05-24 13:19:05 +0000174 $$(hide) $$(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
Andreas Gampe088b16e2014-12-03 21:59:27 -0800175 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
Vladimir Marko0ace5632018-12-14 11:11:47 +0000176 $$(addprefix --dex-file=,$$(TARGET_CORE_IMG_DEX_FILES)) \
177 $$(addprefix --dex-location=,$$(TARGET_CORE_IMG_DEX_LOCATIONS)) \
178 --oat-file=$$(PRIVATE_CORE_OAT_NAME) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700179 --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \
Richard Uhlerbb00f812017-02-16 14:21:10 +0000180 --base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) --instruction-set=$$($(2)TARGET_ARCH) \
181 --instruction-set-variant=$$($(2)DEX2OAT_TARGET_CPU_VARIANT) \
182 --instruction-set-features=$$($(2)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
Richard Uhler556cba02017-02-28 17:06:29 +0000183 --android-root=$$(PRODUCT_OUT)/system \
Vladimir Markoa2da9b92018-10-10 14:21:55 +0100184 --generate-debug-info --generate-build-id \
Andreas Gampee8f74ca2018-01-02 09:26:16 -0800185 --runtime-arg -XX:SlowDebug=true \
Nicolas Geoffray130bd1b2014-11-03 16:23:48 +0000186 $$(PRIVATE_CORE_COMPILE_OPTIONS) || (rm $$(PRIVATE_CORE_OAT_NAME); exit 1)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700187
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700188$$(core_oat_name): $$(core_image_name)
Andreas Gampe2fe07922014-04-21 07:50:39 -0700189
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700190 # Clean up locally used variables.
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000191 core_dex2oat_dependency :=
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700192 core_compile_options :=
193 core_image_name :=
194 core_oat_name :=
195 core_infix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700196endef # create-core-oat-target-rules
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700197
Roland Levillain05e34f42018-05-24 13:19:05 +0000198# $(1): compiler - optimizing, interpreter or interp-ac (interpreter-access-checks).
Andreas Gampec23c9c92014-10-28 14:47:25 -0700199define create-core-oat-target-rule-combination
Roland Levillain05e34f42018-05-24 13:19:05 +0000200 $(call create-core-oat-target-rules,$(1),)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700201
202 ifdef TARGET_2ND_ARCH
Roland Levillain05e34f42018-05-24 13:19:05 +0000203 $(call create-core-oat-target-rules,$(1),2ND_)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700204 endif
205endef
206
Roland Levillain05e34f42018-05-24 13:19:05 +0000207$(eval $(call create-core-oat-target-rule-combination,optimizing))
208$(eval $(call create-core-oat-target-rule-combination,interpreter))
209$(eval $(call create-core-oat-target-rule-combination,interp-ac))
Richard Uhler67e1dc52017-02-06 16:50:17 +0000210
211# Define a default core image that can be used for things like gtests that
212# need some image to run, but don't otherwise care which image is used.
Richard Uhlerbb00f812017-02-16 14:21:10 +0000213HOST_CORE_IMAGE_DEFAULT_32 := $(HOST_CORE_IMAGE_optimizing_32)
214HOST_CORE_IMAGE_DEFAULT_64 := $(HOST_CORE_IMAGE_optimizing_64)
215TARGET_CORE_IMAGE_DEFAULT_32 := $(TARGET_CORE_IMAGE_optimizing_32)
216TARGET_CORE_IMAGE_DEFAULT_64 := $(TARGET_CORE_IMAGE_optimizing_64)