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