blob: 710b130282effd25a43da88565fa2a12b48816c9 [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
Mathieu Chartier3fc1b122015-02-26 10:58:08 -080034# $(1): compiler - default, optimizing, jit or interpreter.
Andreas Gampec23c9c92014-10-28 14:47:25 -070035# $(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
Nicolas Geoffray6427df12014-12-17 12:34:15 +000055 ifeq ($(1),default)
56 core_compile_options += --compiler-backend=Quick
57 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -070058 ifeq ($(1),optimizing)
Nicolas Geoffraya136ab52014-10-31 10:48:25 +000059 core_compile_options += --compiler-backend=Optimizing
Nicolas Geoffraya136ab52014-10-31 10:48:25 +000060 core_dex2oat_dependency := $(DEX2OAT)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070061 core_infix := -optimizing
62 endif
63 ifeq ($(1),interpreter)
64 core_compile_options += --compiler-filter=interpret-only
65 core_infix := -interpreter
66 endif
67 ifeq ($(1),default)
68 # Default has no infix, no compile options.
69 endif
Mathieu Chartier3fc1b122015-02-26 10:58:08 -080070 ifneq ($(filter-out default interpreter jit optimizing,$(1)),)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070071 #Technically this test is not precise, but hopefully good enough.
Mathieu Chartier3fc1b122015-02-26 10:58:08 -080072 $$(error found $(1) expected default, interpreter, jit or optimizing)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070073 endif
Andreas Gampec23c9c92014-10-28 14:47:25 -070074
75 ifeq ($(2),pic)
76 core_compile_options += --compile-pic
77 core_pic_infix := -pic
78 endif
79 ifeq ($(2),no-pic)
80 # No change for non-pic
81 endif
82 ifneq ($(filter-out pic no-pic,$(2)),)
83 # Technically this test is not precise, but hopefully good enough.
84 $$(error found $(2) expected pic or no-pic)
85 endif
86
Andreas Gampe088b16e2014-12-03 21:59:27 -080087 core_image_name := $($(3)HOST_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(4)$(CORE_IMG_SUFFIX)
88 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 -070089
90 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
Andreas Gampec23c9c92014-10-28 14:47:25 -070091 ifeq ($(3),)
Andreas Gampe088b16e2014-12-03 21:59:27 -080092 $(4)HOST_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070093 else
Andreas Gampe088b16e2014-12-03 21:59:27 -080094 $(4)HOST_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070095 endif
Andreas Gampe088b16e2014-12-03 21:59:27 -080096 $(4)HOST_CORE_IMG_OUTS += $$(core_image_name)
97 $(4)HOST_CORE_OAT_OUTS += $$(core_oat_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070098
Andreas Gampe088b16e2014-12-03 21:59:27 -080099 # If we have a wrapper, make the target phony.
100 ifneq ($(4),)
101.PHONY: $$(core_image_name)
102 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700103$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options)
104$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name)
105$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name)
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000106$$(core_image_name): $$(HOST_CORE_DEX_LOCATIONS) $$(core_dex2oat_dependency)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700107 @echo "host dex2oat: $$@ ($$?)"
108 @mkdir -p $$(dir $$@)
Andreas Gampe088b16e2014-12-03 21:59:27 -0800109 $$(hide) $(4) $$(DEX2OAT)$(5) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
110 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700111 --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(HOST_CORE_DEX_FILES)) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700112 $$(addprefix --dex-location=,$$(HOST_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \
113 --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \
Andreas Gampec23c9c92014-10-28 14:47:25 -0700114 --base=$$(LIBART_IMG_HOST_BASE_ADDRESS) --instruction-set=$$($(3)ART_HOST_ARCH) \
Ian Rogersd582fa42014-11-05 23:46:43 -0800115 --instruction-set-features=$$($(3)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700116 --host --android-root=$$(HOST_OUT) --include-patch-information \
117 $$(PRIVATE_CORE_COMPILE_OPTIONS)
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700118
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700119$$(core_oat_name): $$(core_image_name)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700120
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700121 # Clean up locally used variables.
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000122 core_dex2oat_dependency :=
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700123 core_compile_options :=
124 core_image_name :=
125 core_oat_name :=
126 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -0700127 core_pic_infix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700128endef # create-core-oat-host-rules
129
Mathieu Chartier3fc1b122015-02-26 10:58:08 -0800130# $(1): compiler - default, optimizing, jit or interpreter.
Andreas Gampe088b16e2014-12-03 21:59:27 -0800131# $(2): wrapper.
132# $(3): dex2oat suffix.
Andreas Gampec23c9c92014-10-28 14:47:25 -0700133define create-core-oat-host-rule-combination
Andreas Gampe088b16e2014-12-03 21:59:27 -0800134 $(call create-core-oat-host-rules,$(1),no-pic,,$(2),$(3))
135 $(call create-core-oat-host-rules,$(1),pic,,$(2),$(3))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700136
137 ifneq ($(HOST_PREFER_32_BIT),true)
Andreas Gampe088b16e2014-12-03 21:59:27 -0800138 $(call create-core-oat-host-rules,$(1),no-pic,2ND_,$(2),$(3))
139 $(call create-core-oat-host-rules,$(1),pic,2ND_,$(2),$(3))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700140 endif
141endef
142
Andreas Gampe088b16e2014-12-03 21:59:27 -0800143$(eval $(call create-core-oat-host-rule-combination,default,,))
144$(eval $(call create-core-oat-host-rule-combination,optimizing,,))
145$(eval $(call create-core-oat-host-rule-combination,interpreter,,))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700146
Andreas Gampe088b16e2014-12-03 21:59:27 -0800147valgrindHOST_CORE_IMG_OUTS :=
148valgrindHOST_CORE_OAT_OUTS :=
149$(eval $(call create-core-oat-host-rule-combination,default,valgrind,32))
150$(eval $(call create-core-oat-host-rule-combination,optimizing,valgrind,32))
151$(eval $(call create-core-oat-host-rule-combination,interpreter,valgrind,32))
152
153valgrind-test-art-host-dex2oat-host: $(valgrindHOST_CORE_IMG_OUTS)
Brian Carlstrom2b7cdf42011-10-13 11:18:28 -0700154
Ian Rogersafd9acc2014-06-17 08:21:54 -0700155define create-core-oat-target-rules
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700156 core_compile_options :=
157 core_image_name :=
158 core_oat_name :=
159 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -0700160 core_pic_infix :=
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000161 core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700162
Nicolas Geoffray5d672a62014-12-04 14:39:31 +0000163 # With the optimizing compiler, we want to rerun dex2oat whenever there is
164 # a dex2oat change to catch regressions early.
165 ifeq ($(ART_USE_OPTIMIZING_COMPILER), true)
166 core_dex2oat_dependency := $(DEX2OAT)
Nicolas Geoffrayc9338b92014-12-03 13:36:10 +0000167 endif
Nicolas Geoffray5d672a62014-12-04 14:39:31 +0000168
Nicolas Geoffray6427df12014-12-17 12:34:15 +0000169 ifeq ($(1),default)
170 core_compile_options += --compiler-backend=Quick
171 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700172 ifeq ($(1),optimizing)
Serban Constantinescu010cf912014-12-04 18:12:21 +0000173 core_compile_options += --compiler-backend=Optimizing
174 core_dex2oat_dependency := $(DEX2OAT)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700175 core_infix := -optimizing
176 endif
177 ifeq ($(1),interpreter)
178 core_compile_options += --compiler-filter=interpret-only
179 core_infix := -interpreter
180 endif
181 ifeq ($(1),default)
182 # Default has no infix, no compile options.
183 endif
Mathieu Chartier3fc1b122015-02-26 10:58:08 -0800184 ifneq ($(filter-out default interpreter jit optimizing,$(1)),)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700185 # Technically this test is not precise, but hopefully good enough.
Mathieu Chartier3fc1b122015-02-26 10:58:08 -0800186 $$(error found $(1) expected default, interpreter, jit or optimizing)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700187 endif
Andreas Gampec23c9c92014-10-28 14:47:25 -0700188
189 ifeq ($(2),pic)
190 core_compile_options += --compile-pic
191 core_pic_infix := -pic
192 endif
193 ifeq ($(2),no-pic)
194 # No change for non-pic
195 endif
196 ifneq ($(filter-out pic no-pic,$(2)),)
197 #Technically this test is not precise, but hopefully good enough.
198 $$(error found $(2) expected pic or no-pic)
199 endif
200
Andreas Gampe088b16e2014-12-03 21:59:27 -0800201 core_image_name := $($(3)TARGET_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(4)$(CORE_IMG_SUFFIX)
202 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 -0700203
204 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
Andreas Gampec23c9c92014-10-28 14:47:25 -0700205 ifeq ($(3),)
206 ifdef TARGET_2ND_ARCH
Andreas Gampe088b16e2014-12-03 21:59:27 -0800207 $(4)TARGET_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700208 else
Andreas Gampe088b16e2014-12-03 21:59:27 -0800209 $(4)TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700210 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700211 else
Andreas Gampe088b16e2014-12-03 21:59:27 -0800212 $(4)TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700213 endif
Andreas Gampe088b16e2014-12-03 21:59:27 -0800214 $(4)TARGET_CORE_IMG_OUTS += $$(core_image_name)
215 $(4)TARGET_CORE_OAT_OUTS += $$(core_oat_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700216
Andreas Gampe088b16e2014-12-03 21:59:27 -0800217 # If we have a wrapper, make the target phony.
218 ifneq ($(4),)
219.PHONY: $$(core_image_name)
220 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700221$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options)
222$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name)
223$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name)
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000224$$(core_image_name): $$(TARGET_CORE_DEX_FILES) $$(core_dex2oat_dependency)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700225 @echo "target dex2oat: $$@ ($$?)"
226 @mkdir -p $$(dir $$@)
Andreas Gampe088b16e2014-12-03 21:59:27 -0800227 $$(hide) $(4) $$(DEX2OAT)$(5) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
228 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700229 --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(TARGET_CORE_DEX_FILES)) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700230 $$(addprefix --dex-location=,$$(TARGET_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \
231 --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \
Andreas Gampec23c9c92014-10-28 14:47:25 -0700232 --base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) --instruction-set=$$($(3)TARGET_ARCH) \
Douglas Leung3d12ead2015-03-18 11:29:14 -0700233 --instruction-set-variant=$$($(3)DEX2OAT_TARGET_CPU_VARIANT) \
Ian Rogersd582fa42014-11-05 23:46:43 -0800234 --instruction-set-features=$$($(3)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700235 --android-root=$$(PRODUCT_OUT)/system --include-patch-information \
Nicolas Geoffray130bd1b2014-11-03 16:23:48 +0000236 $$(PRIVATE_CORE_COMPILE_OPTIONS) || (rm $$(PRIVATE_CORE_OAT_NAME); exit 1)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700237
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700238$$(core_oat_name): $$(core_image_name)
Andreas Gampe2fe07922014-04-21 07:50:39 -0700239
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700240 # Clean up locally used variables.
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000241 core_dex2oat_dependency :=
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700242 core_compile_options :=
243 core_image_name :=
244 core_oat_name :=
245 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -0700246 core_pic_infix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700247endef # create-core-oat-target-rules
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700248
Mathieu Chartier3fc1b122015-02-26 10:58:08 -0800249# $(1): compiler - default, optimizing, jit or interpreter.
Andreas Gampe088b16e2014-12-03 21:59:27 -0800250# $(2): wrapper.
251# $(3): dex2oat suffix.
Andreas Gampec23c9c92014-10-28 14:47:25 -0700252define create-core-oat-target-rule-combination
Andreas Gampe088b16e2014-12-03 21:59:27 -0800253 $(call create-core-oat-target-rules,$(1),no-pic,,$(2),$(3))
254 $(call create-core-oat-target-rules,$(1),pic,,$(2),$(3))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700255
256 ifdef TARGET_2ND_ARCH
Andreas Gampe088b16e2014-12-03 21:59:27 -0800257 $(call create-core-oat-target-rules,$(1),no-pic,2ND_,$(2),$(3))
258 $(call create-core-oat-target-rules,$(1),pic,2ND_,$(2),$(3))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700259 endif
260endef
261
Andreas Gampe088b16e2014-12-03 21:59:27 -0800262$(eval $(call create-core-oat-target-rule-combination,default,,))
263$(eval $(call create-core-oat-target-rule-combination,optimizing,,))
264$(eval $(call create-core-oat-target-rule-combination,interpreter,,))
265
266valgrindTARGET_CORE_IMG_OUTS :=
267valgrindTARGET_CORE_OAT_OUTS :=
268$(eval $(call create-core-oat-target-rule-combination,default,valgrind,32))
269$(eval $(call create-core-oat-target-rule-combination,optimizing,valgrind,32))
270$(eval $(call create-core-oat-target-rule-combination,interpreter,valgrind,32))
271
272valgrind-test-art-host-dex2oat-target: $(valgrindTARGET_CORE_IMG_OUTS)
273
274valgrind-test-art-host-dex2oat: valgrind-test-art-host-dex2oat-host valgrind-test-art-host-dex2oat-target