• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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	debug/elf_debug_writer.cc \
24	dex/dex_to_dex_compiler.cc \
25	dex/verified_method.cc \
26	dex/verification_results.cc \
27	dex/quick_compiler_callbacks.cc \
28	dex/quick/dex_file_method_inliner.cc \
29	dex/quick/dex_file_to_method_inliner_map.cc \
30	driver/compiled_method_storage.cc \
31	driver/compiler_driver.cc \
32	driver/compiler_options.cc \
33	driver/dex_compilation_unit.cc \
34	linker/buffered_output_stream.cc \
35	linker/file_output_stream.cc \
36	linker/multi_oat_relative_patcher.cc \
37	linker/output_stream.cc \
38	linker/vector_output_stream.cc \
39	linker/relative_patcher.cc \
40	jit/jit_compiler.cc \
41	jni/quick/calling_convention.cc \
42	jni/quick/jni_compiler.cc \
43	optimizing/block_builder.cc \
44	optimizing/bounds_check_elimination.cc \
45	optimizing/builder.cc \
46	optimizing/code_generator.cc \
47	optimizing/code_generator_utils.cc \
48	optimizing/constant_folding.cc \
49	optimizing/dead_code_elimination.cc \
50	optimizing/dex_cache_array_fixups_arm.cc \
51	optimizing/graph_checker.cc \
52	optimizing/graph_visualizer.cc \
53	optimizing/gvn.cc \
54	optimizing/induction_var_analysis.cc \
55	optimizing/induction_var_range.cc \
56	optimizing/inliner.cc \
57	optimizing/instruction_builder.cc \
58	optimizing/instruction_simplifier.cc \
59	optimizing/intrinsics.cc \
60	optimizing/licm.cc \
61	optimizing/load_store_elimination.cc \
62	optimizing/locations.cc \
63	optimizing/nodes.cc \
64	optimizing/nodes_arm64.cc \
65	optimizing/optimization.cc \
66	optimizing/optimizing_compiler.cc \
67	optimizing/parallel_move_resolver.cc \
68	optimizing/prepare_for_register_allocation.cc \
69	optimizing/reference_type_propagation.cc \
70	optimizing/register_allocator.cc \
71	optimizing/select_generator.cc \
72	optimizing/sharpening.cc \
73	optimizing/side_effects_analysis.cc \
74	optimizing/ssa_builder.cc \
75	optimizing/ssa_liveness_analysis.cc \
76	optimizing/ssa_phi_elimination.cc \
77	optimizing/stack_map_stream.cc \
78	trampolines/trampoline_compiler.cc \
79	utils/assembler.cc \
80	utils/swap_space.cc \
81	compiler.cc \
82	elf_writer.cc \
83	elf_writer_quick.cc \
84	image_writer.cc \
85	oat_writer.cc
86
87LIBART_COMPILER_SRC_FILES_arm := \
88	jni/quick/arm/calling_convention_arm.cc \
89	linker/arm/relative_patcher_arm_base.cc \
90	linker/arm/relative_patcher_thumb2.cc \
91	optimizing/code_generator_arm.cc \
92	optimizing/intrinsics_arm.cc \
93	utils/arm/assembler_arm.cc \
94	utils/arm/assembler_arm32.cc \
95	utils/arm/assembler_thumb2.cc \
96	utils/arm/managed_register_arm.cc \
97
98# TODO We should really separate out those files that are actually needed for both variants of an
99# architecture into its own category. Currently we just include all of the 32bit variant in the
100# 64bit variant. It also might be good to allow one to compile only the 64bit variant without the
101# 32bit one.
102LIBART_COMPILER_SRC_FILES_arm64 := \
103    $(LIBART_COMPILER_SRC_FILES_arm) \
104	jni/quick/arm64/calling_convention_arm64.cc \
105	linker/arm64/relative_patcher_arm64.cc \
106	optimizing/code_generator_arm64.cc \
107	optimizing/instruction_simplifier_arm.cc \
108	optimizing/instruction_simplifier_arm64.cc \
109	optimizing/instruction_simplifier_shared.cc \
110	optimizing/intrinsics_arm64.cc \
111	utils/arm64/assembler_arm64.cc \
112	utils/arm64/managed_register_arm64.cc \
113
114LIBART_COMPILER_SRC_FILES_mips := \
115	jni/quick/mips/calling_convention_mips.cc \
116	optimizing/code_generator_mips.cc \
117	optimizing/intrinsics_mips.cc \
118	utils/mips/assembler_mips.cc \
119	utils/mips/managed_register_mips.cc \
120
121LIBART_COMPILER_SRC_FILES_mips64 := \
122    $(LIBART_COMPILER_SRC_FILES_mips) \
123	jni/quick/mips64/calling_convention_mips64.cc \
124	optimizing/code_generator_mips64.cc \
125	optimizing/intrinsics_mips64.cc \
126	utils/mips64/assembler_mips64.cc \
127	utils/mips64/managed_register_mips64.cc \
128
129
130LIBART_COMPILER_SRC_FILES_x86 := \
131	jni/quick/x86/calling_convention_x86.cc \
132	linker/x86/relative_patcher_x86.cc \
133	linker/x86/relative_patcher_x86_base.cc \
134	optimizing/code_generator_x86.cc \
135	optimizing/intrinsics_x86.cc \
136	optimizing/pc_relative_fixups_x86.cc \
137	utils/x86/assembler_x86.cc \
138	utils/x86/managed_register_x86.cc \
139
140LIBART_COMPILER_SRC_FILES_x86_64 := \
141    $(LIBART_COMPILER_SRC_FILES_x86) \
142	jni/quick/x86_64/calling_convention_x86_64.cc \
143	linker/x86_64/relative_patcher_x86_64.cc \
144	optimizing/intrinsics_x86_64.cc \
145	optimizing/code_generator_x86_64.cc \
146	utils/x86_64/assembler_x86_64.cc \
147	utils/x86_64/managed_register_x86_64.cc \
148
149
150LIBART_COMPILER_CFLAGS :=
151
152LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES := \
153  compiled_method.h \
154  dex/compiler_enums.h \
155  dex/dex_to_dex_compiler.h \
156  driver/compiler_driver.h \
157  driver/compiler_options.h \
158  image_writer.h \
159  optimizing/locations.h
160
161LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_arm := \
162  utils/arm/constants_arm.h
163
164LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_arm64 := \
165  $(LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_arm)
166
167LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_mips := \
168  utils/mips/assembler_mips.h
169
170LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_mips64 := \
171  $(LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_mips) \
172  utils/mips64/assembler_mips64.h
173
174LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_x86 :=
175LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_x86_64 := \
176  $(LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_x86)
177
178# $(1): target or host
179# $(2): ndebug or debug
180# $(3): static or shared (empty means shared, applies only for host)
181define build-libart-compiler
182  ifneq ($(1),target)
183    ifneq ($(1),host)
184      $$(error expected target or host for argument 1, received $(1))
185    endif
186  endif
187  ifneq ($(2),ndebug)
188    ifneq ($(2),debug)
189      $$(error expected ndebug or debug for argument 2, received $(2))
190    endif
191  endif
192
193  art_target_or_host := $(1)
194  art_ndebug_or_debug := $(2)
195  art_static_or_shared := $(3)
196
197  include $(CLEAR_VARS)
198  ifeq ($$(art_target_or_host),host)
199    LOCAL_IS_HOST_MODULE := true
200    art_codegen_targets := $(ART_HOST_CODEGEN_ARCHS)
201  else
202    art_codegen_targets := $(ART_TARGET_CODEGEN_ARCHS)
203  endif
204  LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
205  ifeq ($$(art_ndebug_or_debug),ndebug)
206    LOCAL_MODULE := libart-compiler
207    ifeq ($$(art_static_or_shared), static)
208      LOCAL_STATIC_LIBRARIES += libart liblz4 liblzma
209    else
210      LOCAL_SHARED_LIBRARIES += libart liblz4 liblzma
211    endif
212    ifeq ($$(art_target_or_host),target)
213      LOCAL_FDO_SUPPORT := true
214    endif
215  else # debug
216    LOCAL_MODULE := libartd-compiler
217    ifeq ($$(art_static_or_shared), static)
218      LOCAL_STATIC_LIBRARIES += libartd liblz4 liblzma
219    else
220      LOCAL_SHARED_LIBRARIES += libartd liblz4 liblzma
221    endif
222  endif
223
224  LOCAL_MODULE_TAGS := optional
225  ifeq ($$(art_static_or_shared), static)
226    LOCAL_MODULE_CLASS := STATIC_LIBRARIES
227  else
228    LOCAL_MODULE_CLASS := SHARED_LIBRARIES
229  endif
230
231  # Sort removes duplicates.
232  LOCAL_SRC_FILES := $$(LIBART_COMPILER_SRC_FILES) \
233    $$(sort $$(foreach arch,$$(art_codegen_targets), $$(LIBART_COMPILER_SRC_FILES_$$(arch))))
234
235  GENERATED_SRC_DIR := $$(call local-generated-sources-dir)
236  ENUM_OPERATOR_OUT_CC_FILES := $$(patsubst %.h,%_operator_out.cc,\
237                                $$(LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES) \
238                                $$(sort $$(foreach arch,$$(art_codegen_targets), $$(LIBART_COMPILER_ENUM_OPERATOR_OUT_HEADER_FILES_$$(arch)))))
239  ENUM_OPERATOR_OUT_GEN := $$(addprefix $$(GENERATED_SRC_DIR)/,$$(ENUM_OPERATOR_OUT_CC_FILES))
240
241$$(ENUM_OPERATOR_OUT_GEN): art/tools/generate-operator-out.py
242$$(ENUM_OPERATOR_OUT_GEN): PRIVATE_CUSTOM_TOOL = art/tools/generate-operator-out.py $(LOCAL_PATH) $$< > $$@
243$$(ENUM_OPERATOR_OUT_GEN): $$(GENERATED_SRC_DIR)/%_operator_out.cc : $(LOCAL_PATH)/%.h
244	$$(transform-generated-source)
245
246  LOCAL_GENERATED_SOURCES += $$(ENUM_OPERATOR_OUT_GEN)
247
248  LOCAL_CFLAGS := $$(LIBART_COMPILER_CFLAGS)
249  ifeq ($$(art_target_or_host),target)
250    $(call set-target-local-clang-vars)
251    $(call set-target-local-cflags-vars,$(2))
252  else # host
253    LOCAL_CLANG := $(ART_HOST_CLANG)
254    LOCAL_CFLAGS += $(ART_HOST_CFLAGS)
255    LOCAL_ASFLAGS += $(ART_HOST_ASFLAGS)
256    LOCAL_LDLIBS := $(ART_HOST_LDLIBS)
257    ifeq ($$(art_static_or_shared),static)
258      LOCAL_LDFLAGS += -static
259    endif
260    ifeq ($$(art_ndebug_or_debug),debug)
261      LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
262    else
263      LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS)
264    endif
265  endif
266
267  LOCAL_C_INCLUDES += $(ART_C_INCLUDES) art/runtime art/disassembler
268
269  ifeq ($$(art_target_or_host),host)
270    # For compiler driver TLS.
271    LOCAL_LDLIBS += -lpthread
272  endif
273  LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
274  LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
275  # Vixl assembly support for ARM64 targets.
276  ifeq ($$(art_ndebug_or_debug),debug)
277    ifeq ($$(art_static_or_shared), static)
278      LOCAL_WHOLESTATIC_LIBRARIES += libvixl
279    else
280      LOCAL_SHARED_LIBRARIES += libvixl
281    endif
282  else
283    ifeq ($$(art_static_or_shared), static)
284      LOCAL_WHOLE_STATIC_LIBRARIES += libvixl
285    else
286      LOCAL_SHARED_LIBRARIES += libvixl
287    endif
288  endif
289
290  LOCAL_NATIVE_COVERAGE := $(ART_COVERAGE)
291
292  ifeq ($$(art_target_or_host),target)
293    # For atrace.
294    LOCAL_SHARED_LIBRARIES += libcutils
295    include $(BUILD_SHARED_LIBRARY)
296  else # host
297    LOCAL_MULTILIB := both
298    ifeq ($$(art_static_or_shared), static)
299      include $(BUILD_HOST_STATIC_LIBRARY)
300    else
301      include $(BUILD_HOST_SHARED_LIBRARY)
302    endif
303  endif
304
305  # Clear locally defined variables.
306  art_target_or_host :=
307  art_ndebug_or_debug :=
308  art_static_or_shared :=
309  art_codegen_targets :=
310endef
311
312# We always build dex2oat and dependencies, even if the host build is otherwise disabled, since they are used to cross compile for the target.
313ifeq ($(ART_BUILD_HOST_NDEBUG),true)
314  $(eval $(call build-libart-compiler,host,ndebug))
315  ifeq ($(ART_BUILD_HOST_STATIC),true)
316    $(eval $(call build-libart-compiler,host,ndebug,static))
317  endif
318endif
319ifeq ($(ART_BUILD_HOST_DEBUG),true)
320  $(eval $(call build-libart-compiler,host,debug))
321  ifeq ($(ART_BUILD_HOST_STATIC),true)
322    $(eval $(call build-libart-compiler,host,debug,static))
323  endif
324endif
325ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
326  $(eval $(call build-libart-compiler,target,ndebug))
327endif
328ifeq ($(ART_BUILD_TARGET_DEBUG),true)
329  $(eval $(call build-libart-compiler,target,debug))
330endif
331