ART: Wire up a valgrind-wrapped dex2oat run
Extend build-art-executable to understand multilib=both, in which
case a stem is necessary. Use name32 for the 32b version, and name
for the 64b version (or only version).
Create both 32b and 64b dex2oat on the host.
Extend the core generation rules to allow a wrapper. Create rules
to run with valgrind: valgrind-test-art-host-dex2oat.
Currently this is not wired up to valgrind-test-art-host, as valgrind
reports an error on exit.
Note: this takes a long time, as by default the debug version of
dex2oat is used. The author has seen runs of about 6 minutes.
Bug: 18605772
Change-Id: I32c270d2cf8a104f154bdf91875670b03d3f5d3b
diff --git a/build/Android.executable.mk b/build/Android.executable.mk
index 86f445f..ae42136 100644
--- a/build/Android.executable.mk
+++ b/build/Android.executable.mk
@@ -99,7 +99,18 @@
ifeq ($$(art_target_or_host),target)
LOCAL_MODULE_TARGET_ARCH := $(ART_SUPPORTED_ARCH)
endif
+
+ # If multilib, need to provide stem.
LOCAL_MULTILIB := $$(art_multilib)
+ ifeq ($$(art_multilib),both)
+ ifeq ($$(art_ndebug_or_debug),ndebug)
+ LOCAL_MODULE_STEM_32 := $$(art_executable)32
+ LOCAL_MODULE_STEM_64 := $$(art_executable)
+ else #debug
+ LOCAL_MODULE_STEM_32 := $$(art_executable)d32
+ LOCAL_MODULE_STEM_64 := $$(art_executable)d
+ endif
+ endif
include external/libcxx/libcxx.mk
ifeq ($$(art_target_or_host),target)
diff --git a/build/Android.oat.mk b/build/Android.oat.mk
index 523d143..f0fadca 100644
--- a/build/Android.oat.mk
+++ b/build/Android.oat.mk
@@ -34,6 +34,8 @@
# $(1): compiler - default, optimizing or interpreter.
# $(2): pic/no-pic
# $(3): 2ND_ or undefined, 2ND_ for 32-bit host builds.
+# $(4): wrapper, e.g., valgrind.
+# $(5): dex2oat suffix, e.g, valgrind requires 32 right now.
# NB depending on HOST_CORE_DEX_LOCATIONS so we are sure to have the dex files in frameworks for
# run-test --no-image
define create-core-oat-host-rules
@@ -78,25 +80,30 @@
$$(error found $(2) expected pic or no-pic)
endif
- core_image_name := $($(3)HOST_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(CORE_IMG_SUFFIX)
- core_oat_name := $($(3)HOST_CORE_OAT_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(CORE_OAT_SUFFIX)
+ core_image_name := $($(3)HOST_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(4)$(CORE_IMG_SUFFIX)
+ core_oat_name := $($(3)HOST_CORE_OAT_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(4)$(CORE_OAT_SUFFIX)
# Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
ifeq ($(3),)
- HOST_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
+ $(4)HOST_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
else
- HOST_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
+ $(4)HOST_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
endif
- HOST_CORE_IMG_OUTS += $$(core_image_name)
- HOST_CORE_OAT_OUTS += $$(core_oat_name)
+ $(4)HOST_CORE_IMG_OUTS += $$(core_image_name)
+ $(4)HOST_CORE_OAT_OUTS += $$(core_oat_name)
+ # If we have a wrapper, make the target phony.
+ ifneq ($(4),)
+.PHONY: $$(core_image_name)
+ endif
$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options)
$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name)
$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name)
$$(core_image_name): $$(HOST_CORE_DEX_LOCATIONS) $$(core_dex2oat_dependency)
@echo "host dex2oat: $$@ ($$?)"
@mkdir -p $$(dir $$@)
- $$(hide) $$(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
+ $$(hide) $(4) $$(DEX2OAT)$(5) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
+ --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
--image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(HOST_CORE_DEX_FILES)) \
$$(addprefix --dex-location=,$$(HOST_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \
--oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \
@@ -117,20 +124,29 @@
endef # create-core-oat-host-rules
# $(1): compiler - default, optimizing or interpreter.
+# $(2): wrapper.
+# $(3): dex2oat suffix.
define create-core-oat-host-rule-combination
- $(call create-core-oat-host-rules,$(1),no-pic,)
- $(call create-core-oat-host-rules,$(1),pic,)
+ $(call create-core-oat-host-rules,$(1),no-pic,,$(2),$(3))
+ $(call create-core-oat-host-rules,$(1),pic,,$(2),$(3))
ifneq ($(HOST_PREFER_32_BIT),true)
- $(call create-core-oat-host-rules,$(1),no-pic,2ND_)
- $(call create-core-oat-host-rules,$(1),pic,2ND_)
+ $(call create-core-oat-host-rules,$(1),no-pic,2ND_,$(2),$(3))
+ $(call create-core-oat-host-rules,$(1),pic,2ND_,$(2),$(3))
endif
endef
-$(eval $(call create-core-oat-host-rule-combination,default))
-$(eval $(call create-core-oat-host-rule-combination,optimizing))
-$(eval $(call create-core-oat-host-rule-combination,interpreter))
+$(eval $(call create-core-oat-host-rule-combination,default,,))
+$(eval $(call create-core-oat-host-rule-combination,optimizing,,))
+$(eval $(call create-core-oat-host-rule-combination,interpreter,,))
+valgrindHOST_CORE_IMG_OUTS :=
+valgrindHOST_CORE_OAT_OUTS :=
+$(eval $(call create-core-oat-host-rule-combination,default,valgrind,32))
+$(eval $(call create-core-oat-host-rule-combination,optimizing,valgrind,32))
+$(eval $(call create-core-oat-host-rule-combination,interpreter,valgrind,32))
+
+valgrind-test-art-host-dex2oat-host: $(valgrindHOST_CORE_IMG_OUTS)
define create-core-oat-target-rules
core_compile_options :=
@@ -180,29 +196,34 @@
$$(error found $(2) expected pic or no-pic)
endif
- core_image_name := $($(3)TARGET_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(CORE_IMG_SUFFIX)
- core_oat_name := $($(3)TARGET_CORE_OAT_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(CORE_OAT_SUFFIX)
+ core_image_name := $($(3)TARGET_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(4)$(CORE_IMG_SUFFIX)
+ core_oat_name := $($(3)TARGET_CORE_OAT_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(4)$(CORE_OAT_SUFFIX)
# Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
ifeq ($(3),)
ifdef TARGET_2ND_ARCH
- TARGET_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
+ $(4)TARGET_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
else
- TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
+ $(4)TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
endif
else
- TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
+ $(4)TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
endif
- TARGET_CORE_IMG_OUTS += $$(core_image_name)
- TARGET_CORE_OAT_OUTS += $$(core_oat_name)
+ $(4)TARGET_CORE_IMG_OUTS += $$(core_image_name)
+ $(4)TARGET_CORE_OAT_OUTS += $$(core_oat_name)
+ # If we have a wrapper, make the target phony.
+ ifneq ($(4),)
+.PHONY: $$(core_image_name)
+ endif
$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options)
$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name)
$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name)
$$(core_image_name): $$(TARGET_CORE_DEX_FILES) $$(core_dex2oat_dependency)
@echo "target dex2oat: $$@ ($$?)"
@mkdir -p $$(dir $$@)
- $$(hide) $$(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \
+ $$(hide) $(4) $$(DEX2OAT)$(5) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
+ --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
--image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(TARGET_CORE_DEX_FILES)) \
$$(addprefix --dex-location=,$$(TARGET_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \
--oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \
@@ -223,16 +244,28 @@
endef # create-core-oat-target-rules
# $(1): compiler - default, optimizing or interpreter.
+# $(2): wrapper.
+# $(3): dex2oat suffix.
define create-core-oat-target-rule-combination
- $(call create-core-oat-target-rules,$(1),no-pic,)
- $(call create-core-oat-target-rules,$(1),pic,)
+ $(call create-core-oat-target-rules,$(1),no-pic,,$(2),$(3))
+ $(call create-core-oat-target-rules,$(1),pic,,$(2),$(3))
ifdef TARGET_2ND_ARCH
- $(call create-core-oat-target-rules,$(1),no-pic,2ND_)
- $(call create-core-oat-target-rules,$(1),pic,2ND_)
+ $(call create-core-oat-target-rules,$(1),no-pic,2ND_,$(2),$(3))
+ $(call create-core-oat-target-rules,$(1),pic,2ND_,$(2),$(3))
endif
endef
-$(eval $(call create-core-oat-target-rule-combination,default))
-$(eval $(call create-core-oat-target-rule-combination,optimizing))
-$(eval $(call create-core-oat-target-rule-combination,interpreter))
+$(eval $(call create-core-oat-target-rule-combination,default,,))
+$(eval $(call create-core-oat-target-rule-combination,optimizing,,))
+$(eval $(call create-core-oat-target-rule-combination,interpreter,,))
+
+valgrindTARGET_CORE_IMG_OUTS :=
+valgrindTARGET_CORE_OAT_OUTS :=
+$(eval $(call create-core-oat-target-rule-combination,default,valgrind,32))
+$(eval $(call create-core-oat-target-rule-combination,optimizing,valgrind,32))
+$(eval $(call create-core-oat-target-rule-combination,interpreter,valgrind,32))
+
+valgrind-test-art-host-dex2oat-target: $(valgrindTARGET_CORE_IMG_OUTS)
+
+valgrind-test-art-host-dex2oat: valgrind-test-art-host-dex2oat-host valgrind-test-art-host-dex2oat-target
diff --git a/dex2oat/Android.mk b/dex2oat/Android.mk
index 4f39c42..cf30667 100644
--- a/dex2oat/Android.mk
+++ b/dex2oat/Android.mk
@@ -38,8 +38,8 @@
# We always build dex2oat and dependencies, even if the host build is otherwise disabled, since they are used to cross compile for the target.
ifeq ($(ART_BUILD_HOST_NDEBUG),true)
- $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libart-compiler libziparchive-host,art/compiler,host,ndebug))
+ $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libart-compiler libziparchive-host,art/compiler,host,ndebug,both))
endif
ifeq ($(ART_BUILD_HOST_DEBUG),true)
- $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libartd-compiler libziparchive-host,art/compiler,host,debug))
+ $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libartd-compiler libziparchive-host,art/compiler,host,debug,both))
endif