Add a Make variable to disable all dexpreopt and dexopt activities.

This change adds a Make variable "OVERRIDE_DISABLE_DEXOPT_ALL", which
disables all dexpreopt and dexopt activities.

This is for faster iteration during development and should never be
enabled for production.

Bug: 309011617
Test: See no dex2oat invocation during build.
Test: Boot and see no dex2oat invocation during boot, except for the
  in-memory boot image for JIT Zygote.
Change-Id: I0193b57fdb18e1fb717f44af81d1cf525f1609ee
This commit is contained in:
Jiakai Zhang
2023-11-06 17:55:59 +00:00
parent 7707456104
commit bf0c0e6856
5 changed files with 39 additions and 29 deletions

View File

@@ -202,7 +202,7 @@ _board_strip_readonly_list += $(_build_broken_var_list) \
# Conditional to building on linux, as dex2oat currently does not work on darwin.
ifeq ($(HOST_OS),linux)
WITH_DEXPREOPT := true
WITH_DEXPREOPT ?= true
endif
# ###############################################################

View File

@@ -58,25 +58,10 @@ DEX_PREOPT_WITH_UPDATABLE_BCP := true
# Conditional to building on linux, as dex2oat currently does not work on darwin.
ifeq ($(HOST_OS),linux)
ifeq (eng,$(TARGET_BUILD_VARIANT))
# For an eng build only pre-opt the boot image and system server. This gives reasonable performance
# and still allows a simple workflow: building in frameworks/base and syncing.
WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY ?= true
endif
# Add mini-debug-info to the boot classpath unless explicitly asked not to.
ifneq (false,$(WITH_DEXPREOPT_DEBUG_INFO))
PRODUCT_DEX_PREOPT_BOOT_FLAGS += --generate-mini-debug-info
endif
# Non eng linux builds must have preopt enabled so that system server doesn't run as interpreter
# only. b/74209329
ifeq (,$(filter eng, $(TARGET_BUILD_VARIANT)))
ifneq (true,$(WITH_DEXPREOPT))
ifneq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))
$(call pretty-error, DEXPREOPT must be enabled for user and userdebug builds)
endif
endif
endif
endif
# Get value of a property. It is first searched from PRODUCT_VENDOR_PROPERTIES
@@ -100,7 +85,7 @@ ifeq ($(WRITE_SOONG_VARIABLES),true)
$(call add_json_bool, DisablePreopt, $(call invert_bool,$(ENABLE_PREOPT)))
$(call add_json_bool, DisablePreoptBootImages, $(call invert_bool,$(ENABLE_PREOPT_BOOT_IMAGES)))
$(call add_json_list, DisablePreoptModules, $(DEXPREOPT_DISABLED_MODULES))
$(call add_json_bool, OnlyPreoptBootImageAndSystemServer, $(filter true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY)))
$(call add_json_bool, OnlyPreoptArtBootImage , $(filter true,$(WITH_DEXPREOPT_ART_BOOT_IMG_ONLY)))
$(call add_json_bool, PreoptWithUpdatableBcp, $(filter true,$(DEX_PREOPT_WITH_UPDATABLE_BCP)))
$(call add_json_bool, DontUncompressPrivAppsDex, $(filter true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS)))
$(call add_json_list, ModulesLoadedByPrivilegedModules, $(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))

View File

@@ -60,17 +60,9 @@ ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file)$(LOCAL_SOONG_DEX_JAR)))
LOCAL_DEX_PREOPT :=
endif
# if WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY=true and module is not in boot class path skip
# Also preopt system server jars since selinux prevents system server from loading anything from
# /data. If we don't do this they will need to be extracted which is not favorable for RAM usage
# or performance. If my_preopt_for_extracted_apk is true, we ignore the only preopt boot image
# options.
system_server_jars := $(foreach m,$(PRODUCT_SYSTEM_SERVER_JARS),$(call word-colon,2,$(m)))
ifneq (true,$(my_preopt_for_extracted_apk))
ifeq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))
ifeq ($(filter $(system_server_jars) $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)),)
LOCAL_DEX_PREOPT :=
endif
ifeq (true,$(WITH_DEXPREOPT_ART_BOOT_IMG_ONLY))
LOCAL_DEX_PREOPT :=
endif
endif
@@ -226,7 +218,7 @@ endif
# as a failure to get manifest from an APK).
ifneq (true,$(WITH_DEXPREOPT))
LOCAL_ENFORCE_USES_LIBRARIES := false
else ifeq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))
else ifeq (true,$(WITH_DEXPREOPT_ART_BOOT_IMG_ONLY))
LOCAL_ENFORCE_USES_LIBRARIES := false
endif

View File

@@ -548,7 +548,7 @@ endef
# be cleaned up to not be product variables.
_readonly_late_variables := \
DEVICE_PACKAGE_OVERLAYS \
WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY \
WITH_DEXPREOPT_ART_BOOT_IMG_ONLY \
# Modified internally in the build system
_readonly_late_variables += \

View File

@@ -126,6 +126,39 @@ PRODUCT_SYSTEM_PROPERTIES += \
pm.dexopt.cmdline?=verify \
pm.dexopt.shared?=speed
ifneq (,$(filter eng,$(TARGET_BUILD_VARIANT)))
OVERRIDE_DISABLE_DEXOPT_ALL ?= true
endif
# OVERRIDE_DISABLE_DEXOPT_ALL disables all dexpreopt (build-time) and dexopt (on-device) activities.
# This option is for faster iteration during development and should never be enabled for production.
ifneq (,$(filter true,$(OVERRIDE_DISABLE_DEXOPT_ALL)))
PRODUCT_SYSTEM_PROPERTIES += \
pm.dexopt.post-boot=skip \
pm.dexopt.first-boot=skip \
pm.dexopt.boot-after-ota=skip \
pm.dexopt.boot-after-mainline-update=skip \
pm.dexopt.install=skip \
pm.dexopt.install-fast=skip \
pm.dexopt.install-bulk=skip \
pm.dexopt.install-bulk-secondary=skip \
pm.dexopt.install-bulk-downgraded=skip \
pm.dexopt.install-bulk-secondary-downgraded=skip \
pm.dexopt.bg-dexopt=skip \
pm.dexopt.ab-ota=skip \
pm.dexopt.inactive=skip \
pm.dexopt.cmdline=skip \
pm.dexopt.shared=skip
PRODUCT_SYSTEM_PROPERTIES += dalvik.vm.disable-odrefresh=true
# Disable all dexpreopt activities except for the ART boot image.
# We have to dexpreopt the ART boot image because they are used by ART tests. This should not
# be too much of a problem for platform developers because a change to framework code should not
# trigger dexpreopt for the ART boot image.
WITH_DEXPREOPT_ART_BOOT_IMG_ONLY := true
endif
# Enable resolution of startup const strings.
PRODUCT_SYSTEM_PROPERTIES += \
dalvik.vm.dex2oat-resolve-startup-strings=true