blob: 2824a099b270e289235eed02557b3bdbf38abb89 [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.
Roland Levillain05e34f42018-05-24 13:19:05 +000042# $(3): multi-image.
Alex Light1ef4ce82014-08-27 11:13:47 -070043# NB depending on HOST_CORE_DEX_LOCATIONS so we are sure to have the dex files in frameworks for
44# run-test --no-image
Ian Rogersafd9acc2014-06-17 08:21:54 -070045define create-core-oat-host-rules
Andreas Gampe63fc30e2014-10-24 21:58:16 -070046 core_compile_options :=
47 core_image_name :=
48 core_oat_name :=
49 core_infix :=
Nicolas Geoffraya136ab52014-10-31 10:48:25 +000050 core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070051
52 ifeq ($(1),optimizing)
Nicolas Geoffraya136ab52014-10-31 10:48:25 +000053 core_compile_options += --compiler-backend=Optimizing
Nicolas Geoffrayc13f13a2015-10-06 12:39:17 +010054 core_dex2oat_dependency := $(DEX2OAT)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070055 endif
56 ifeq ($(1),interpreter)
Nicolas Geoffray49cda062017-04-21 13:08:25 +010057 core_compile_options += --compiler-filter=quicken
Andreas Gampe63fc30e2014-10-24 21:58:16 -070058 core_infix := -interpreter
59 endif
Andreas Gampe825570c2015-07-26 10:26:03 -070060 ifeq ($(1),interp-ac)
Nicolas Geoffray49cda062017-04-21 13:08:25 +010061 core_compile_options += --compiler-filter=extract --runtime-arg -Xverify:softfail
Andreas Gampe825570c2015-07-26 10:26:03 -070062 core_infix := -interp-ac
Igor Murashkin7617abd2015-07-10 18:27:47 -070063 endif
Nicolas Geoffrayb76bc782016-09-14 12:33:34 +000064 ifneq ($(filter-out interpreter interp-ac optimizing,$(1)),)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070065 #Technically this test is not precise, but hopefully good enough.
Roland Levillain05e34f42018-05-24 13:19:05 +000066 $$(error found $(1) expected interpreter, interp-ac, or optimizing)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070067 endif
Andreas Gampec23c9c92014-10-28 14:47:25 -070068
Roland Levillain05e34f42018-05-24 13:19:05 +000069 # If $(3) is true, generate a multi-image.
70 ifeq ($(3),true)
Jeff Haodcdc85b2015-12-04 14:06:18 -080071 core_multi_infix := -multi
72 core_multi_param := --multi-image --no-inline-from=core-oj-hostdex.jar
73 core_multi_group := _multi
74 else
75 core_multi_infix :=
76 core_multi_param :=
77 core_multi_group :=
78 endif
79
Roland Levillain05e34f42018-05-24 13:19:05 +000080 core_image_name := $($(2)HOST_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_multi_infix)$(CORE_IMG_SUFFIX)
81 core_oat_name := $($(2)HOST_CORE_OAT_OUT_BASE)$$(core_infix)$$(core_multi_infix)$(CORE_OAT_SUFFIX)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070082
83 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
Richard Uhlerbb00f812017-02-16 14:21:10 +000084 ifeq ($(2),)
Roland Levillain05e34f42018-05-24 13:19:05 +000085 HOST_CORE_IMAGE_$(1)$$(core_multi_group)_64 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070086 else
Roland Levillain05e34f42018-05-24 13:19:05 +000087 HOST_CORE_IMAGE_$(1)$$(core_multi_group)_32 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070088 endif
Roland Levillain05e34f42018-05-24 13:19:05 +000089 HOST_CORE_IMG_OUTS += $$(core_image_name)
90 HOST_CORE_OAT_OUTS += $$(core_oat_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070091
92$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options)
93$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name)
94$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name)
Jeff Haodcdc85b2015-12-04 14:06:18 -080095$$(core_image_name): PRIVATE_CORE_MULTI_PARAM := $$(core_multi_param)
Nicolas Geoffraya136ab52014-10-31 10:48:25 +000096$$(core_image_name): $$(HOST_CORE_DEX_LOCATIONS) $$(core_dex2oat_dependency)
Shinichiro Hamajic5d29052015-12-18 15:51:51 +090097 @echo "host dex2oat: $$@"
Ian Rogersafd9acc2014-06-17 08:21:54 -070098 @mkdir -p $$(dir $$@)
Andreas Gampe206f4a12018-06-19 11:08:32 -070099 $$(hide) ANDROID_LOG_TAGS="*:e" $$(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
Andreas Gampe088b16e2014-12-03 21:59:27 -0800100 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700101 --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(HOST_CORE_DEX_FILES)) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700102 $$(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) \
Richard Uhlerbb00f812017-02-16 14:21:10 +0000104 --base=$$(LIBART_IMG_HOST_BASE_ADDRESS) --instruction-set=$$($(2)ART_HOST_ARCH) \
105 $$(LOCAL_$(2)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION) \
Richard Uhler556cba02017-02-28 17:06:29 +0000106 --host --android-root=$$(HOST_OUT) \
Vladimir Markoa2da9b92018-10-10 14:21:55 +0100107 --generate-debug-info --generate-build-id \
Andreas Gampee8f74ca2018-01-02 09:26:16 -0800108 --runtime-arg -XX:SlowDebug=true \
Jeff Haodcdc85b2015-12-04 14:06:18 -0800109 $$(PRIVATE_CORE_MULTI_PARAM) $$(PRIVATE_CORE_COMPILE_OPTIONS)
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700110
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700111$$(core_oat_name): $$(core_image_name)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700112
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700113 # Clean up locally used variables.
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000114 core_dex2oat_dependency :=
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700115 core_compile_options :=
116 core_image_name :=
117 core_oat_name :=
118 core_infix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700119endef # create-core-oat-host-rules
120
Roland Levillain05e34f42018-05-24 13:19:05 +0000121# $(1): compiler - optimizing, interpreter or interp-ac (interpreter-access-checks).
122# $(2): multi-image.
Andreas Gampec23c9c92014-10-28 14:47:25 -0700123define create-core-oat-host-rule-combination
Roland Levillain05e34f42018-05-24 13:19:05 +0000124 $(call create-core-oat-host-rules,$(1),,$(2))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700125
126 ifneq ($(HOST_PREFER_32_BIT),true)
Roland Levillain05e34f42018-05-24 13:19:05 +0000127 $(call create-core-oat-host-rules,$(1),2ND_,$(2))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700128 endif
129endef
130
Roland Levillain05e34f42018-05-24 13:19:05 +0000131$(eval $(call create-core-oat-host-rule-combination,optimizing,false))
132$(eval $(call create-core-oat-host-rule-combination,interpreter,false))
133$(eval $(call create-core-oat-host-rule-combination,interp-ac,false))
134$(eval $(call create-core-oat-host-rule-combination,optimizing,true))
135$(eval $(call create-core-oat-host-rule-combination,interpreter,true))
136$(eval $(call create-core-oat-host-rule-combination,interp-ac,true))
Brian Carlstrom2b7cdf42011-10-13 11:18:28 -0700137
Dan Willemsend60f5a22018-07-24 14:45:33 -0700138.PHONY: test-art-host-dex2oat-host
Jeff Haodcdc85b2015-12-04 14:06:18 -0800139test-art-host-dex2oat-host: $(HOST_CORE_IMG_OUTS)
140
Roland Levillain05e34f42018-05-24 13:19:05 +0000141# $(1): compiler - optimizing, interpreter or interp-ac (interpreter-access-checks).
142# $(2): 2ND_ or undefined
Ian Rogersafd9acc2014-06-17 08:21:54 -0700143define create-core-oat-target-rules
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700144 core_compile_options :=
145 core_image_name :=
146 core_oat_name :=
147 core_infix :=
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000148 core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700149
150 ifeq ($(1),optimizing)
Serban Constantinescu010cf912014-12-04 18:12:21 +0000151 core_compile_options += --compiler-backend=Optimizing
Nicolas Geoffray7701d102015-10-05 09:51:36 +0100152 # With the optimizing compiler, we want to rerun dex2oat whenever there is
153 # a dex2oat change to catch regressions early.
154 core_dex2oat_dependency := $(DEX2OAT)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700155 endif
156 ifeq ($(1),interpreter)
Nicolas Geoffray49cda062017-04-21 13:08:25 +0100157 core_compile_options += --compiler-filter=quicken
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700158 core_infix := -interpreter
159 endif
Andreas Gampe825570c2015-07-26 10:26:03 -0700160 ifeq ($(1),interp-ac)
Nicolas Geoffray49cda062017-04-21 13:08:25 +0100161 core_compile_options += --compiler-filter=extract --runtime-arg -Xverify:softfail
Andreas Gampe825570c2015-07-26 10:26:03 -0700162 core_infix := -interp-ac
Igor Murashkin7617abd2015-07-10 18:27:47 -0700163 endif
Nicolas Geoffrayb76bc782016-09-14 12:33:34 +0000164 ifneq ($(filter-out interpreter interp-ac optimizing,$(1)),)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700165 # Technically this test is not precise, but hopefully good enough.
Roland Levillain05e34f42018-05-24 13:19:05 +0000166 $$(error found $(1) expected interpreter, interp-ac, or optimizing)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700167 endif
Andreas Gampec23c9c92014-10-28 14:47:25 -0700168
Roland Levillain05e34f42018-05-24 13:19:05 +0000169 core_image_name := $($(2)TARGET_CORE_IMG_OUT_BASE)$$(core_infix)$(CORE_IMG_SUFFIX)
170 core_oat_name := $($(2)TARGET_CORE_OAT_OUT_BASE)$$(core_infix)$(CORE_OAT_SUFFIX)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700171
172 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
Richard Uhlerbb00f812017-02-16 14:21:10 +0000173 ifeq ($(2),)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700174 ifdef TARGET_2ND_ARCH
Roland Levillain05e34f42018-05-24 13:19:05 +0000175 TARGET_CORE_IMAGE_$(1)_64 := $$(core_image_name)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700176 else
Roland Levillain05e34f42018-05-24 13:19:05 +0000177 TARGET_CORE_IMAGE_$(1)_32 := $$(core_image_name)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700178 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700179 else
Roland Levillain05e34f42018-05-24 13:19:05 +0000180 TARGET_CORE_IMAGE_$(1)_32 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700181 endif
Roland Levillain05e34f42018-05-24 13:19:05 +0000182 TARGET_CORE_IMG_OUTS += $$(core_image_name)
183 TARGET_CORE_OAT_OUTS += $$(core_oat_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700184
185$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options)
186$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name)
187$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name)
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000188$$(core_image_name): $$(TARGET_CORE_DEX_FILES) $$(core_dex2oat_dependency)
Shinichiro Hamajic5d29052015-12-18 15:51:51 +0900189 @echo "target dex2oat: $$@"
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700190 @mkdir -p $$(dir $$@)
Roland Levillain05e34f42018-05-24 13:19:05 +0000191 $$(hide) $$(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
Andreas Gampe088b16e2014-12-03 21:59:27 -0800192 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700193 --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(TARGET_CORE_DEX_FILES)) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700194 $$(addprefix --dex-location=,$$(TARGET_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \
195 --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \
Richard Uhlerbb00f812017-02-16 14:21:10 +0000196 --base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) --instruction-set=$$($(2)TARGET_ARCH) \
197 --instruction-set-variant=$$($(2)DEX2OAT_TARGET_CPU_VARIANT) \
198 --instruction-set-features=$$($(2)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
Richard Uhler556cba02017-02-28 17:06:29 +0000199 --android-root=$$(PRODUCT_OUT)/system \
Vladimir Markoa2da9b92018-10-10 14:21:55 +0100200 --generate-debug-info --generate-build-id \
Andreas Gampee8f74ca2018-01-02 09:26:16 -0800201 --runtime-arg -XX:SlowDebug=true \
Nicolas Geoffray130bd1b2014-11-03 16:23:48 +0000202 $$(PRIVATE_CORE_COMPILE_OPTIONS) || (rm $$(PRIVATE_CORE_OAT_NAME); exit 1)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700203
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700204$$(core_oat_name): $$(core_image_name)
Andreas Gampe2fe07922014-04-21 07:50:39 -0700205
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700206 # Clean up locally used variables.
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000207 core_dex2oat_dependency :=
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700208 core_compile_options :=
209 core_image_name :=
210 core_oat_name :=
211 core_infix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700212endef # create-core-oat-target-rules
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700213
Roland Levillain05e34f42018-05-24 13:19:05 +0000214# $(1): compiler - optimizing, interpreter or interp-ac (interpreter-access-checks).
Andreas Gampec23c9c92014-10-28 14:47:25 -0700215define create-core-oat-target-rule-combination
Roland Levillain05e34f42018-05-24 13:19:05 +0000216 $(call create-core-oat-target-rules,$(1),)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700217
218 ifdef TARGET_2ND_ARCH
Roland Levillain05e34f42018-05-24 13:19:05 +0000219 $(call create-core-oat-target-rules,$(1),2ND_)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700220 endif
221endef
222
Roland Levillain05e34f42018-05-24 13:19:05 +0000223$(eval $(call create-core-oat-target-rule-combination,optimizing))
224$(eval $(call create-core-oat-target-rule-combination,interpreter))
225$(eval $(call create-core-oat-target-rule-combination,interp-ac))
Richard Uhler67e1dc52017-02-06 16:50:17 +0000226
227# Define a default core image that can be used for things like gtests that
228# need some image to run, but don't otherwise care which image is used.
Richard Uhlerbb00f812017-02-16 14:21:10 +0000229HOST_CORE_IMAGE_DEFAULT_32 := $(HOST_CORE_IMAGE_optimizing_32)
230HOST_CORE_IMAGE_DEFAULT_64 := $(HOST_CORE_IMAGE_optimizing_64)
231TARGET_CORE_IMAGE_DEFAULT_32 := $(TARGET_CORE_IMAGE_optimizing_32)
232TARGET_CORE_IMAGE_DEFAULT_64 := $(TARGET_CORE_IMAGE_optimizing_64)