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 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 38ifneq ($(strip $(DEBUG_DALVIK_VM)),) 39 dvm_make_debug_vm := $(DEBUG_DALVIK_VM) 40endif 41 42ifeq ($(dvm_make_debug_vm),true) 43 # 44 # "Debug" profile: 45 # - debugger enabled 46 # - profiling enabled 47 # - tracked-reference verification enabled 48 # - allocation limits enabled 49 # - GDB helpers enabled 50 # - LOGV 51 # - assert() 52 # 53 LOCAL_CFLAGS += -DWITH_INSTR_CHECKS 54 LOCAL_CFLAGS += -DWITH_EXTRA_OBJECT_VALIDATION 55 LOCAL_CFLAGS += -DWITH_TRACKREF_CHECKS 56 LOCAL_CFLAGS += -DWITH_EXTRA_GC_CHECKS=1 57 #LOCAL_CFLAGS += -DCHECK_MUTEX 58 LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=3 59 # add some extra stuff to make it easier to examine with GDB 60 LOCAL_CFLAGS += -DEASY_GDB 61 # overall config may be for a "release" build, so reconfigure these 62 LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT 63else # !dvm_make_debug_vm 64 # 65 # "Performance" profile: 66 # - all development features disabled 67 # - compiler optimizations enabled (redundant for "release" builds) 68 # - (debugging and profiling still enabled) 69 # 70 #LOCAL_CFLAGS += -DNDEBUG -DLOG_NDEBUG=1 71 # "-O2" is redundant for device (release) but useful for sim (debug) 72 #LOCAL_CFLAGS += -O2 -Winline 73 #LOCAL_CFLAGS += -DWITH_EXTRA_OBJECT_VALIDATION 74 LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=1 75 # if you want to try with assertions on the device, add: 76 #LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT 77endif # !dvm_make_debug_vm 78 79# bug hunting: checksum and verify interpreted stack when making JNI calls 80#LOCAL_CFLAGS += -DWITH_JNI_STACK_CHECK 81 82LOCAL_SRC_FILES := \ 83 AllocTracker.cpp \ 84 Atomic.cpp.arm \ 85 AtomicCache.cpp \ 86 BitVector.cpp.arm \ 87 CheckJni.cpp \ 88 Ddm.cpp \ 89 Debugger.cpp \ 90 DvmDex.cpp \ 91 Exception.cpp \ 92 Hash.cpp \ 93 IndirectRefTable.cpp.arm \ 94 Init.cpp \ 95 InitRefs.cpp \ 96 InlineNative.cpp.arm \ 97 Inlines.cpp \ 98 Intern.cpp \ 99 Jni.cpp \ 100 JarFile.cpp \ 101 LinearAlloc.cpp \ 102 Misc.cpp \ 103 Native.cpp \ 104 PointerSet.cpp \ 105 Profile.cpp \ 106 RawDexFile.cpp \ 107 ReferenceTable.cpp \ 108 SignalCatcher.cpp \ 109 StdioConverter.cpp \ 110 Sync.cpp \ 111 Thread.cpp \ 112 UtfString.cpp \ 113 alloc/Alloc.cpp \ 114 alloc/CardTable.cpp \ 115 alloc/HeapBitmap.cpp.arm \ 116 alloc/HeapDebug.cpp \ 117 alloc/Heap.cpp.arm \ 118 alloc/DdmHeap.cpp \ 119 alloc/Verify.cpp \ 120 alloc/Visit.cpp \ 121 analysis/CodeVerify.cpp \ 122 analysis/DexPrepare.cpp \ 123 analysis/DexVerify.cpp \ 124 analysis/Liveness.cpp \ 125 analysis/Optimize.cpp \ 126 analysis/RegisterMap.cpp \ 127 analysis/VerifySubs.cpp \ 128 analysis/VfyBasicBlock.cpp \ 129 hprof/Hprof.cpp \ 130 hprof/HprofClass.cpp \ 131 hprof/HprofHeap.cpp \ 132 hprof/HprofOutput.cpp \ 133 hprof/HprofString.cpp \ 134 interp/Interp.cpp.arm \ 135 interp/Stack.cpp \ 136 jdwp/ExpandBuf.cpp \ 137 jdwp/JdwpAdb.cpp \ 138 jdwp/JdwpConstants.cpp \ 139 jdwp/JdwpEvent.cpp \ 140 jdwp/JdwpHandler.cpp \ 141 jdwp/JdwpMain.cpp \ 142 jdwp/JdwpSocket.cpp \ 143 mterp/Mterp.cpp.arm \ 144 mterp/out/InterpC-portable.cpp.arm \ 145 native/InternalNative.cpp \ 146 native/dalvik_bytecode_OpcodeInfo.cpp \ 147 native/dalvik_system_DexFile.cpp \ 148 native/dalvik_system_VMDebug.cpp \ 149 native/dalvik_system_VMRuntime.cpp \ 150 native/dalvik_system_VMStack.cpp \ 151 native/dalvik_system_Zygote.cpp \ 152 native/java_lang_Class.cpp \ 153 native/java_lang_Double.cpp \ 154 native/java_lang_Float.cpp \ 155 native/java_lang_Math.cpp \ 156 native/java_lang_Object.cpp \ 157 native/java_lang_Runtime.cpp \ 158 native/java_lang_String.cpp \ 159 native/java_lang_System.cpp \ 160 native/java_lang_Throwable.cpp \ 161 native/java_lang_VMClassLoader.cpp \ 162 native/java_lang_VMThread.cpp \ 163 native/java_lang_reflect_AccessibleObject.cpp \ 164 native/java_lang_reflect_Array.cpp \ 165 native/java_lang_reflect_Constructor.cpp \ 166 native/java_lang_reflect_Field.cpp \ 167 native/java_lang_reflect_Method.cpp \ 168 native/java_lang_reflect_Proxy.cpp \ 169 native/java_util_concurrent_atomic_AtomicLong.cpp \ 170 native/org_apache_harmony_dalvik_NativeTestTarget.cpp \ 171 native/org_apache_harmony_dalvik_ddmc_DdmServer.cpp \ 172 native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cpp \ 173 native/sun_misc_Unsafe.cpp \ 174 oo/AccessCheck.cpp \ 175 oo/Array.cpp \ 176 oo/Class.cpp \ 177 oo/Object.cpp \ 178 oo/Resolve.cpp \ 179 oo/TypeCheck.cpp \ 180 reflect/Annotation.cpp \ 181 reflect/Proxy.cpp \ 182 reflect/Reflect.cpp \ 183 test/AtomicTest.cpp.arm \ 184 test/TestHash.cpp \ 185 test/TestIndirectRefTable.cpp 186 187# TODO: this is the wrong test, but what's the right one? 188ifeq ($(dvm_arch),arm) 189 LOCAL_SRC_FILES += os/android.cpp 190else 191 LOCAL_SRC_FILES += os/linux.cpp 192endif 193 194WITH_COPYING_GC := $(strip $(WITH_COPYING_GC)) 195 196ifeq ($(WITH_COPYING_GC),true) 197 LOCAL_CFLAGS += -DWITH_COPYING_GC 198 LOCAL_SRC_FILES += \ 199 alloc/Copying.cpp.arm 200else 201 LOCAL_SRC_FILES += \ 202 alloc/HeapSource.cpp \ 203 alloc/MarkSweep.cpp.arm 204endif 205 206WITH_JIT := $(strip $(WITH_JIT)) 207 208ifeq ($(WITH_JIT),true) 209 LOCAL_CFLAGS += -DWITH_JIT 210 LOCAL_SRC_FILES += \ 211 compiler/Compiler.cpp \ 212 compiler/Frontend.cpp \ 213 compiler/Utility.cpp \ 214 compiler/InlineTransformation.cpp \ 215 compiler/IntermediateRep.cpp \ 216 compiler/Dataflow.cpp \ 217 compiler/SSATransformation.cpp \ 218 compiler/Loop.cpp \ 219 compiler/Ralloc.cpp \ 220 interp/Jit.cpp 221endif 222 223LOCAL_C_INCLUDES += \ 224 $(JNI_H_INCLUDE) \ 225 dalvik \ 226 dalvik/vm \ 227 external/zlib \ 228 libcore/include \ 229 230MTERP_ARCH_KNOWN := false 231 232ifeq ($(dvm_arch),arm) 233 #dvm_arch_variant := armv7-a 234 #LOCAL_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfp 235 LOCAL_CFLAGS += -Werror 236 MTERP_ARCH_KNOWN := true 237 # Select architecture-specific sources (armv5te, armv7-a, etc.) 238 LOCAL_SRC_FILES += \ 239 arch/arm/CallOldABI.S \ 240 arch/arm/CallEABI.S \ 241 arch/arm/HintsEABI.cpp \ 242 mterp/out/InterpC-$(dvm_arch_variant).cpp.arm \ 243 mterp/out/InterpAsm-$(dvm_arch_variant).S 244 245 ifeq ($(WITH_JIT),true) 246 LOCAL_SRC_FILES += \ 247 compiler/codegen/RallocUtil.cpp \ 248 compiler/codegen/arm/$(dvm_arch_variant)/Codegen.cpp \ 249 compiler/codegen/arm/$(dvm_arch_variant)/CallingConvention.S \ 250 compiler/codegen/arm/Assemble.cpp \ 251 compiler/codegen/arm/ArchUtility.cpp \ 252 compiler/codegen/arm/LocalOptimizations.cpp \ 253 compiler/codegen/arm/GlobalOptimizations.cpp \ 254 compiler/codegen/arm/ArmRallocUtil.cpp \ 255 compiler/template/out/CompilerTemplateAsm-$(dvm_arch_variant).S 256 endif 257endif 258 259ifeq ($(dvm_arch),x86) 260 ifeq ($(dvm_os),linux) 261 MTERP_ARCH_KNOWN := true 262 LOCAL_CFLAGS += -DDVM_JMP_TABLE_MTERP=1 263 LOCAL_SRC_FILES += \ 264 arch/$(dvm_arch_variant)/Call386ABI.S \ 265 arch/$(dvm_arch_variant)/Hints386ABI.cpp \ 266 mterp/out/InterpC-$(dvm_arch_variant).cpp \ 267 mterp/out/InterpAsm-$(dvm_arch_variant).S 268 ifeq ($(WITH_JIT),true) 269 LOCAL_SRC_FILES += \ 270 compiler/codegen/x86/Assemble.cpp \ 271 compiler/codegen/x86/ArchUtility.cpp \ 272 compiler/codegen/x86/ia32/Codegen.cpp \ 273 compiler/codegen/x86/ia32/CallingConvention.S \ 274 compiler/template/out/CompilerTemplateAsm-ia32.S 275 endif 276 endif 277endif 278 279ifeq ($(dvm_arch),sh) 280 MTERP_ARCH_KNOWN := true 281 LOCAL_SRC_FILES += \ 282 arch/sh/CallSH4ABI.S \ 283 arch/generic/Hints.cpp \ 284 mterp/out/InterpC-allstubs.cpp \ 285 mterp/out/InterpAsm-allstubs.S 286endif 287 288ifeq ($(MTERP_ARCH_KNOWN),false) 289 # unknown architecture, try to use FFI 290 LOCAL_C_INCLUDES += external/libffi/$(dvm_os)-$(dvm_arch) 291 292 ifeq ($(dvm_os)-$(dvm_arch),darwin-x86) 293 # OSX includes libffi, so just make the linker aware of it directly. 294 LOCAL_LDLIBS += -lffi 295 else 296 LOCAL_SHARED_LIBRARIES += libffi 297 endif 298 299 LOCAL_SRC_FILES += \ 300 arch/generic/Call.cpp \ 301 arch/generic/Hints.cpp \ 302 mterp/out/InterpC-allstubs.cpp 303 304 # The following symbols are usually defined in the asm file, but 305 # since we don't have an asm file in this case, we instead just 306 # peg them at 0 here, and we add an #ifdef'able define for good 307 # measure, too. 308 LOCAL_CFLAGS += -DdvmAsmInstructionStart=0 -DdvmAsmInstructionEnd=0 \ 309 -DdvmAsmSisterStart=0 -DdvmAsmSisterEnd=0 -DDVM_NO_ASM_INTERP=1 310endif 311