dex_preopt_libart.mk revision 222ebac10c9c0e24c6fdac58787500c5cc30db8a
1#################################### 2# dexpreopt support for ART 3# 4#################################### 5 6# Default to debug version to help find bugs. 7# Set USE_DEX2OAT_DEBUG to false for only building non-debug versions. 8ifeq ($(USE_DEX2OAT_DEBUG),false) 9DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oat$(HOST_EXECUTABLE_SUFFIX) 10else 11DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oatd$(HOST_EXECUTABLE_SUFFIX) 12endif 13 14DEX2OAT_DEPENDENCY += $(DEX2OAT) 15 16# Use the first preloaded-classes file in PRODUCT_COPY_FILES. 17PRELOADED_CLASSES := $(call word-colon,1,$(firstword \ 18 $(filter %system/etc/preloaded-classes,$(PRODUCT_COPY_FILES)))) 19 20# Use the first compiled-classes file in PRODUCT_COPY_FILES. 21COMPILED_CLASSES := $(call word-colon,1,$(firstword \ 22 $(filter %system/etc/compiled-classes,$(PRODUCT_COPY_FILES)))) 23 24# start of image reserved address space 25LIBART_IMG_HOST_BASE_ADDRESS := 0x60000000 26LIBART_IMG_TARGET_BASE_ADDRESS := 0x70000000 27 28define get-product-default-property 29$(strip $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES)))) 30endef 31 32DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms) 33DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx) 34DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms) 35DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx) 36 37ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64)) 38# MIPS specific overrides. 39# For MIPS the ART image is loaded at a lower address. This causes issues 40# with the image overlapping with memory on the host cross-compiling and 41# building the image. We therefore limit the Xmx value. This isn't done 42# via a property as we want the larger Xmx value if we're running on a 43# MIPS device. 44LIBART_IMG_TARGET_BASE_ADDRESS := 0x30000000 45DEX2OAT_XMX := 128m 46endif 47 48######################################################################## 49# The full system boot classpath 50 51# Returns the path to the .odex file 52# $(1): the arch name. 53# $(2): the full path (including file name) of the corresponding .jar or .apk. 54define get-odex-file-path 55$(dir $(2))oat/$(1)/$(basename $(notdir $(2))).odex 56endef 57 58# Returns the path to the image file (such as "/system/framework/<arch>/boot.art" 59# $(1): the arch name (such as "arm") 60# $(2): the image location (such as "/system/framework/boot.art") 61define get-image-file-path 62$(dir $(2))$(1)/$(notdir $(2)) 63endef 64 65# note we use core-libart.jar in place of core.jar for ART. 66LIBART_TARGET_BOOT_JARS := $(patsubst core, core-libart,$(DEXPREOPT_BOOT_JARS_MODULES)) 67LIBART_TARGET_BOOT_DEX_LOCATIONS := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),/$(DEXPREOPT_BOOT_JAR_DIR)/$(jar).jar) 68LIBART_TARGET_BOOT_DEX_FILES := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),$(call intermediates-dir-for,JAVA_LIBRARIES,$(jar),,COMMON)/javalib.jar) 69 70# dex preopt on the bootclasspath produces multiple files. The first dex file 71# is converted into to boot.art (to match the legacy assumption that boot.art 72# exists), and the rest are converted to boot-<name>.art. 73# In addition, each .art file has an associated .oat file. 74LIBART_TARGET_BOOT_ART_EXTRA_FILES := $(foreach jar,$(wordlist 2,999,$(LIBART_TARGET_BOOT_JARS)),boot-$(jar).art boot-$(jar).oat) 75LIBART_TARGET_BOOT_ART_EXTRA_FILES += boot.oat 76 77my_2nd_arch_prefix := 78include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk 79 80ifdef TARGET_2ND_ARCH 81my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) 82include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk 83my_2nd_arch_prefix := 84endif 85 86 87######################################################################## 88# For a single jar or APK 89 90# $(1): the input .jar or .apk file 91# $(2): the output .odex file 92define dex2oat-one-file 93$(hide) rm -f $(2) 94$(hide) mkdir -p $(dir $(2)) 95$(hide) ANDROID_LOG_TAGS="*:e" $(DEX2OAT) \ 96 --runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \ 97 --boot-image=$(PRIVATE_DEX_PREOPT_IMAGE_LOCATION) \ 98 --dex-file=$(1) \ 99 --dex-location=$(PRIVATE_DEX_LOCATION) \ 100 --oat-file=$(2) \ 101 --android-root=$(PRODUCT_OUT)/system \ 102 --instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \ 103 --instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \ 104 --instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \ 105 --include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info \ 106 --abort-on-hard-verifier-error \ 107 --no-inline-from=core-oj.jar \ 108 $(PRIVATE_DEX_PREOPT_FLAGS) 109endef 110