blob: 9fe38078d2b65bd939ebc102c16fe82aacba389f [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
Nicolas Geoffray1db132d2014-03-26 10:56:24 +000026# Use dex2oat debug version for better error reporting
Andreas Gampec23c9c92014-10-28 14:47:25 -070027# $(1): compiler - default, optimizing or interpreter.
28# $(2): pic/no-pic
29# $(3): 2ND_ or undefined, 2ND_ for 32-bit host builds.
Alex Light1ef4ce82014-08-27 11:13:47 -070030# NB depending on HOST_CORE_DEX_LOCATIONS so we are sure to have the dex files in frameworks for
31# run-test --no-image
Ian Rogersafd9acc2014-06-17 08:21:54 -070032define create-core-oat-host-rules
Andreas Gampe63fc30e2014-10-24 21:58:16 -070033 core_compile_options :=
34 core_image_name :=
35 core_oat_name :=
36 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -070037 core_pic_infix :=
Nicolas Geoffraya136ab52014-10-31 10:48:25 +000038 core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070039
40 ifeq ($(1),optimizing)
Nicolas Geoffraya136ab52014-10-31 10:48:25 +000041 core_compile_options += --compiler-backend=Optimizing
42 # With the optimizing compiler, we want to rerun dex2oat whenever there is
43 # a dex2oat change to catch regressions early.
44 core_dex2oat_dependency := $(DEX2OAT)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070045 core_infix := -optimizing
46 endif
47 ifeq ($(1),interpreter)
48 core_compile_options += --compiler-filter=interpret-only
49 core_infix := -interpreter
50 endif
51 ifeq ($(1),default)
52 # Default has no infix, no compile options.
53 endif
54 ifneq ($(filter-out default interpreter optimizing,$(1)),)
55 #Technically this test is not precise, but hopefully good enough.
56 $$(error found $(1) expected default, interpreter or optimizing)
57 endif
Andreas Gampec23c9c92014-10-28 14:47:25 -070058
59 ifeq ($(2),pic)
60 core_compile_options += --compile-pic
61 core_pic_infix := -pic
62 endif
63 ifeq ($(2),no-pic)
64 # No change for non-pic
65 endif
66 ifneq ($(filter-out pic no-pic,$(2)),)
67 # Technically this test is not precise, but hopefully good enough.
68 $$(error found $(2) expected pic or no-pic)
69 endif
70
71 core_image_name := $($(3)HOST_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(CORE_IMG_SUFFIX)
72 core_oat_name := $($(3)HOST_CORE_OAT_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(CORE_OAT_SUFFIX)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070073
74 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
Andreas Gampec23c9c92014-10-28 14:47:25 -070075 ifeq ($(3),)
76 HOST_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070077 else
Andreas Gampec23c9c92014-10-28 14:47:25 -070078 HOST_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070079 endif
80 HOST_CORE_IMG_OUTS += $$(core_image_name)
81 HOST_CORE_OAT_OUTS += $$(core_oat_name)
82
83$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options)
84$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name)
85$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name)
Nicolas Geoffraya136ab52014-10-31 10:48:25 +000086$$(core_image_name): $$(HOST_CORE_DEX_LOCATIONS) $$(core_dex2oat_dependency)
Ian Rogersafd9acc2014-06-17 08:21:54 -070087 @echo "host dex2oat: $$@ ($$?)"
88 @mkdir -p $$(dir $$@)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070089 $$(hide) $$(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
Ian Rogersafd9acc2014-06-17 08:21:54 -070090 --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(HOST_CORE_DEX_FILES)) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -070091 $$(addprefix --dex-location=,$$(HOST_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \
92 --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \
Andreas Gampec23c9c92014-10-28 14:47:25 -070093 --base=$$(LIBART_IMG_HOST_BASE_ADDRESS) --instruction-set=$$($(3)ART_HOST_ARCH) \
94 --instruction-set-features=$$($(3)HOST_INSTRUCTION_SET_FEATURES) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -070095 --host --android-root=$$(HOST_OUT) --include-patch-information \
96 $$(PRIVATE_CORE_COMPILE_OPTIONS)
Brian Carlstrom27ec9612011-09-19 20:20:38 -070097
Andreas Gampe63fc30e2014-10-24 21:58:16 -070098$$(core_oat_name): $$(core_image_name)
Ian Rogersafd9acc2014-06-17 08:21:54 -070099
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700100 # Clean up locally used variables.
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000101 core_dex2oat_dependency :=
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700102 core_compile_options :=
103 core_image_name :=
104 core_oat_name :=
105 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -0700106 core_pic_infix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700107endef # create-core-oat-host-rules
108
Andreas Gampec23c9c92014-10-28 14:47:25 -0700109# $(1): compiler - default, optimizing or interpreter.
110define create-core-oat-host-rule-combination
111 $(call create-core-oat-host-rules,$(1),no-pic,)
112 $(call create-core-oat-host-rules,$(1),pic,)
113
114 ifneq ($(HOST_PREFER_32_BIT),true)
115 $(call create-core-oat-host-rules,$(1),no-pic,2ND_)
116 $(call create-core-oat-host-rules,$(1),pic,2ND_)
117 endif
118endef
119
120$(eval $(call create-core-oat-host-rule-combination,default))
121$(eval $(call create-core-oat-host-rule-combination,optimizing))
122$(eval $(call create-core-oat-host-rule-combination,interpreter))
123
Brian Carlstrom2b7cdf42011-10-13 11:18:28 -0700124
Ian Rogersafd9acc2014-06-17 08:21:54 -0700125define create-core-oat-target-rules
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700126 core_compile_options :=
127 core_image_name :=
128 core_oat_name :=
129 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -0700130 core_pic_infix :=
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000131 core_dex2oat_dependency := $(DEX2OAT_DEPENDENCY)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700132
133 ifeq ($(1),optimizing)
Nicolas Geoffray08d5e282014-11-03 14:39:21 +0000134 ifeq ($($(3)TARGET_ARCH),arm64)
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000135 # TODO: Enable image generation on arm64 once the backend
136 # is on par with other architectures.
137 core_compile_options += --compiler-backend=Quick
138 else
139 core_compile_options += --compiler-backend=Optimizing
140 # With the optimizing compiler, we want to rerun dex2oat whenever there is
141 # a dex2oat change to catch regressions early.
142 core_dex2oat_dependency := $(DEX2OAT)
143 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700144 core_infix := -optimizing
145 endif
146 ifeq ($(1),interpreter)
147 core_compile_options += --compiler-filter=interpret-only
148 core_infix := -interpreter
149 endif
150 ifeq ($(1),default)
151 # Default has no infix, no compile options.
152 endif
153 ifneq ($(filter-out default interpreter optimizing,$(1)),)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700154 # Technically this test is not precise, but hopefully good enough.
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700155 $$(error found $(1) expected default, interpreter or optimizing)
156 endif
Andreas Gampec23c9c92014-10-28 14:47:25 -0700157
158 ifeq ($(2),pic)
159 core_compile_options += --compile-pic
160 core_pic_infix := -pic
161 endif
162 ifeq ($(2),no-pic)
163 # No change for non-pic
164 endif
165 ifneq ($(filter-out pic no-pic,$(2)),)
166 #Technically this test is not precise, but hopefully good enough.
167 $$(error found $(2) expected pic or no-pic)
168 endif
169
170 core_image_name := $($(3)TARGET_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(CORE_IMG_SUFFIX)
171 core_oat_name := $($(3)TARGET_CORE_OAT_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(CORE_OAT_SUFFIX)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700172
173 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
Andreas Gampec23c9c92014-10-28 14:47:25 -0700174 ifeq ($(3),)
175 ifdef TARGET_2ND_ARCH
176 TARGET_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
177 else
178 TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
179 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700180 else
Andreas Gampec23c9c92014-10-28 14:47:25 -0700181 TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700182 endif
183 TARGET_CORE_IMG_OUTS += $$(core_image_name)
184 TARGET_CORE_OAT_OUTS += $$(core_oat_name)
185
186$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options)
187$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name)
188$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name)
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000189$$(core_image_name): $$(TARGET_CORE_DEX_FILES) $$(core_dex2oat_dependency)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700190 @echo "target dex2oat: $$@ ($$?)"
191 @mkdir -p $$(dir $$@)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700192 $$(hide) $$(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_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) \
Andreas Gampec23c9c92014-10-28 14:47:25 -0700196 --base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) --instruction-set=$$($(3)TARGET_ARCH) \
197 --instruction-set-features=$$($(3)TARGET_INSTRUCTION_SET_FEATURES) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700198 --android-root=$$(PRODUCT_OUT)/system --include-patch-information \
Nicolas Geoffray130bd1b2014-11-03 16:23:48 +0000199 $$(PRIVATE_CORE_COMPILE_OPTIONS) || (rm $$(PRIVATE_CORE_OAT_NAME); exit 1)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700200
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700201$$(core_oat_name): $$(core_image_name)
Andreas Gampe2fe07922014-04-21 07:50:39 -0700202
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700203 # Clean up locally used variables.
Nicolas Geoffraya136ab52014-10-31 10:48:25 +0000204 core_dex2oat_dependency :=
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700205 core_compile_options :=
206 core_image_name :=
207 core_oat_name :=
208 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -0700209 core_pic_infix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700210endef # create-core-oat-target-rules
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700211
Andreas Gampec23c9c92014-10-28 14:47:25 -0700212# $(1): compiler - default, optimizing or interpreter.
213define create-core-oat-target-rule-combination
214 $(call create-core-oat-target-rules,$(1),no-pic,)
215 $(call create-core-oat-target-rules,$(1),pic,)
216
217 ifdef TARGET_2ND_ARCH
218 $(call create-core-oat-target-rules,$(1),no-pic,2ND_)
219 $(call create-core-oat-target-rules,$(1),pic,2ND_)
220 endif
221endef
222
223$(eval $(call create-core-oat-target-rule-combination,default))
224$(eval $(call create-core-oat-target-rule-combination,optimizing))
225$(eval $(call create-core-oat-target-rule-combination,interpreter))