• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
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
17########################################################################
18# 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
23
24include art/build/Android.common_build.mk
25
26ifeq ($(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
33# Use dex2oat debug version for better error reporting
34# $(1): compiler - default, optimizing, jit or interpreter.
35# $(2): pic/no-pic
36# $(3): 2ND_ or undefined, 2ND_ for 32-bit host builds.
37# $(4): wrapper, e.g., valgrind.
38# $(5): dex2oat suffix, e.g, valgrind requires 32 right now.
39# NB depending on HOST_CORE_DEX_LOCATIONS so we are sure to have the dex files in frameworks for
40# run-test --no-image
41define create-core-oat-host-rules
42  core_compile_options :=
43  core_image_name :=
44  core_oat_name :=
45  core_infix :=
46  core_pic_infix :=
47  core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY)
48
49  # 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)
53  endif
54
55  ifeq ($(1),default)
56    core_compile_options += --compiler-backend=Quick
57  endif
58  ifeq ($(1),optimizing)
59    core_compile_options += --compiler-backend=Optimizing
60    core_dex2oat_dependency := $(DEX2OAT)
61    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
70  ifneq ($(filter-out default interpreter jit optimizing,$(1)),)
71    #Technically this test is not precise, but hopefully good enough.
72    $$(error found $(1) expected default, interpreter, jit or optimizing)
73  endif
74
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
87  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)
89
90  # Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
91  ifeq ($(3),)
92    $(4)HOST_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
93  else
94    $(4)HOST_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
95  endif
96  $(4)HOST_CORE_IMG_OUTS += $$(core_image_name)
97  $(4)HOST_CORE_OAT_OUTS += $$(core_oat_name)
98
99  # If we have a wrapper, make the target phony.
100  ifneq ($(4),)
101.PHONY: $$(core_image_name)
102  endif
103$$(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)
106$$(core_image_name): $$(HOST_CORE_DEX_LOCATIONS) $$(core_dex2oat_dependency)
107	@echo "host dex2oat: $$@ ($$?)"
108	@mkdir -p $$(dir $$@)
109	$$(hide) $(4) $$(DEX2OAT)$(5) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
110	  --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
111	  --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(HOST_CORE_DEX_FILES)) \
112	  $$(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) \
114	  --base=$$(LIBART_IMG_HOST_BASE_ADDRESS) --instruction-set=$$($(3)ART_HOST_ARCH) \
115	  --instruction-set-features=$$($(3)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES) \
116	  --host --android-root=$$(HOST_OUT) --include-patch-information --generate-debug-info \
117	  $$(PRIVATE_CORE_COMPILE_OPTIONS)
118
119$$(core_oat_name): $$(core_image_name)
120
121  # Clean up locally used variables.
122  core_dex2oat_dependency :=
123  core_compile_options :=
124  core_image_name :=
125  core_oat_name :=
126  core_infix :=
127  core_pic_infix :=
128endef  # create-core-oat-host-rules
129
130# $(1): compiler - default, optimizing, jit or interpreter.
131# $(2): wrapper.
132# $(3): dex2oat suffix.
133define create-core-oat-host-rule-combination
134  $(call create-core-oat-host-rules,$(1),no-pic,,$(2),$(3))
135  $(call create-core-oat-host-rules,$(1),pic,,$(2),$(3))
136
137  ifneq ($(HOST_PREFER_32_BIT),true)
138    $(call create-core-oat-host-rules,$(1),no-pic,2ND_,$(2),$(3))
139    $(call create-core-oat-host-rules,$(1),pic,2ND_,$(2),$(3))
140  endif
141endef
142
143$(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,,))
146
147valgrindHOST_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)
154
155define create-core-oat-target-rules
156  core_compile_options :=
157  core_image_name :=
158  core_oat_name :=
159  core_infix :=
160  core_pic_infix :=
161  core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY)
162
163  # 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)
167  endif
168
169  ifeq ($(1),default)
170    core_compile_options += --compiler-backend=Quick
171  endif
172  ifeq ($(1),optimizing)
173    core_compile_options += --compiler-backend=Optimizing
174    core_dex2oat_dependency := $(DEX2OAT)
175    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
184  ifneq ($(filter-out default interpreter jit optimizing,$(1)),)
185    # Technically this test is not precise, but hopefully good enough.
186    $$(error found $(1) expected default, interpreter, jit or optimizing)
187  endif
188
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
201  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)
203
204  # Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
205  ifeq ($(3),)
206    ifdef TARGET_2ND_ARCH
207      $(4)TARGET_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
208    else
209      $(4)TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
210    endif
211  else
212    $(4)TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
213  endif
214  $(4)TARGET_CORE_IMG_OUTS += $$(core_image_name)
215  $(4)TARGET_CORE_OAT_OUTS += $$(core_oat_name)
216
217  # If we have a wrapper, make the target phony.
218  ifneq ($(4),)
219.PHONY: $$(core_image_name)
220  endif
221$$(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)
224$$(core_image_name): $$(TARGET_CORE_DEX_FILES) $$(core_dex2oat_dependency)
225	@echo "target dex2oat: $$@ ($$?)"
226	@mkdir -p $$(dir $$@)
227	$$(hide) $(4) $$(DEX2OAT)$(5) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
228	  --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
229	  --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(TARGET_CORE_DEX_FILES)) \
230	  $$(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) \
232	  --base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) --instruction-set=$$($(3)TARGET_ARCH) \
233	  --instruction-set-variant=$$($(3)DEX2OAT_TARGET_CPU_VARIANT) \
234	  --instruction-set-features=$$($(3)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
235	  --android-root=$$(PRODUCT_OUT)/system --include-patch-information --generate-debug-info \
236	  $$(PRIVATE_CORE_COMPILE_OPTIONS) || (rm $$(PRIVATE_CORE_OAT_NAME); exit 1)
237
238$$(core_oat_name): $$(core_image_name)
239
240  # Clean up locally used variables.
241  core_dex2oat_dependency :=
242  core_compile_options :=
243  core_image_name :=
244  core_oat_name :=
245  core_infix :=
246  core_pic_infix :=
247endef  # create-core-oat-target-rules
248
249# $(1): compiler - default, optimizing, jit or interpreter.
250# $(2): wrapper.
251# $(3): dex2oat suffix.
252define create-core-oat-target-rule-combination
253  $(call create-core-oat-target-rules,$(1),no-pic,,$(2),$(3))
254  $(call create-core-oat-target-rules,$(1),pic,,$(2),$(3))
255
256  ifdef TARGET_2ND_ARCH
257    $(call create-core-oat-target-rules,$(1),no-pic,2ND_,$(2),$(3))
258    $(call create-core-oat-target-rules,$(1),pic,2ND_,$(2),$(3))
259  endif
260endef
261
262$(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
275