Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 1 | #################################### |
| 2 | # dexpreopt support for ART |
| 3 | # |
| 4 | #################################### |
| 5 | |
Fredrik Roubert | 8a3dd24 | 2015-07-27 21:48:39 +0200 | [diff] [blame] | 6 | # Default to debug version to help find bugs. |
| 7 | # Set USE_DEX2OAT_DEBUG to false for only building non-debug versions. |
| 8 | ifeq ($(USE_DEX2OAT_DEBUG),false) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 9 | DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oat$(HOST_EXECUTABLE_SUFFIX) |
Fredrik Roubert | 8a3dd24 | 2015-07-27 21:48:39 +0200 | [diff] [blame] | 10 | else |
| 11 | DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oatd$(HOST_EXECUTABLE_SUFFIX) |
| 12 | endif |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 13 | |
Jeff Hao | b00263f | 2016-06-13 16:53:11 -0700 | [diff] [blame] | 14 | # Pass special classpath to skip uses library check. |
| 15 | # Should modify build system to pass used libraries properly later. |
| 16 | DEX2OAT_CLASSPATH := "&" |
| 17 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 18 | DEX2OAT_DEPENDENCY += $(DEX2OAT) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 19 | |
Ying Wang | 0c9b3ba | 2014-11-13 15:19:12 -0800 | [diff] [blame] | 20 | # Use the first preloaded-classes file in PRODUCT_COPY_FILES. |
| 21 | PRELOADED_CLASSES := $(call word-colon,1,$(firstword \ |
| 22 | $(filter %system/etc/preloaded-classes,$(PRODUCT_COPY_FILES)))) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 23 | |
Andreas Gampe | 96a5220 | 2014-11-18 11:45:10 -0800 | [diff] [blame] | 24 | # Use the first compiled-classes file in PRODUCT_COPY_FILES. |
| 25 | COMPILED_CLASSES := $(call word-colon,1,$(firstword \ |
| 26 | $(filter %system/etc/compiled-classes,$(PRODUCT_COPY_FILES)))) |
| 27 | |
Colin Cross | dd2ff55 | 2014-07-09 22:09:50 -0700 | [diff] [blame] | 28 | define get-product-default-property |
| 29 | $(strip $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES)))) |
Brian Carlstrom | cffe289 | 2014-07-08 10:35:29 -0700 | [diff] [blame] | 30 | endef |
| 31 | |
Colin Cross | dd2ff55 | 2014-07-09 22:09:50 -0700 | [diff] [blame] | 32 | DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms) |
| 33 | DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx) |
| 34 | DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms) |
| 35 | DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx) |
Brian Carlstrom | cffe289 | 2014-07-08 10:35:29 -0700 | [diff] [blame] | 36 | |
Nikola Veljkovic | a57aaa3 | 2014-12-23 13:50:18 +0100 | [diff] [blame] | 37 | ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64)) |
Ian Rogers | 7d70f83 | 2014-07-16 18:06:02 -0700 | [diff] [blame] | 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. |
Ian Rogers | 87f0d00 | 2014-07-16 22:25:35 -0700 | [diff] [blame] | 44 | DEX2OAT_XMX := 128m |
Ian Rogers | 7d70f83 | 2014-07-16 18:06:02 -0700 | [diff] [blame] | 45 | endif |
| 46 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 47 | ######################################################################## |
| 48 | # The full system boot classpath |
| 49 | |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 50 | # Returns the path to the .odex file |
| 51 | # $(1): the arch name. |
| 52 | # $(2): the full path (including file name) of the corresponding .jar or .apk. |
| 53 | define get-odex-file-path |
Richard Uhler | 820fe32 | 2015-03-16 14:38:17 -0700 | [diff] [blame] | 54 | $(dir $(2))oat/$(1)/$(basename $(notdir $(2))).odex |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 55 | endef |
| 56 | |
Alex Light | 4e358ab | 2016-06-16 14:47:10 -0700 | [diff] [blame] | 57 | # Returns the full path to the installed .odex file. |
| 58 | # This handles BOARD_USES_SYSTEM_OTHER_ODEX to install odex files into another |
| 59 | # partition. |
| 60 | # $(1): the arch name. |
| 61 | # $(2): the full install path (including file name) of the corresponding .apk. |
| 62 | ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true) |
| 63 | define get-odex-installed-file-path |
Nicolas Geoffray | cdd4343 | 2017-03-24 14:45:59 +0000 | [diff] [blame] | 64 | $(if $(call install-on-system-other, $(2)), |
Alex Light | 4e358ab | 2016-06-16 14:47:10 -0700 | [diff] [blame] | 65 | $(call get-odex-file-path,$(1),$(patsubst $(TARGET_OUT)/%,$(TARGET_OUT_SYSTEM_OTHER)/%,$(2))), |
| 66 | $(call get-odex-file-path,$(1),$(2))) |
| 67 | endef |
| 68 | else |
| 69 | get-odex-installed-file-path = $(get-odex-file-path) |
| 70 | endif |
| 71 | |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 72 | # Returns the path to the image file (such as "/system/framework/<arch>/boot.art" |
| 73 | # $(1): the arch name (such as "arm") |
| 74 | # $(2): the image location (such as "/system/framework/boot.art") |
| 75 | define get-image-file-path |
| 76 | $(dir $(2))$(1)/$(notdir $(2)) |
| 77 | endef |
| 78 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 79 | # note we use core-libart.jar in place of core.jar for ART. |
| 80 | LIBART_TARGET_BOOT_JARS := $(patsubst core, core-libart,$(DEXPREOPT_BOOT_JARS_MODULES)) |
| 81 | LIBART_TARGET_BOOT_DEX_LOCATIONS := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),/$(DEXPREOPT_BOOT_JAR_DIR)/$(jar).jar) |
| 82 | LIBART_TARGET_BOOT_DEX_FILES := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),$(call intermediates-dir-for,JAVA_LIBRARIES,$(jar),,COMMON)/javalib.jar) |
| 83 | |
Colin Cross | 52dcb2f | 2016-03-08 13:21:49 -0800 | [diff] [blame] | 84 | # dex preopt on the bootclasspath produces multiple files. The first dex file |
| 85 | # is converted into to boot.art (to match the legacy assumption that boot.art |
| 86 | # exists), and the rest are converted to boot-<name>.art. |
| 87 | # In addition, each .art file has an associated .oat file. |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame] | 88 | LIBART_TARGET_BOOT_ART_EXTRA_FILES := $(foreach jar,$(wordlist 2,999,$(LIBART_TARGET_BOOT_JARS)),boot-$(jar).art boot-$(jar).oat boot-$(jar).vdex) |
| 89 | LIBART_TARGET_BOOT_ART_EXTRA_FILES += boot.oat boot.vdex |
Colin Cross | 52dcb2f | 2016-03-08 13:21:49 -0800 | [diff] [blame] | 90 | |
Mathieu Chartier | a61acf6 | 2017-06-28 18:23:37 -0700 | [diff] [blame^] | 91 | # If we use a boot image profile. |
| 92 | my_use_profile_for_boot_image := $(PRODUCT_USE_PROFILE_FOR_BOOT_IMAGE) |
| 93 | ifeq (,$(my_use_profile_for_boot_image)) |
| 94 | # If not set, use the default. |
| 95 | my_use_profile_for_boot_image := false |
| 96 | endif |
| 97 | |
| 98 | ifeq (true,$(my_use_profile_for_boot_image)) |
| 99 | |
| 100 | # Location of text based profile for the boot image. |
| 101 | my_boot_image_profile_location := $(PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION) |
| 102 | ifeq (,$(my_boot_image_profile_location)) |
| 103 | # If not set, use the default. |
| 104 | my_boot_image_profile_location := frameworks/base/boot-image-profile.txt |
| 105 | endif |
| 106 | |
| 107 | # Code to create the boot image profile, not in dex_preopt_libart_boot.mk since the profile is the same for all archs. |
| 108 | my_out_boot_image_profile_location := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/boot.prof |
| 109 | $(my_out_boot_image_profile_location): PRIVATE_PROFILE_INPUT_LOCATION := $(my_boot_image_profile_location) |
| 110 | $(my_out_boot_image_profile_location): $(PROFMAN) $(LIBART_TARGET_BOOT_DEX_FILES) $(my_boot_image_profile_location) |
| 111 | @echo "target profman: $@" |
| 112 | @mkdir -p $(dir $@) |
| 113 | ANDROID_LOG_TAGS="*:e" $(PROFMAN) \ |
| 114 | --create-profile-from=$(PRIVATE_PROFILE_INPUT_LOCATION) \ |
| 115 | $(addprefix --apk=,$(LIBART_TARGET_BOOT_DEX_FILES)) \ |
| 116 | $(addprefix --dex-location=,$(LIBART_TARGET_BOOT_DEX_LOCATIONS)) \ |
| 117 | --reference-profile-file=$@ |
| 118 | |
| 119 | # We want to install the profile even if we are not using preopt since it is required to generate |
| 120 | # the image on the device. |
| 121 | my_installed_profile := $(TARGET_OUT)/etc/boot-image.prof |
| 122 | $(eval $(call copy-one-file,$(my_out_boot_image_profile_location),$(my_installed_profile))) |
| 123 | ALL_DEFAULT_INSTALLED_MODULES += $(my_installed_profile) |
| 124 | |
| 125 | endif |
| 126 | |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 127 | my_2nd_arch_prefix := |
| 128 | include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 129 | |
Ying Wang | 87538e4 | 2016-03-16 19:53:19 -0700 | [diff] [blame] | 130 | ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true) |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 131 | ifdef TARGET_2ND_ARCH |
| 132 | my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) |
| 133 | include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk |
| 134 | my_2nd_arch_prefix := |
| 135 | endif |
Ying Wang | 87538e4 | 2016-03-16 19:53:19 -0700 | [diff] [blame] | 136 | endif |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 137 | |
| 138 | |
| 139 | ######################################################################## |
| 140 | # For a single jar or APK |
| 141 | |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 142 | # $(1): the input .jar or .apk file |
| 143 | # $(2): the output .odex file |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 144 | define dex2oat-one-file |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 145 | $(hide) rm -f $(2) |
| 146 | $(hide) mkdir -p $(dir $(2)) |
Joe Onorato | 401ffae | 2016-03-09 14:48:46 -0800 | [diff] [blame] | 147 | $(hide) ANDROID_LOG_TAGS="*:e" $(DEX2OAT) \ |
Colin Cross | dd2ff55 | 2014-07-09 22:09:50 -0700 | [diff] [blame] | 148 | --runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \ |
Jeff Hao | b00263f | 2016-06-13 16:53:11 -0700 | [diff] [blame] | 149 | --runtime-arg -classpath --runtime-arg $(DEX2OAT_CLASSPATH) \ |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 150 | --boot-image=$(PRIVATE_DEX_PREOPT_IMAGE_LOCATION) \ |
| 151 | --dex-file=$(1) \ |
| 152 | --dex-location=$(PRIVATE_DEX_LOCATION) \ |
| 153 | --oat-file=$(2) \ |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 154 | --android-root=$(PRODUCT_OUT)/system \ |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 155 | --instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \ |
Ian Rogers | a18a283 | 2014-10-17 01:05:50 -0700 | [diff] [blame] | 156 | --instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \ |
Alex Light | ce090d3 | 2014-07-24 16:26:13 -0700 | [diff] [blame] | 157 | --instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \ |
Richard Uhler | 41408b0 | 2017-02-28 17:05:12 +0000 | [diff] [blame] | 158 | --runtime-arg -Xnorelocate --compile-pic \ |
Alexey Alexandrov | e469063 | 2016-09-19 10:54:21 -0700 | [diff] [blame] | 159 | --no-generate-debug-info --generate-build-id \ |
Andreas Gampe | 06d86e9 | 2015-03-05 19:18:18 -0800 | [diff] [blame] | 160 | --abort-on-hard-verifier-error \ |
Nicolas Geoffray | a5bb180 | 2017-04-28 15:00:28 +0100 | [diff] [blame] | 161 | --force-determinism \ |
Jeff Hao | d1d3fd9 | 2015-12-16 17:20:11 -0800 | [diff] [blame] | 162 | --no-inline-from=core-oj.jar \ |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 163 | $(PRIVATE_DEX_PREOPT_FLAGS) \ |
Mathieu Chartier | 192b91c | 2017-02-08 18:30:31 -0800 | [diff] [blame] | 164 | $(PRIVATE_ART_FILE_PREOPT_FLAGS) \ |
Mathieu Chartier | a4b993b | 2017-02-28 11:17:32 -0800 | [diff] [blame] | 165 | $(PRIVATE_PROFILE_PREOPT_FLAGS) \ |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 166 | $(GLOBAL_DEXPREOPT_FLAGS) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 167 | endef |