1#
2# Copyright (C) 2012 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
17LOCAL_PATH := $(call my-dir)
18
19include art/build/Android.common_build.mk
20
21LIBART_COMPILER_SRC_FILES := \
22	compiled_method.cc \
23	dex/global_value_numbering.cc \
24	dex/gvn_dead_code_elimination.cc \
25	dex/local_value_numbering.cc \
26	dex/type_inference.cc \
27	dex/quick/arm/assemble_arm.cc \
28	dex/quick/arm/call_arm.cc \
29	dex/quick/arm/fp_arm.cc \
30	dex/quick/arm/int_arm.cc \
31	dex/quick/arm/target_arm.cc \
32	dex/quick/arm/utility_arm.cc \
33	dex/quick/arm64/assemble_arm64.cc \
34	dex/quick/arm64/call_arm64.cc \
35	dex/quick/arm64/fp_arm64.cc \
36	dex/quick/arm64/int_arm64.cc \
37	dex/quick/arm64/target_arm64.cc \
38	dex/quick/arm64/utility_arm64.cc \
39	dex/quick/codegen_util.cc \
40	dex/quick/dex_file_method_inliner.cc \
41	dex/quick/dex_file_to_method_inliner_map.cc \
42	dex/quick/gen_common.cc \
43	dex/quick/gen_invoke.cc \
44	dex/quick/gen_loadstore.cc \
45	dex/quick/lazy_debug_frame_opcode_writer.cc \
46	dex/quick/local_optimizations.cc \
47	dex/quick/mips/assemble_mips.cc \
48	dex/quick/mips/call_mips.cc \
49	dex/quick/mips/fp_mips.cc \
50	dex/quick/mips/int_mips.cc \
51	dex/quick/mips/target_mips.cc \
52	dex/quick/mips/utility_mips.cc \
53	dex/quick/mir_to_lir.cc \
54	dex/quick/quick_compiler.cc \
55	dex/quick/ralloc_util.cc \
56	dex/quick/resource_mask.cc \
57	dex/quick/x86/assemble_x86.cc \
58	dex/quick/x86/call_x86.cc \
59	dex/quick/x86/fp_x86.cc \
60	dex/quick/x86/int_x86.cc \
61	dex/quick/x86/target_x86.cc \
62	dex/quick/x86/utility_x86.cc \
63	dex/dex_to_dex_compiler.cc \
64	dex/bb_optimizations.cc \
65	dex/compiler_ir.cc \
66	dex/mir_analysis.cc \
67	dex/mir_dataflow.cc \
68	dex/mir_field_info.cc \
69	dex/mir_graph.cc \
70	dex/mir_method_info.cc \
71	dex/mir_optimization.cc \
72	dex/post_opt_passes.cc \
73	dex/pass_driver_me_opts.cc \
74	dex/pass_driver_me_post_opt.cc \
75	dex/pass_manager.cc \
76	dex/ssa_transformation.cc \
77	dex/verified_method.cc \
78	dex/verification_results.cc \
79	dex/vreg_analysis.cc \
80	dex/quick_compiler_callbacks.cc \
81	driver/compiler_driver.cc \
82	driver/compiler_options.cc \
83	driver/dex_compilation_unit.cc \
84	linker/relative_patcher.cc \
85	linker/arm/relative_patcher_arm_base.cc \
86	linker/arm/relative_patcher_thumb2.cc \
87	linker/arm64/relative_patcher_arm64.cc \
88	linker/x86/relative_patcher_x86_base.cc \
89	linker/x86/relative_patcher_x86.cc \
90	linker/x86_64/relative_patcher_x86_64.cc \
91	jit/jit_compiler.cc \
92	jni/quick/arm/calling_convention_arm.cc \
93	jni/quick/arm64/calling_convention_arm64.cc \
94	jni/quick/mips/calling_convention_mips.cc \
95	jni/quick/mips64/calling_convention_mips64.cc \
96	jni/quick/x86/calling_convention_x86.cc \
97	jni/quick/x86_64/calling_convention_x86_64.cc \
98	jni/quick/calling_convention.cc \
99	jni/quick/jni_compiler.cc \
100	optimizing/boolean_simplifier.cc \
101	optimizing/builder.cc \
102	optimizing/bounds_check_elimination.cc \
103	optimizing/code_generator.cc \
104	optimizing/code_generator_arm.cc \
105	optimizing/code_generator_arm64.cc \
106	optimizing/code_generator_mips64.cc \
107	optimizing/code_generator_x86.cc \
108	optimizing/code_generator_x86_64.cc \
109	optimizing/code_generator_utils.cc \
110	optimizing/constant_folding.cc \
111	optimizing/dead_code_elimination.cc \
112	optimizing/graph_checker.cc \
113	optimizing/graph_visualizer.cc \
114	optimizing/gvn.cc \
115	optimizing/inliner.cc \
116	optimizing/instruction_simplifier.cc \
117	optimizing/intrinsics.cc \
118	optimizing/intrinsics_arm.cc \
119	optimizing/intrinsics_arm64.cc \
120	optimizing/intrinsics_x86.cc \
121	optimizing/intrinsics_x86_64.cc \
122	optimizing/licm.cc \
123	optimizing/locations.cc \
124	optimizing/nodes.cc \
125	optimizing/optimization.cc \
126	optimizing/optimizing_compiler.cc \
127	optimizing/parallel_move_resolver.cc \
128	optimizing/prepare_for_register_allocation.cc \
129	optimizing/primitive_type_propagation.cc \
130	optimizing/reference_type_propagation.cc \
131	optimizing/register_allocator.cc \
132	optimizing/side_effects_analysis.cc \
133	optimizing/ssa_builder.cc \
134	optimizing/ssa_liveness_analysis.cc \
135	optimizing/ssa_phi_elimination.cc \
136	optimizing/stack_map_stream.cc \
137	trampolines/trampoline_compiler.cc \
138	utils/arena_bit_vector.cc \
139	utils/arm/assembler_arm.cc \
140	utils/arm/assembler_arm32.cc \
141	utils/arm/assembler_thumb2.cc \
142	utils/arm/managed_register_arm.cc \
143	utils/arm64/assembler_arm64.cc \
144	utils/arm64/managed_register_arm64.cc \
145	utils/assembler.cc \
146	utils/mips/assembler_mips.cc \
147	utils/mips/managed_register_mips.cc \
148	utils/mips64/assembler_mips64.cc \
149	utils/mips64/managed_register_mips64.cc \
150	utils/x86/assembler_x86.cc \
151	utils/x86/managed_register_x86.cc \
152	utils/x86_64/assembler_x86_64.cc \
153	utils/x86_64/managed_register_x86_64.cc \
154	utils/swap_space.cc \
155	buffered_output_stream.cc \
156	compiler.cc \
157	elf_writer.cc \
158	elf_writer_debug.cc \
159	elf_writer_quick.cc \
160	file_output_stream.cc \
161	image_writer.cc \
162	oat_writer.cc \
163	output_stream.cc \
164	vector_output_stream.cc
165
166LIBART_COMPILER_CFLAGS :=
167
168LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES := \
169  dex/quick/arm/arm_lir.h \
170  dex/quick/arm64/arm64_lir.h \
171  dex/quick/mips/mips_lir.h \
172  dex/quick/resource_mask.h \
173  dex/compiler_enums.h \
174  dex/global_value_numbering.h \
175  dex/pass_me.h \
176  driver/compiler_driver.h \
177  driver/compiler_options.h \
178  image_writer.h \
179  optimizing/locations.h \
180  utils/arm/constants_arm.h
181
182# $(1): target or host
183# $(2): ndebug or debug
184define build-libart-compiler
185  ifneq ($(1),target)
186    ifneq ($(1),host)
187      $$(error expected target or host for argument 1, received $(1))
188    endif
189  endif
190  ifneq ($(2),ndebug)
191    ifneq ($(2),debug)
192      $$(error expected ndebug or debug for argument 2, received $(2))
193    endif
194  endif
195
196  art_target_or_host := $(1)
197  art_ndebug_or_debug := $(2)
198
199  include $(CLEAR_VARS)
200  ifeq ($$(art_target_or_host),host)
201    LOCAL_IS_HOST_MODULE := true
202  endif
203  LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
204  ifeq ($$(art_ndebug_or_debug),ndebug)
205    LOCAL_MODULE := libart-compiler
206    LOCAL_SHARED_LIBRARIES += libart
207    ifeq ($$(art_target_or_host),target)
208      LOCAL_FDO_SUPPORT := true
209    endif
210  else # debug
211    LOCAL_MODULE := libartd-compiler
212    LOCAL_SHARED_LIBRARIES += libartd
213  endif
214
215  LOCAL_MODULE_TAGS := optional
216  LOCAL_MODULE_CLASS := SHARED_LIBRARIES
217
218  LOCAL_SRC_FILES := $$(LIBART_COMPILER_SRC_FILES)
219
220  GENERATED_SRC_DIR := $$(call local-generated-sources-dir)
221  ENUM_OPERATOR_OUT_CC_FILES := $$(patsubst %.h,%_operator_out.cc,$$(LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES))
222  ENUM_OPERATOR_OUT_GEN := $$(addprefix $$(GENERATED_SRC_DIR)/,$$(ENUM_OPERATOR_OUT_CC_FILES))
223
224$$(ENUM_OPERATOR_OUT_GEN): art/tools/generate-operator-out.py
225$$(ENUM_OPERATOR_OUT_GEN): PRIVATE_CUSTOM_TOOL = art/tools/generate-operator-out.py $(LOCAL_PATH) $$< > $$@
226$$(ENUM_OPERATOR_OUT_GEN): $$(GENERATED_SRC_DIR)/%_operator_out.cc : $(LOCAL_PATH)/%.h
227	$$(transform-generated-source)
228
229  LOCAL_GENERATED_SOURCES += $$(ENUM_OPERATOR_OUT_GEN)
230
231  LOCAL_CFLAGS := $$(LIBART_COMPILER_CFLAGS)
232  ifeq ($$(art_target_or_host),target)
233    $(call set-target-local-clang-vars)
234    $(call set-target-local-cflags-vars,$(2))
235  else # host
236    LOCAL_CLANG := $(ART_HOST_CLANG)
237    LOCAL_CFLAGS += $(ART_HOST_CFLAGS)
238    LOCAL_LDLIBS := $(ART_HOST_LDLIBS)
239    ifeq ($$(art_ndebug_or_debug),debug)
240      LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
241    else
242      LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS)
243    endif
244  endif
245
246  LOCAL_C_INCLUDES += $(ART_C_INCLUDES) art/runtime
247
248  ifeq ($$(art_target_or_host),host)
249    # For compiler driver TLS.
250    LOCAL_LDLIBS += -lpthread
251  endif
252  LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
253  LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
254  # Vixl assembly support for ARM64 targets.
255  ifeq ($$(art_ndebug_or_debug),debug)
256    LOCAL_SHARED_LIBRARIES += libvixld
257  else
258    LOCAL_SHARED_LIBRARIES += libvixl
259  endif
260
261  LOCAL_NATIVE_COVERAGE := $(ART_COVERAGE)
262
263  ifeq ($$(art_target_or_host),target)
264    # For atrace.
265    LOCAL_SHARED_LIBRARIES += libcutils
266    include $(BUILD_SHARED_LIBRARY)
267  else # host
268    LOCAL_MULTILIB := both
269    include $(BUILD_HOST_SHARED_LIBRARY)
270  endif
271
272  ifeq ($$(art_target_or_host),target)
273    ifeq ($$(art_ndebug_or_debug),debug)
274      $(TARGET_OUT_EXECUTABLES)/dex2oatd: $$(LOCAL_INSTALLED_MODULE)
275    else
276      $(TARGET_OUT_EXECUTABLES)/dex2oat: $$(LOCAL_INSTALLED_MODULE)
277    endif
278  else # host
279    ifeq ($$(art_ndebug_or_debug),debug)
280      $(HOST_OUT_EXECUTABLES)/dex2oatd: $$(LOCAL_INSTALLED_MODULE)
281    else
282      $(HOST_OUT_EXECUTABLES)/dex2oat: $$(LOCAL_INSTALLED_MODULE)
283    endif
284  endif
285
286endef
287
288# We always build dex2oat and dependencies, even if the host build is otherwise disabled, since they are used to cross compile for the target.
289ifeq ($(ART_BUILD_HOST_NDEBUG),true)
290  $(eval $(call build-libart-compiler,host,ndebug))
291endif
292ifeq ($(ART_BUILD_HOST_DEBUG),true)
293  $(eval $(call build-libart-compiler,host,debug))
294endif
295ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
296  $(eval $(call build-libart-compiler,target,ndebug))
297endif
298ifeq ($(ART_BUILD_TARGET_DEBUG),true)
299  $(eval $(call build-libart-compiler,target,debug))
300endif
301