blob: 22ecb016c241eb8efdf03cc9725f5f65334ea46d [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
Mathieu Chartier3fc1b122015-02-26 10:58:08 -080067 ifeq ($(1),jit)
68 core_compile_options += --compiler-filter=interpret-only
69 core_infix := -jit
70 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -070071 ifeq ($(1),default)
72 # Default has no infix, no compile options.
73 endif
Mathieu Chartier3fc1b122015-02-26 10:58:08 -080074 ifneq ($(filter-out default interpreter jit optimizing,$(1)),)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070075 #Technically this test is not precise, but hopefully good enough.
Mathieu Chartier3fc1b122015-02-26 10:58:08 -080076 $$(error found $(1) expected default, interpreter, jit or optimizing)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070077 endif
Andreas Gampec23c9c92014-10-28 14:47:25 -070078
79 ifeq ($(2),pic)
80 core_compile_options += --compile-pic
81 core_pic_infix := -pic
82 endif
83 ifeq ($(2),no-pic)
84 # No change for non-pic
85 endif
86 ifneq ($(filter-out pic no-pic,$(2)),)
87 # Technically this test is not precise, but hopefully good enough.
88 $$(error found $(2) expected pic or no-pic)
89 endif
90
Andreas Gampe088b16e2014-12-03 21:59:27 -080091 core_image_name := $($(3)HOST_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(4)$(CORE_IMG_SUFFIX)
92 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 -070093
94 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
Andreas Gampec23c9c92014-10-28 14:47:25 -070095 ifeq ($(3),)
Andreas Gampe088b16e2014-12-03 21:59:27 -080096 $(4)HOST_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070097 else
Andreas Gampe088b16e2014-12-03 21:59:27 -080098 $(4)HOST_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070099 endif
Andreas Gampe088b16e2014-12-03 21:59:27 -0800100 $(4)HOST_CORE_IMG_OUTS += $$(core_image_name)
101 $(4)HOST_CORE_OAT_OUTS += $$(core_oat_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700102
Andreas Gampe088b16e2014-12-03 21:59:27 -0800103 # If we have a wrapper, make the target phony.
104 ifneq ($(4),)
105.PHONY: $$(core_image_name)
106 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700107$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options)
108$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name)
109$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name)
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000110$$(core_image_name): $$(HOST_CORE_DEX_LOCATIONS) $$(core_dex2oat_dependency)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700111 @echo "host dex2oat: $$@ ($$?)"
112 @mkdir -p $$(dir $$@)
Andreas Gampe088b16e2014-12-03 21:59:27 -0800113 $$(hide) $(4) $$(DEX2OAT)$(5) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
114 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700115 --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(HOST_CORE_DEX_FILES)) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700116 $$(addprefix --dex-location=,$$(HOST_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \
117 --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \
Andreas Gampec23c9c92014-10-28 14:47:25 -0700118 --base=$$(LIBART_IMG_HOST_BASE_ADDRESS) --instruction-set=$$($(3)ART_HOST_ARCH) \
Ian Rogersd582fa42014-11-05 23:46:43 -0800119 --instruction-set-features=$$($(3)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700120 --host --android-root=$$(HOST_OUT) --include-patch-information \
121 $$(PRIVATE_CORE_COMPILE_OPTIONS)
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700122
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700123$$(core_oat_name): $$(core_image_name)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700124
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700125 # Clean up locally used variables.
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000126 core_dex2oat_dependency :=
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700127 core_compile_options :=
128 core_image_name :=
129 core_oat_name :=
130 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -0700131 core_pic_infix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700132endef # create-core-oat-host-rules
133
Mathieu Chartier3fc1b122015-02-26 10:58:08 -0800134# $(1): compiler - default, optimizing, jit or interpreter.
Andreas Gampe088b16e2014-12-03 21:59:27 -0800135# $(2): wrapper.
136# $(3): dex2oat suffix.
Andreas Gampec23c9c92014-10-28 14:47:25 -0700137define create-core-oat-host-rule-combination
Andreas Gampe088b16e2014-12-03 21:59:27 -0800138 $(call create-core-oat-host-rules,$(1),no-pic,,$(2),$(3))
139 $(call create-core-oat-host-rules,$(1),pic,,$(2),$(3))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700140
141 ifneq ($(HOST_PREFER_32_BIT),true)
Andreas Gampe088b16e2014-12-03 21:59:27 -0800142 $(call create-core-oat-host-rules,$(1),no-pic,2ND_,$(2),$(3))
143 $(call create-core-oat-host-rules,$(1),pic,2ND_,$(2),$(3))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700144 endif
145endef
146
Andreas Gampe088b16e2014-12-03 21:59:27 -0800147$(eval $(call create-core-oat-host-rule-combination,default,,))
148$(eval $(call create-core-oat-host-rule-combination,optimizing,,))
149$(eval $(call create-core-oat-host-rule-combination,interpreter,,))
Mathieu Chartier3fc1b122015-02-26 10:58:08 -0800150$(eval $(call create-core-oat-host-rule-combination,jit,,))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700151
Andreas Gampe088b16e2014-12-03 21:59:27 -0800152valgrindHOST_CORE_IMG_OUTS :=
153valgrindHOST_CORE_OAT_OUTS :=
154$(eval $(call create-core-oat-host-rule-combination,default,valgrind,32))
155$(eval $(call create-core-oat-host-rule-combination,optimizing,valgrind,32))
156$(eval $(call create-core-oat-host-rule-combination,interpreter,valgrind,32))
Mathieu Chartier3fc1b122015-02-26 10:58:08 -0800157$(eval $(call create-core-oat-host-rule-combination,jit,valgrind,32))
Andreas Gampe088b16e2014-12-03 21:59:27 -0800158
159valgrind-test-art-host-dex2oat-host: $(valgrindHOST_CORE_IMG_OUTS)
Brian Carlstrom2b7cdf42011-10-13 11:18:28 -0700160
Ian Rogersafd9acc2014-06-17 08:21:54 -0700161define create-core-oat-target-rules
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700162 core_compile_options :=
163 core_image_name :=
164 core_oat_name :=
165 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -0700166 core_pic_infix :=
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000167 core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700168
Nicolas Geoffray5d672a62014-12-04 14:39:31 +0000169 # With the optimizing compiler, we want to rerun dex2oat whenever there is
170 # a dex2oat change to catch regressions early.
171 ifeq ($(ART_USE_OPTIMIZING_COMPILER), true)
172 core_dex2oat_dependency := $(DEX2OAT)
Nicolas Geoffrayc9338b92014-12-03 13:36:10 +0000173 endif
Nicolas Geoffray5d672a62014-12-04 14:39:31 +0000174
Nicolas Geoffray6427df12014-12-17 12:34:15 +0000175 ifeq ($(1),default)
176 core_compile_options += --compiler-backend=Quick
177 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700178 ifeq ($(1),optimizing)
Serban Constantinescu010cf912014-12-04 18:12:21 +0000179 core_compile_options += --compiler-backend=Optimizing
180 core_dex2oat_dependency := $(DEX2OAT)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700181 core_infix := -optimizing
182 endif
183 ifeq ($(1),interpreter)
184 core_compile_options += --compiler-filter=interpret-only
185 core_infix := -interpreter
186 endif
Mathieu Chartier3fc1b122015-02-26 10:58:08 -0800187 ifeq ($(1),jit)
188 core_compile_options += --compiler-filter=interpret-only
189 core_infix := -jit
190 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700191 ifeq ($(1),default)
192 # Default has no infix, no compile options.
193 endif
Mathieu Chartier3fc1b122015-02-26 10:58:08 -0800194 ifneq ($(filter-out default interpreter jit optimizing,$(1)),)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700195 # Technically this test is not precise, but hopefully good enough.
Mathieu Chartier3fc1b122015-02-26 10:58:08 -0800196 $$(error found $(1) expected default, interpreter, jit or optimizing)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700197 endif
Andreas Gampec23c9c92014-10-28 14:47:25 -0700198
199 ifeq ($(2),pic)
200 core_compile_options += --compile-pic
201 core_pic_infix := -pic
202 endif
203 ifeq ($(2),no-pic)
204 # No change for non-pic
205 endif
206 ifneq ($(filter-out pic no-pic,$(2)),)
207 #Technically this test is not precise, but hopefully good enough.
208 $$(error found $(2) expected pic or no-pic)
209 endif
210
Andreas Gampe088b16e2014-12-03 21:59:27 -0800211 core_image_name := $($(3)TARGET_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(4)$(CORE_IMG_SUFFIX)
212 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 -0700213
214 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
Andreas Gampec23c9c92014-10-28 14:47:25 -0700215 ifeq ($(3),)
216 ifdef TARGET_2ND_ARCH
Andreas Gampe088b16e2014-12-03 21:59:27 -0800217 $(4)TARGET_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700218 else
Andreas Gampe088b16e2014-12-03 21:59:27 -0800219 $(4)TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700220 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700221 else
Andreas Gampe088b16e2014-12-03 21:59:27 -0800222 $(4)TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700223 endif
Andreas Gampe088b16e2014-12-03 21:59:27 -0800224 $(4)TARGET_CORE_IMG_OUTS += $$(core_image_name)
225 $(4)TARGET_CORE_OAT_OUTS += $$(core_oat_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700226
Andreas Gampe088b16e2014-12-03 21:59:27 -0800227 # If we have a wrapper, make the target phony.
228 ifneq ($(4),)
229.PHONY: $$(core_image_name)
230 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700231$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options)
232$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name)
233$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name)
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000234$$(core_image_name): $$(TARGET_CORE_DEX_FILES) $$(core_dex2oat_dependency)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700235 @echo "target dex2oat: $$@ ($$?)"
236 @mkdir -p $$(dir $$@)
Andreas Gampe088b16e2014-12-03 21:59:27 -0800237 $$(hide) $(4) $$(DEX2OAT)$(5) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
238 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700239 --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(TARGET_CORE_DEX_FILES)) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700240 $$(addprefix --dex-location=,$$(TARGET_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \
241 --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \
Andreas Gampec23c9c92014-10-28 14:47:25 -0700242 --base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) --instruction-set=$$($(3)TARGET_ARCH) \
Ian Rogersd582fa42014-11-05 23:46:43 -0800243 --instruction-set-features=$$($(3)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700244 --android-root=$$(PRODUCT_OUT)/system --include-patch-information \
Nicolas Geoffray130bd1b2014-11-03 16:23:48 +0000245 $$(PRIVATE_CORE_COMPILE_OPTIONS) || (rm $$(PRIVATE_CORE_OAT_NAME); exit 1)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700246
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700247$$(core_oat_name): $$(core_image_name)
Andreas Gampe2fe07922014-04-21 07:50:39 -0700248
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700249 # Clean up locally used variables.
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000250 core_dex2oat_dependency :=
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700251 core_compile_options :=
252 core_image_name :=
253 core_oat_name :=
254 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -0700255 core_pic_infix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700256endef # create-core-oat-target-rules
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700257
Mathieu Chartier3fc1b122015-02-26 10:58:08 -0800258# $(1): compiler - default, optimizing, jit or interpreter.
Andreas Gampe088b16e2014-12-03 21:59:27 -0800259# $(2): wrapper.
260# $(3): dex2oat suffix.
Andreas Gampec23c9c92014-10-28 14:47:25 -0700261define create-core-oat-target-rule-combination
Andreas Gampe088b16e2014-12-03 21:59:27 -0800262 $(call create-core-oat-target-rules,$(1),no-pic,,$(2),$(3))
263 $(call create-core-oat-target-rules,$(1),pic,,$(2),$(3))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700264
265 ifdef TARGET_2ND_ARCH
Andreas Gampe088b16e2014-12-03 21:59:27 -0800266 $(call create-core-oat-target-rules,$(1),no-pic,2ND_,$(2),$(3))
267 $(call create-core-oat-target-rules,$(1),pic,2ND_,$(2),$(3))
Andreas Gampec23c9c92014-10-28 14:47:25 -0700268 endif
269endef
270
Andreas Gampe088b16e2014-12-03 21:59:27 -0800271$(eval $(call create-core-oat-target-rule-combination,default,,))
272$(eval $(call create-core-oat-target-rule-combination,optimizing,,))
273$(eval $(call create-core-oat-target-rule-combination,interpreter,,))
274
275valgrindTARGET_CORE_IMG_OUTS :=
276valgrindTARGET_CORE_OAT_OUTS :=
277$(eval $(call create-core-oat-target-rule-combination,default,valgrind,32))
278$(eval $(call create-core-oat-target-rule-combination,optimizing,valgrind,32))
279$(eval $(call create-core-oat-target-rule-combination,interpreter,valgrind,32))
280
281valgrind-test-art-host-dex2oat-target: $(valgrindTARGET_CORE_IMG_OUTS)
282
283valgrind-test-art-host-dex2oat: valgrind-test-art-host-dex2oat-host valgrind-test-art-host-dex2oat-target