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/local_value_numbering.cc \
25	dex/quick/arm/assemble_arm.cc \
26	dex/quick/arm/call_arm.cc \
27	dex/quick/arm/fp_arm.cc \
28	dex/quick/arm/int_arm.cc \
29	dex/quick/arm/target_arm.cc \
30	dex/quick/arm/utility_arm.cc \
31	dex/quick/arm64/assemble_arm64.cc \
32	dex/quick/arm64/call_arm64.cc \
33	dex/quick/arm64/fp_arm64.cc \
34	dex/quick/arm64/int_arm64.cc \
35	dex/quick/arm64/target_arm64.cc \
36	dex/quick/arm64/utility_arm64.cc \
37	dex/quick/codegen_util.cc \
38	dex/quick/dex_file_method_inliner.cc \
39	dex/quick/dex_file_to_method_inliner_map.cc \
40	dex/quick/gen_common.cc \
41	dex/quick/gen_invoke.cc \
42	dex/quick/gen_loadstore.cc \
43	dex/quick/local_optimizations.cc \
44	dex/quick/mips/assemble_mips.cc \
45	dex/quick/mips/call_mips.cc \
46	dex/quick/mips/fp_mips.cc \
47	dex/quick/mips/int_mips.cc \
48	dex/quick/mips/target_mips.cc \
49	dex/quick/mips/utility_mips.cc \
50	dex/quick/mir_to_lir.cc \
51	dex/quick/ralloc_util.cc \
52	dex/quick/resource_mask.cc \
53	dex/quick/x86/assemble_x86.cc \
54	dex/quick/x86/call_x86.cc \
55	dex/quick/x86/fp_x86.cc \
56	dex/quick/x86/int_x86.cc \
57	dex/quick/x86/target_x86.cc \
58	dex/quick/x86/utility_x86.cc \
59	dex/dex_to_dex_compiler.cc \
60	dex/mir_dataflow.cc \
61	dex/mir_field_info.cc \
62	dex/mir_method_info.cc \
63	dex/mir_optimization.cc \
64	dex/bb_optimizations.cc \
65	dex/post_opt_passes.cc \
66	dex/pass_driver_me_opts.cc \
67	dex/pass_driver_me_post_opt.cc \
68	dex/frontend.cc \
69	dex/mir_graph.cc \
70	dex/mir_analysis.cc \
71	dex/verified_method.cc \
72	dex/verification_results.cc \
73	dex/vreg_analysis.cc \
74	dex/ssa_transformation.cc \
75	dex/quick_compiler_callbacks.cc \
76	driver/compiler_driver.cc \
77	driver/dex_compilation_unit.cc \
78	jni/quick/arm/calling_convention_arm.cc \
79	jni/quick/arm64/calling_convention_arm64.cc \
80	jni/quick/mips/calling_convention_mips.cc \
81	jni/quick/x86/calling_convention_x86.cc \
82	jni/quick/x86_64/calling_convention_x86_64.cc \
83	jni/quick/calling_convention.cc \
84	jni/quick/jni_compiler.cc \
85	optimizing/builder.cc \
86	optimizing/code_generator.cc \
87	optimizing/code_generator_arm.cc \
88	optimizing/code_generator_x86.cc \
89	optimizing/code_generator_x86_64.cc \
90	optimizing/graph_visualizer.cc \
91	optimizing/locations.cc \
92	optimizing/nodes.cc \
93	optimizing/optimizing_compiler.cc \
94	optimizing/parallel_move_resolver.cc \
95	optimizing/register_allocator.cc \
96	optimizing/ssa_builder.cc \
97	optimizing/ssa_liveness_analysis.cc \
98	optimizing/ssa_phi_elimination.cc \
99	optimizing/ssa_type_propagation.cc \
100	trampolines/trampoline_compiler.cc \
101	utils/arena_allocator.cc \
102	utils/arena_bit_vector.cc \
103	utils/arm/assembler_arm.cc \
104	utils/arm/assembler_arm32.cc \
105	utils/arm/assembler_thumb2.cc \
106	utils/arm/managed_register_arm.cc \
107	utils/arm64/assembler_arm64.cc \
108	utils/arm64/managed_register_arm64.cc \
109	utils/assembler.cc \
110	utils/mips/assembler_mips.cc \
111	utils/mips/managed_register_mips.cc \
112	utils/x86/assembler_x86.cc \
113	utils/x86/managed_register_x86.cc \
114	utils/x86_64/assembler_x86_64.cc \
115	utils/x86_64/managed_register_x86_64.cc \
116	utils/scoped_arena_allocator.cc \
117	utils/swap_space.cc \
118	buffered_output_stream.cc \
119	compilers.cc \
120	compiler.cc \
121	elf_fixup.cc \
122	elf_patcher.cc \
123	elf_stripper.cc \
124	elf_writer.cc \
125	elf_writer_quick.cc \
126	file_output_stream.cc \
127	image_writer.cc \
128	oat_writer.cc \
129	vector_output_stream.cc
130
131ifeq ($(ART_SEA_IR_MODE),true)
132LIBART_COMPILER_SRC_FILES += \
133	sea_ir/frontend.cc \
134	sea_ir/ir/instruction_tools.cc \
135	sea_ir/ir/sea.cc \
136	sea_ir/code_gen/code_gen.cc \
137	sea_ir/code_gen/code_gen_data.cc \
138	sea_ir/types/type_inference.cc \
139	sea_ir/types/type_inference_visitor.cc \
140	sea_ir/debug/dot_gen.cc
141endif
142
143LIBART_COMPILER_CFLAGS :=
144
145ifeq ($(ART_USE_PORTABLE_COMPILER),true)
146LIBART_COMPILER_SRC_FILES += \
147	dex/portable/mir_to_gbc.cc \
148	elf_writer_mclinker.cc \
149	jni/portable/jni_compiler.cc \
150	llvm/compiler_llvm.cc \
151	llvm/gbc_expander.cc \
152	llvm/generated/art_module.cc \
153	llvm/intrinsic_helper.cc \
154	llvm/ir_builder.cc \
155	llvm/llvm_compilation_unit.cc \
156	llvm/md_builder.cc \
157	llvm/runtime_support_builder.cc \
158	llvm/runtime_support_builder_arm.cc \
159	llvm/runtime_support_builder_x86.cc
160LIBART_COMPILER_CFLAGS += -DART_USE_PORTABLE_COMPILER=1
161endif
162
163LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES := \
164	dex/compiler_enums.h
165
166# $(1): target or host
167# $(2): ndebug or debug
168define build-libart-compiler
169  ifneq ($(1),target)
170    ifneq ($(1),host)
171      $$(error expected target or host for argument 1, received $(1))
172    endif
173  endif
174  ifneq ($(2),ndebug)
175    ifneq ($(2),debug)
176      $$(error expected ndebug or debug for argument 2, received $(2))
177    endif
178  endif
179
180  art_target_or_host := $(1)
181  art_ndebug_or_debug := $(2)
182
183  include $(CLEAR_VARS)
184  ifeq ($$(art_target_or_host),host)
185    LOCAL_IS_HOST_MODULE := true
186  endif
187  LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
188  ifeq ($$(art_ndebug_or_debug),ndebug)
189    LOCAL_MODULE := libart-compiler
190    LOCAL_SHARED_LIBRARIES += libart
191    LOCAL_FDO_SUPPORT := true
192  else # debug
193    LOCAL_MODULE := libartd-compiler
194    LOCAL_SHARED_LIBRARIES += libartd
195  endif
196
197  LOCAL_MODULE_TAGS := optional
198  LOCAL_MODULE_CLASS := SHARED_LIBRARIES
199
200  LOCAL_SRC_FILES := $$(LIBART_COMPILER_SRC_FILES)
201
202  GENERATED_SRC_DIR := $$(call local-generated-sources-dir)
203  ENUM_OPERATOR_OUT_CC_FILES := $$(patsubst %.h,%_operator_out.cc,$$(LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES))
204  ENUM_OPERATOR_OUT_GEN := $$(addprefix $$(GENERATED_SRC_DIR)/,$$(ENUM_OPERATOR_OUT_CC_FILES))
205
206$$(ENUM_OPERATOR_OUT_GEN): art/tools/generate-operator-out.py
207$$(ENUM_OPERATOR_OUT_GEN): PRIVATE_CUSTOM_TOOL = art/tools/generate-operator-out.py $(LOCAL_PATH) $$< > $$@
208$$(ENUM_OPERATOR_OUT_GEN): $$(GENERATED_SRC_DIR)/%_operator_out.cc : $(LOCAL_PATH)/%.h
209	$$(transform-generated-source)
210
211  LOCAL_GENERATED_SOURCES += $$(ENUM_OPERATOR_OUT_GEN)
212
213  LOCAL_CFLAGS := $$(LIBART_COMPILER_CFLAGS)
214  include external/libcxx/libcxx.mk
215  ifeq ($$(art_target_or_host),target)
216    $(call set-target-local-clang-vars)
217    $(call set-target-local-cflags-vars,$(2))
218  else # host
219    LOCAL_CLANG := $(ART_HOST_CLANG)
220    LOCAL_CFLAGS += $(ART_HOST_CFLAGS)
221    ifeq ($$(art_ndebug_or_debug),debug)
222      LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
223    else
224      LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS)
225    endif
226  endif
227
228  # TODO: clean up the compilers and remove this.
229  LOCAL_CFLAGS += -Wno-unused-parameter
230
231  ifeq ($(ART_USE_PORTABLE_COMPILER),true)
232    LOCAL_SHARED_LIBRARIES += libLLVM
233    LOCAL_CFLAGS += -DART_USE_PORTABLE_COMPILER=1
234    ifeq ($$(art_target_or_host),target)
235      LOCAL_STATIC_LIBRARIES_arm += libmcldARMInfo libmcldARMTarget
236      LOCAL_STATIC_LIBRARIES_x86 += libmcldX86Info libmcldX86Target
237      LOCAL_STATIC_LIBRARIES_x86_64 += libmcldX86Info libmcldX86Target
238      LOCAL_STATIC_LIBRARIES_mips += libmcldMipsInfo libmcldMipsTarget
239      ifeq ($(TARGET_ARCH),arm64)
240         $$(info TODOAArch64: $$(LOCAL_PATH)/Android.mk Add Arm64 specific MCLinker libraries)
241      endif # TARGET_ARCH != arm64
242      include $(LLVM_DEVICE_BUILD_MK)
243    else # host
244      LOCAL_STATIC_LIBRARIES += libmcldARMInfo libmcldARMTarget
245      LOCAL_STATIC_LIBRARIES += libmcldX86Info libmcldX86Target
246      LOCAL_STATIC_LIBRARIES += libmcldMipsInfo libmcldMipsTarget
247      include $(LLVM_HOST_BUILD_MK)
248    endif
249    LOCAL_STATIC_LIBRARIES += libmcldCore libmcldObject libmcldADT libmcldFragment libmcldTarget libmcldCodeGen libmcldLDVariant libmcldMC libmcldSupport libmcldLD libmcldScript
250    include $(LLVM_GEN_INTRINSICS_MK)
251  endif
252
253  LOCAL_C_INCLUDES += $(ART_C_INCLUDES) art/runtime
254
255  ifeq ($$(art_target_or_host),host)
256    LOCAL_LDLIBS += -ldl -lpthread
257  endif
258  LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
259  LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
260  ifeq ($$(art_target_or_host),target)
261    LOCAL_SHARED_LIBRARIES += libcutils libvixl
262    include $(BUILD_SHARED_LIBRARY)
263  else # host
264    LOCAL_STATIC_LIBRARIES += libcutils libvixl
265    LOCAL_MULTILIB := both
266    include $(BUILD_HOST_SHARED_LIBRARY)
267  endif
268
269  ifeq ($$(art_target_or_host),target)
270    ifeq ($$(art_ndebug_or_debug),debug)
271      $(TARGET_OUT_EXECUTABLES)/dex2oatd: $$(LOCAL_INSTALLED_MODULE)
272    else
273      $(TARGET_OUT_EXECUTABLES)/dex2oat: $$(LOCAL_INSTALLED_MODULE)
274    endif
275  else # host
276    ifeq ($$(art_ndebug_or_debug),debug)
277      $(HOST_OUT_EXECUTABLES)/dex2oatd: $$(LOCAL_INSTALLED_MODULE)
278    else
279      $(HOST_OUT_EXECUTABLES)/dex2oat: $$(LOCAL_INSTALLED_MODULE)
280    endif
281  endif
282
283endef
284
285# We always build dex2oat and dependencies, even if the host build is otherwise disabled, since they are used to cross compile for the target.
286ifeq ($(ART_BUILD_NDEBUG),true)
287  $(eval $(call build-libart-compiler,host,ndebug))
288endif
289ifeq ($(ART_BUILD_DEBUG),true)
290  $(eval $(call build-libart-compiler,host,debug))
291endif
292ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
293  $(eval $(call build-libart-compiler,target,ndebug))
294endif
295ifeq ($(ART_BUILD_TARGET_DEBUG),true)
296  $(eval $(call build-libart-compiler,target,debug))
297endif
298
299# Rule to build /system/lib/libcompiler_rt.a
300# Usually static libraries are not installed on the device.
301ifeq ($(ART_USE_PORTABLE_COMPILER),true)
302ifeq ($(ART_BUILD_TARGET),true)
303# TODO: Move to external/compiler_rt
304$(eval $(call copy-one-file, $(call intermediates-dir-for,STATIC_LIBRARIES,libcompiler_rt,,)/libcompiler_rt.a, $(TARGET_OUT_SHARED_LIBRARIES)/libcompiler_rt.a))
305ifdef TARGET_2ND_ARCH
306$(eval $(call copy-one-file, $(call intermediates-dir-for,STATIC_LIBRARIES,libcompiler_rt,,,t)/libcompiler_rt.a, $(2ND_TARGET_OUT_SHARED_LIBRARIES)/libcompiler_rt.a))
307endif
308
309$(DEX2OAT): $(TARGET_OUT_SHARED_LIBRARIES)/libcompiler_rt.a
310
311endif
312endif
313