Dvm.mk revision d5c36b9040bd26a81219a7f399513526f9b46324
1# Copyright (C) 2008 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15#
16# Common definitions for host or target builds of libdvm.
17#
18# If you enable or disable optional features here, make sure you do
19# a "clean" build -- not everything depends on Dalvik.h.  (See Android.mk
20# for the exact command.)
21#
22
23
24#
25# Compiler defines.
26#
27LOCAL_CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2 -fno-align-jumps
28LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter -Wc++-compat
29LOCAL_CFLAGS += -DARCH_VARIANT=\"$(dvm_arch_variant)\"
30
31#
32# Optional features.  These may impact the size or performance of the VM.
33#
34
35# Make a debugging version when building the simulator (if not told
36# otherwise) and when explicitly asked.
37dvm_make_debug_vm := false
38ifeq ($(strip $(DEBUG_DALVIK_VM)),)
39  ifeq ($(dvm_simulator),true)
40    dvm_make_debug_vm := true
41  endif
42else
43  dvm_make_debug_vm := $(DEBUG_DALVIK_VM)
44endif
45
46ifeq ($(dvm_make_debug_vm),true)
47  #
48  # "Debug" profile:
49  # - debugger enabled
50  # - profiling enabled
51  # - tracked-reference verification enabled
52  # - allocation limits enabled
53  # - GDB helpers enabled
54  # - LOGV
55  # - assert()
56  #
57  LOCAL_CFLAGS += -DWITH_INSTR_CHECKS
58  LOCAL_CFLAGS += -DWITH_EXTRA_OBJECT_VALIDATION
59  LOCAL_CFLAGS += -DWITH_TRACKREF_CHECKS
60  LOCAL_CFLAGS += -DWITH_EXTRA_GC_CHECKS=1
61  #LOCAL_CFLAGS += -DCHECK_MUTEX
62  #LOCAL_CFLAGS += -DPROFILE_FIELD_ACCESS
63  LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=3
64  # add some extra stuff to make it easier to examine with GDB
65  LOCAL_CFLAGS += -DEASY_GDB
66  # overall config may be for a "release" build, so reconfigure these
67  LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT
68else  # !dvm_make_debug_vm
69  #
70  # "Performance" profile:
71  # - all development features disabled
72  # - compiler optimizations enabled (redundant for "release" builds)
73  # - (debugging and profiling still enabled)
74  #
75  #LOCAL_CFLAGS += -DNDEBUG -DLOG_NDEBUG=1
76  # "-O2" is redundant for device (release) but useful for sim (debug)
77  #LOCAL_CFLAGS += -O2 -Winline
78  #LOCAL_CFLAGS += -DWITH_EXTRA_OBJECT_VALIDATION
79  LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=1
80  # if you want to try with assertions on the device, add:
81  #LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT
82endif  # !dvm_make_debug_vm
83
84# bug hunting: checksum and verify interpreted stack when making JNI calls
85#LOCAL_CFLAGS += -DWITH_JNI_STACK_CHECK
86
87LOCAL_SRC_FILES := \
88	AllocTracker.cpp \
89	Atomic.cpp.arm \
90	AtomicCache.cpp \
91	BitVector.cpp.arm \
92	CheckJni.cpp \
93	Ddm.cpp \
94	Debugger.cpp \
95	DvmDex.cpp \
96	Exception.cpp \
97	Hash.cpp \
98	IndirectRefTable.cpp.arm \
99	Init.cpp \
100	InitRefs.cpp \
101	InlineNative.cpp.arm \
102	Inlines.cpp \
103	Intern.cpp \
104	Jni.cpp \
105	JarFile.cpp \
106	LinearAlloc.cpp \
107	Misc.cpp \
108	Native.cpp \
109	PointerSet.cpp \
110	Profile.cpp \
111	Properties.cpp \
112	RawDexFile.cpp \
113	ReferenceTable.cpp \
114	SignalCatcher.cpp \
115	StdioConverter.cpp \
116	Sync.cpp \
117	Thread.cpp \
118	UtfString.cpp \
119	alloc/Alloc.cpp \
120	alloc/CardTable.cpp \
121	alloc/HeapBitmap.cpp.arm \
122	alloc/HeapDebug.cpp \
123	alloc/Heap.cpp.arm \
124	alloc/DdmHeap.cpp \
125	alloc/Verify.cpp \
126	alloc/Visit.cpp \
127	analysis/CodeVerify.cpp \
128	analysis/DexPrepare.cpp \
129	analysis/DexVerify.cpp \
130	analysis/Liveness.cpp \
131	analysis/Optimize.cpp \
132	analysis/RegisterMap.cpp \
133	analysis/VerifySubs.cpp \
134	analysis/VfyBasicBlock.cpp \
135	hprof/Hprof.cpp \
136	hprof/HprofClass.cpp \
137	hprof/HprofHeap.cpp \
138	hprof/HprofOutput.cpp \
139	hprof/HprofString.cpp \
140	interp/Interp.cpp.arm \
141	interp/Stack.cpp \
142	jdwp/ExpandBuf.cpp \
143	jdwp/JdwpAdb.cpp \
144	jdwp/JdwpConstants.cpp \
145	jdwp/JdwpEvent.cpp \
146	jdwp/JdwpHandler.cpp \
147	jdwp/JdwpMain.cpp \
148	jdwp/JdwpSocket.cpp \
149	mterp/Mterp.cpp.arm \
150	mterp/out/InterpC-portable.c.arm \
151	native/InternalNative.cpp \
152	native/dalvik_bytecode_OpcodeInfo.cpp \
153	native/dalvik_system_DexFile.cpp \
154	native/dalvik_system_VMDebug.cpp \
155	native/dalvik_system_VMRuntime.cpp \
156	native/dalvik_system_VMStack.cpp \
157	native/dalvik_system_Zygote.cpp \
158	native/java_lang_Class.cpp \
159	native/java_lang_Double.cpp \
160	native/java_lang_Float.cpp \
161	native/java_lang_Math.cpp \
162	native/java_lang_Object.cpp \
163	native/java_lang_Runtime.cpp \
164	native/java_lang_String.cpp \
165	native/java_lang_System.cpp \
166	native/java_lang_Throwable.cpp \
167	native/java_lang_VMClassLoader.cpp \
168	native/java_lang_VMThread.cpp \
169	native/java_lang_reflect_AccessibleObject.cpp \
170	native/java_lang_reflect_Array.cpp \
171	native/java_lang_reflect_Constructor.cpp \
172	native/java_lang_reflect_Field.cpp \
173	native/java_lang_reflect_Method.cpp \
174	native/java_lang_reflect_Proxy.cpp \
175	native/java_util_concurrent_atomic_AtomicLong.cpp \
176	native/org_apache_harmony_dalvik_NativeTestTarget.cpp \
177	native/org_apache_harmony_dalvik_ddmc_DdmServer.cpp \
178	native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cpp \
179	native/sun_misc_Unsafe.cpp \
180	oo/AccessCheck.cpp \
181	oo/Array.cpp \
182	oo/Class.cpp \
183	oo/Object.cpp \
184	oo/Resolve.cpp \
185	oo/TypeCheck.cpp \
186	reflect/Annotation.cpp \
187	reflect/Proxy.cpp \
188	reflect/Reflect.cpp \
189	test/AtomicTest.cpp.arm \
190	test/TestHash.cpp \
191	test/TestIndirectRefTable.cpp
192
193WITH_COPYING_GC := $(strip $(WITH_COPYING_GC))
194
195ifeq ($(WITH_COPYING_GC),true)
196  LOCAL_CFLAGS += -DWITH_COPYING_GC
197  LOCAL_SRC_FILES += \
198	alloc/Copying.cpp.arm
199else
200  LOCAL_SRC_FILES += \
201	alloc/HeapSource.cpp \
202	alloc/MarkSweep.cpp.arm
203endif
204
205WITH_JIT := $(strip $(WITH_JIT))
206
207ifeq ($(WITH_JIT),true)
208  LOCAL_CFLAGS += -DWITH_JIT
209  LOCAL_SRC_FILES += \
210	compiler/Compiler.c \
211	compiler/Frontend.c \
212	compiler/Utility.c \
213	compiler/InlineTransformation.c \
214	compiler/IntermediateRep.c \
215	compiler/Dataflow.c \
216	compiler/SSATransformation.c \
217	compiler/Loop.c \
218	compiler/Ralloc.c \
219	interp/Jit.cpp
220endif
221
222LOCAL_C_INCLUDES += \
223	$(JNI_H_INCLUDE) \
224	dalvik \
225	dalvik/vm \
226	external/zlib \
227	libcore/include \
228	$(KERNEL_HEADERS)
229
230ifeq ($(dvm_simulator),true)
231  LOCAL_LDLIBS += -lpthread -ldl
232  ifeq ($(HOST_OS),linux)
233    # need this for clock_gettime() in profiling
234    LOCAL_LDLIBS += -lrt
235  endif
236endif
237
238MTERP_ARCH_KNOWN := false
239
240ifeq ($(dvm_arch),arm)
241  #dvm_arch_variant := armv7-a
242  #LOCAL_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfp
243  LOCAL_CFLAGS += -Werror
244  MTERP_ARCH_KNOWN := true
245  # Select architecture-specific sources (armv5te, armv7-a, etc.)
246  LOCAL_SRC_FILES += \
247		arch/arm/CallOldABI.S \
248		arch/arm/CallEABI.S \
249		arch/arm/HintsEABI.c \
250		mterp/out/InterpC-$(dvm_arch_variant).c.arm \
251		mterp/out/InterpAsm-$(dvm_arch_variant).S
252
253  ifeq ($(WITH_JIT),true)
254    LOCAL_SRC_FILES += \
255		compiler/codegen/RallocUtil.c \
256		compiler/codegen/arm/$(dvm_arch_variant)/Codegen.c \
257		compiler/codegen/arm/$(dvm_arch_variant)/CallingConvention.S \
258		compiler/codegen/arm/Assemble.c \
259		compiler/codegen/arm/ArchUtility.c \
260		compiler/codegen/arm/LocalOptimizations.c \
261		compiler/codegen/arm/GlobalOptimizations.c \
262		compiler/codegen/arm/ArmRallocUtil.c \
263		compiler/template/out/CompilerTemplateAsm-$(dvm_arch_variant).S
264  endif
265endif
266
267ifeq ($(dvm_arch),x86)
268  ifeq ($(dvm_os),linux)
269    MTERP_ARCH_KNOWN := true
270    LOCAL_CFLAGS += -DDVM_JMP_TABLE_MTERP=1
271    LOCAL_SRC_FILES += \
272		arch/$(dvm_arch_variant)/Call386ABI.S \
273		arch/$(dvm_arch_variant)/Hints386ABI.c \
274		mterp/out/InterpC-$(dvm_arch_variant).c \
275		mterp/out/InterpAsm-$(dvm_arch_variant).S
276    ifeq ($(WITH_JIT),true)
277      LOCAL_SRC_FILES += \
278		compiler/codegen/x86/Assemble.c \
279		compiler/codegen/x86/ArchUtility.c \
280		compiler/codegen/x86/ia32/Codegen.c \
281		compiler/codegen/x86/ia32/CallingConvention.S \
282		compiler/template/out/CompilerTemplateAsm-ia32.S
283    endif
284  endif
285endif
286
287ifeq ($(dvm_arch),sh)
288  MTERP_ARCH_KNOWN := true
289  LOCAL_SRC_FILES += \
290		arch/sh/CallSH4ABI.S \
291		arch/generic/Hints.c \
292		mterp/out/InterpC-allstubs.c \
293		mterp/out/InterpAsm-allstubs.S
294endif
295
296ifeq ($(MTERP_ARCH_KNOWN),false)
297  # unknown architecture, try to use FFI
298  LOCAL_C_INCLUDES += external/libffi/$(dvm_os)-$(dvm_arch)
299
300  ifeq ($(dvm_os)-$(dvm_arch),darwin-x86)
301      # OSX includes libffi, so just make the linker aware of it directly.
302      LOCAL_LDLIBS += -lffi
303  else
304      LOCAL_SHARED_LIBRARIES += libffi
305  endif
306
307  LOCAL_SRC_FILES += \
308		arch/generic/Call.c \
309		arch/generic/Hints.c \
310		mterp/out/InterpC-allstubs.c
311
312  # The following symbols are usually defined in the asm file, but
313  # since we don't have an asm file in this case, we instead just
314  # peg them at 0 here, and we add an #ifdef'able define for good
315  # measure, too.
316  LOCAL_CFLAGS += -DdvmAsmInstructionStart=0 -DdvmAsmInstructionEnd=0 \
317	-DdvmAsmSisterStart=0 -DdvmAsmSisterEnd=0 -DDVM_NO_ASM_INTERP=1
318endif
319