blob: d4fd5190a04a4a036cd4a7b5c618d9241912e41d [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
Ian Rogersd582fa42014-11-05 23:46:43 -080026ifeq ($(DEX2OAT_HOST_INSTRUCTION_SET_FEATURES),)
27 DEX2OAT_HOST_INSTRUCTION_SET_FEATURES := default
28endif
29ifeq ($($(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES),)
30 $(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES := default
31endif
32
Nicolas Geoffray1db132d2014-03-26 10:56:24 +000033# Use dex2oat debug version for better error reporting
Andreas Gampec23c9c92014-10-28 14:47:25 -070034# $(1): compiler - default, optimizing or interpreter.
35# $(2): pic/no-pic
36# $(3): 2ND_ or undefined, 2ND_ for 32-bit host builds.
Andreas Gampe088b16e2014-12-03 21:59:27 -080037# $(4): wrapper, e.g., valgrind.
38# $(5): dex2oat suffix, e.g, valgrind requires 32 right now.
Alex Light1ef4ce82014-08-27 11:13:47 -070039# NB depending on HOST_CORE_DEX_LOCATIONS so we are sure to have the dex files in frameworks for
40# run-test --no-image
Ian Rogersafd9acc2014-06-17 08:21:54 -070041define create-core-oat-host-rules
Andreas Gampe63fc30e2014-10-24 21:58:16 -070042 core_compile_options :=
43 core_image_name :=
44 core_oat_name :=
45 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -070046 core_pic_infix :=
Nicolas Geoffraya136ab52014-10-31 10:48:25 +000047 core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070048
Nicolas Geoffray5d672a62014-12-04 14:39:31 +000049 # With the optimizing compiler, we want to rerun dex2oat whenever there is
50 # a dex2oat change to catch regressions early.
51 ifeq ($(ART_USE_OPTIMIZING_COMPILER), true)
52 core_dex2oat_dependency := $(DEX2OAT)
Nicolas Geoffrayc9338b92014-12-03 13:36:10 +000053 endif
Nicolas Geoffray5d672a62014-12-04 14:39:31 +000054
Andreas Gampe63fc30e2014-10-24 21:58:16 -070055 ifeq ($(1),optimizing)
Nicolas Geoffraya136ab52014-10-31 10:48:25 +000056 core_compile_options += --compiler-backend=Optimizing
Nicolas Geoffraya136ab52014-10-31 10:48:25 +000057 core_dex2oat_dependency := $(DEX2OAT)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070058 core_infix := -optimizing
59 endif
60 ifeq ($(1),interpreter)
61 core_compile_options += --compiler-filter=interpret-only
62 core_infix := -interpreter
63 endif
64 ifeq ($(1),default)
65 # Default has no infix, no compile options.
66 endif
67 ifneq ($(filter-out default interpreter optimizing,$(1)),)
68 #Technically this test is not precise, but hopefully good enough.
69 $$(error found $(1) expected default, interpreter or optimizing)
70 endif
Andreas Gampec23c9c92014-10-28 14:47:25 -070071
72 ifeq ($(2),pic)
73 core_compile_options += --compile-pic
74 core_pic_infix := -pic
75 endif
76 ifeq ($(2),no-pic)
77 # No change for non-pic
78 endif
79 ifneq ($(filter-out pic no-pic,$(2)),)
80 # Technically this test is not precise, but hopefully good enough.
81 $$(error found $(2) expected pic or no-pic)
82 endif
83
Andreas Gampe088b16e2014-12-03 21:59:27 -080084 core_image_name := $($(3)HOST_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(4)$(CORE_IMG_SUFFIX)
85 core_oat_name := $($(3)HOST_CORE_OAT_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(4)$(CORE_OAT_SUFFIX)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070086
87 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
Andreas Gampec23c9c92014-10-28 14:47:25 -070088 ifeq ($(3),)
Andreas Gampe088b16e2014-12-03 21:59:27 -080089 $(4)HOST_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070090 else
Andreas Gampe088b16e2014-12-03 21:59:27 -080091 $(4)HOST_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070092 endif
Andreas Gampe088b16e2014-12-03 21:59:27 -080093 $(4)HOST_CORE_IMG_OUTS += $$(core_image_name)
94 $(4)HOST_CORE_OAT_OUTS += $$(core_oat_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070095
Andreas Gampe088b16e2014-12-03 21:59:27 -080096 # If we have a wrapper, make the target phony.
97 ifneq ($(4),)
98.PHONY: $$(core_image_name)
99 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700100$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options)
101$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name)
102$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name)
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000103$$(core_image_name): $$(HOST_CORE_DEX_LOCATIONS) $$(core_dex2oat_dependency)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700104 @echo "host dex2oat: $$@ ($$?)"
105 @mkdir -p $$(dir $$@)
Andreas Gampe088b16e2014-12-03 21:59:27 -0800106 $$(hide) $(4) $$(DEX2OAT)$(5) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
107 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700108 --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(HOST_CORE_DEX_FILES)) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700109 $$(addprefix --dex-location=,$$(HOST_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \
110 --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \
Andreas Gampec23c9c92014-10-28 14:47:25 -0700111 --base=$$(LIBART_IMG_HOST_BASE_ADDRESS) --instruction-set=$$($(3)ART_HOST_ARCH) \
Ian Rogersd582fa42014-11-05 23:46:43 -0800112 --instruction-set-features=$$($(3)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700113 --host --android-root=$$(HOST_OUT) --include-patch-information \
114 $$(PRIVATE_CORE_COMPILE_OPTIONS)
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700115
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700116$$(core_oat_name): $$(core_image_name)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700117
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700118 # Clean up locally used variables.
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000119 core_dex2oat_dependency :=
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700120 core_compile_options :=
121 core_image_name :=
122 core_oat_name :=
123 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -0700124 core_pic_infix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700125endef # create-core-oat-host-rules
126
Andreas Gampec23c9c92014-10-28 14:47:25 -0700127# $(1): compiler - default, optimizing or interpreter.
Andreas Gampe088b16e2014-12-03 21:59:27 -0800128# $(2): wrapper.
129# $(3): dex2oat suffix.
Andreas Gampec23c9c92014-10-28 14:47:25 -0700130define create-core-oat-host-rule-combination
Andreas Gampe088b16e2014-12-03 21:59:27 -0800131 $(call create-core-oat-host-rules,$(1),no-pic,,$(2),$(3))
132 $(call create-core-oat-host-rules,$(1),pic,,$(2),$(3))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700133
134 ifneq ($(HOST_PREFER_32_BIT),true)
Andreas Gampe088b16e2014-12-03 21:59:27 -0800135 $(call create-core-oat-host-rules,$(1),no-pic,2ND_,$(2),$(3))
136 $(call create-core-oat-host-rules,$(1),pic,2ND_,$(2),$(3))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700137 endif
138endef
139
Andreas Gampe088b16e2014-12-03 21:59:27 -0800140$(eval $(call create-core-oat-host-rule-combination,default,,))
141$(eval $(call create-core-oat-host-rule-combination,optimizing,,))
142$(eval $(call create-core-oat-host-rule-combination,interpreter,,))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700143
Andreas Gampe088b16e2014-12-03 21:59:27 -0800144valgrindHOST_CORE_IMG_OUTS :=
145valgrindHOST_CORE_OAT_OUTS :=
146$(eval $(call create-core-oat-host-rule-combination,default,valgrind,32))
147$(eval $(call create-core-oat-host-rule-combination,optimizing,valgrind,32))
148$(eval $(call create-core-oat-host-rule-combination,interpreter,valgrind,32))
149
150valgrind-test-art-host-dex2oat-host: $(valgrindHOST_CORE_IMG_OUTS)
Brian Carlstrom2b7cdf42011-10-13 11:18:28 -0700151
Ian Rogersafd9acc2014-06-17 08:21:54 -0700152define create-core-oat-target-rules
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700153 core_compile_options :=
154 core_image_name :=
155 core_oat_name :=
156 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -0700157 core_pic_infix :=
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000158 core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700159
Nicolas Geoffray5d672a62014-12-04 14:39:31 +0000160 # With the optimizing compiler, we want to rerun dex2oat whenever there is
161 # a dex2oat change to catch regressions early.
162 ifeq ($(ART_USE_OPTIMIZING_COMPILER), true)
163 core_dex2oat_dependency := $(DEX2OAT)
Nicolas Geoffrayc9338b92014-12-03 13:36:10 +0000164 endif
Nicolas Geoffray5d672a62014-12-04 14:39:31 +0000165
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700166 ifeq ($(1),optimizing)
Serban Constantinescu010cf912014-12-04 18:12:21 +0000167 core_compile_options += --compiler-backend=Optimizing
168 core_dex2oat_dependency := $(DEX2OAT)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700169 core_infix := -optimizing
170 endif
171 ifeq ($(1),interpreter)
172 core_compile_options += --compiler-filter=interpret-only
173 core_infix := -interpreter
174 endif
175 ifeq ($(1),default)
176 # Default has no infix, no compile options.
177 endif
178 ifneq ($(filter-out default interpreter optimizing,$(1)),)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700179 # Technically this test is not precise, but hopefully good enough.
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700180 $$(error found $(1) expected default, interpreter or optimizing)
181 endif
Andreas Gampec23c9c92014-10-28 14:47:25 -0700182
183 ifeq ($(2),pic)
184 core_compile_options += --compile-pic
185 core_pic_infix := -pic
186 endif
187 ifeq ($(2),no-pic)
188 # No change for non-pic
189 endif
190 ifneq ($(filter-out pic no-pic,$(2)),)
191 #Technically this test is not precise, but hopefully good enough.
192 $$(error found $(2) expected pic or no-pic)
193 endif
194
Andreas Gampe088b16e2014-12-03 21:59:27 -0800195 core_image_name := $($(3)TARGET_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(4)$(CORE_IMG_SUFFIX)
196 core_oat_name := $($(3)TARGET_CORE_OAT_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(4)$(CORE_OAT_SUFFIX)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700197
198 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
Andreas Gampec23c9c92014-10-28 14:47:25 -0700199 ifeq ($(3),)
200 ifdef TARGET_2ND_ARCH
Andreas Gampe088b16e2014-12-03 21:59:27 -0800201 $(4)TARGET_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700202 else
Andreas Gampe088b16e2014-12-03 21:59:27 -0800203 $(4)TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700204 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700205 else
Andreas Gampe088b16e2014-12-03 21:59:27 -0800206 $(4)TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700207 endif
Andreas Gampe088b16e2014-12-03 21:59:27 -0800208 $(4)TARGET_CORE_IMG_OUTS += $$(core_image_name)
209 $(4)TARGET_CORE_OAT_OUTS += $$(core_oat_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700210
Andreas Gampe088b16e2014-12-03 21:59:27 -0800211 # If we have a wrapper, make the target phony.
212 ifneq ($(4),)
213.PHONY: $$(core_image_name)
214 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700215$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options)
216$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name)
217$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name)
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000218$$(core_image_name): $$(TARGET_CORE_DEX_FILES) $$(core_dex2oat_dependency)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700219 @echo "target dex2oat: $$@ ($$?)"
220 @mkdir -p $$(dir $$@)
Andreas Gampe088b16e2014-12-03 21:59:27 -0800221 $$(hide) $(4) $$(DEX2OAT)$(5) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
222 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700223 --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(TARGET_CORE_DEX_FILES)) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700224 $$(addprefix --dex-location=,$$(TARGET_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \
225 --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \
Andreas Gampec23c9c92014-10-28 14:47:25 -0700226 --base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) --instruction-set=$$($(3)TARGET_ARCH) \
Ian Rogersd582fa42014-11-05 23:46:43 -0800227 --instruction-set-features=$$($(3)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700228 --android-root=$$(PRODUCT_OUT)/system --include-patch-information \
Nicolas Geoffray130bd1b2014-11-03 16:23:48 +0000229 $$(PRIVATE_CORE_COMPILE_OPTIONS) || (rm $$(PRIVATE_CORE_OAT_NAME); exit 1)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700230
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700231$$(core_oat_name): $$(core_image_name)
Andreas Gampe2fe07922014-04-21 07:50:39 -0700232
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700233 # Clean up locally used variables.
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000234 core_dex2oat_dependency :=
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700235 core_compile_options :=
236 core_image_name :=
237 core_oat_name :=
238 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -0700239 core_pic_infix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700240endef # create-core-oat-target-rules
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700241
Andreas Gampec23c9c92014-10-28 14:47:25 -0700242# $(1): compiler - default, optimizing or interpreter.
Andreas Gampe088b16e2014-12-03 21:59:27 -0800243# $(2): wrapper.
244# $(3): dex2oat suffix.
Andreas Gampec23c9c92014-10-28 14:47:25 -0700245define create-core-oat-target-rule-combination
Andreas Gampe088b16e2014-12-03 21:59:27 -0800246 $(call create-core-oat-target-rules,$(1),no-pic,,$(2),$(3))
247 $(call create-core-oat-target-rules,$(1),pic,,$(2),$(3))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700248
249 ifdef TARGET_2ND_ARCH
Andreas Gampe088b16e2014-12-03 21:59:27 -0800250 $(call create-core-oat-target-rules,$(1),no-pic,2ND_,$(2),$(3))
251 $(call create-core-oat-target-rules,$(1),pic,2ND_,$(2),$(3))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700252 endif
253endef
254
Andreas Gampe088b16e2014-12-03 21:59:27 -0800255$(eval $(call create-core-oat-target-rule-combination,default,,))
256$(eval $(call create-core-oat-target-rule-combination,optimizing,,))
257$(eval $(call create-core-oat-target-rule-combination,interpreter,,))
258
259valgrindTARGET_CORE_IMG_OUTS :=
260valgrindTARGET_CORE_OAT_OUTS :=
261$(eval $(call create-core-oat-target-rule-combination,default,valgrind,32))
262$(eval $(call create-core-oat-target-rule-combination,optimizing,valgrind,32))
263$(eval $(call create-core-oat-target-rule-combination,interpreter,valgrind,32))
264
265valgrind-test-art-host-dex2oat-target: $(valgrindTARGET_CORE_IMG_OUTS)
266
267valgrind-test-art-host-dex2oat: valgrind-test-art-host-dex2oat-host valgrind-test-art-host-dex2oat-target