ART: PIC testing
Adds run-test support for PIC testing.
For the core image, enable with ART_TEST_PIC_IMAGE=true.
For the tests themselves, enable with ART_TEST_PIC_TEST=true.
Off by default.
Bug: 18035729
Change-Id: I23e396a2fa47b9471145f45b3c63f447871ebebf
diff --git a/build/Android.common_test.mk b/build/Android.common_test.mk
index ca718f1..2493565 100644
--- a/build/Android.common_test.mk
+++ b/build/Android.common_test.mk
@@ -63,6 +63,12 @@
# Do you want optimizing compiler tests run?
ART_TEST_OPTIMIZING ?= $(ART_TEST_FULL)
+# Do we want to test a PIC-compiled core image?
+ART_TEST_PIC_IMAGE ?= $(ART_TEST_FULL)
+
+# Do we want to test PIC-compiled tests ("apps")?
+ART_TEST_PIC_TEST ?= $(ART_TEST_FULL)
+
# Do you want tracing tests run?
ART_TEST_TRACE ?= $(ART_TEST_FULL)
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index db7257a..9e640c6 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -59,11 +59,11 @@
ART_GTEST_transaction_test_DEX_DEPS := Transaction
# The elf writer test has dependencies on core.oat.
-ART_GTEST_elf_writer_test_HOST_DEPS := $(HOST_CORE_OAT_OUT) $(2ND_HOST_CORE_OAT_OUT)
-ART_GTEST_elf_writer_test_TARGET_DEPS := $(TARGET_CORE_OAT_OUT) $(2ND_TARGET_CORE_OAT_OUT)
+ART_GTEST_elf_writer_test_HOST_DEPS := $(HOST_CORE_IMAGE_default_no-pic_64) $(HOST_CORE_IMAGE_default_no-pic_32)
+ART_GTEST_elf_writer_test_TARGET_DEPS := $(TARGET_CORE_IMAGE_default_no-pic_64) $(TARGET_CORE_IMAGE_default_no-pic_32)
ART_GTEST_jni_internal_test_TARGET_DEPS := $(TARGET_CORE_DEX_FILES)
ART_GTEST_proxy_test_TARGET_DEPS := $(TARGET_CORE_DEX_FILES)
-ART_GTEST_proxy_test_HOST_DEPS := $(HOST_CORE_OAT_OUT) $(2ND_HOST_CORE_OAT_OUT)
+ART_GTEST_proxy_test_HOST_DEPS := $(HOST_CORE_IMAGE_default_no-pic_64) $(HOST_CORE_IMAGE_default_no-pic_32)
# The path for which all the source files are relative, not actually the current directory.
LOCAL_PATH := art
diff --git a/build/Android.oat.mk b/build/Android.oat.mk
index 823ef7d..80a000b 100644
--- a/build/Android.oat.mk
+++ b/build/Android.oat.mk
@@ -24,8 +24,9 @@
include art/build/Android.common_build.mk
# Use dex2oat debug version for better error reporting
-# $(1): compiler
-# $(2): 2ND_ or undefined, 2ND_ for 32-bit host builds.
+# $(1): compiler - default, optimizing or interpreter.
+# $(2): pic/no-pic
+# $(3): 2ND_ or undefined, 2ND_ for 32-bit host builds.
# 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
@@ -33,6 +34,7 @@
core_image_name :=
core_oat_name :=
core_infix :=
+ core_pic_infix :=
ifeq ($(1),optimizing)
core_compile_options += --compiler-backend=optimizing
@@ -49,14 +51,27 @@
#Technically this test is not precise, but hopefully good enough.
$$(error found $(1) expected default, interpreter or optimizing)
endif
- core_image_name := $($(2)HOST_CORE_IMG_OUT_BASE)$$(core_infix)$(CORE_IMG_SUFFIX)
- core_oat_name := $($(2)HOST_CORE_OAT_OUT_BASE)$$(core_infix)$(CORE_OAT_SUFFIX)
+
+ ifeq ($(2),pic)
+ core_compile_options += --compile-pic
+ core_pic_infix := -pic
+ endif
+ ifeq ($(2),no-pic)
+ # No change for non-pic
+ endif
+ ifneq ($(filter-out pic no-pic,$(2)),)
+ # Technically this test is not precise, but hopefully good enough.
+ $$(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)
# Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
- ifeq ($(2),)
- HOST_CORE_IMAGE_$(1)_64 := $$(core_image_name)
+ ifeq ($(3),)
+ HOST_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
else
- HOST_CORE_IMAGE_$(1)_32 := $$(core_image_name)
+ HOST_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
endif
HOST_CORE_IMG_OUTS += $$(core_image_name)
HOST_CORE_OAT_OUTS += $$(core_oat_name)
@@ -71,8 +86,8 @@
--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) \
- --base=$$(LIBART_IMG_HOST_BASE_ADDRESS) --instruction-set=$$($(2)ART_HOST_ARCH) \
- --instruction-set-features=$$($(2)HOST_INSTRUCTION_SET_FEATURES) \
+ --base=$$(LIBART_IMG_HOST_BASE_ADDRESS) --instruction-set=$$($(3)ART_HOST_ARCH) \
+ --instruction-set-features=$$($(3)HOST_INSTRUCTION_SET_FEATURES) \
--host --android-root=$$(HOST_OUT) --include-patch-information \
$$(PRIVATE_CORE_COMPILE_OPTIONS)
@@ -83,22 +98,31 @@
core_image_name :=
core_oat_name :=
core_infix :=
+ core_pic_infix :=
endef # create-core-oat-host-rules
-$(eval $(call create-core-oat-host-rules,default,))
-$(eval $(call create-core-oat-host-rules,optimizing,))
-$(eval $(call create-core-oat-host-rules,interpreter,))
-ifneq ($(HOST_PREFER_32_BIT),true)
-$(eval $(call create-core-oat-host-rules,default,2ND_))
-$(eval $(call create-core-oat-host-rules,optimizing,2ND_))
-$(eval $(call create-core-oat-host-rules,interpreter,2ND_))
-endif
+# $(1): compiler - default, optimizing or interpreter.
+define create-core-oat-host-rule-combination
+ $(call create-core-oat-host-rules,$(1),no-pic,)
+ $(call create-core-oat-host-rules,$(1),pic,)
+
+ 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_)
+ 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))
+
define create-core-oat-target-rules
core_compile_options :=
core_image_name :=
core_oat_name :=
core_infix :=
+ core_pic_infix :=
ifeq ($(1),optimizing)
core_compile_options += --compiler-backend=optimizing
@@ -112,17 +136,34 @@
# Default has no infix, no compile options.
endif
ifneq ($(filter-out default interpreter optimizing,$(1)),)
- #Technically this test is not precise, but hopefully good enough.
+ # Technically this test is not precise, but hopefully good enough.
$$(error found $(1) expected default, interpreter or optimizing)
endif
- core_image_name := $($(2)TARGET_CORE_IMG_OUT_BASE)$$(core_infix)$(CORE_IMG_SUFFIX)
- core_oat_name := $($(2)TARGET_CORE_OAT_OUT_BASE)$$(core_infix)$(CORE_OAT_SUFFIX)
+
+ ifeq ($(2),pic)
+ core_compile_options += --compile-pic
+ core_pic_infix := -pic
+ endif
+ ifeq ($(2),no-pic)
+ # No change for non-pic
+ endif
+ ifneq ($(filter-out pic no-pic,$(2)),)
+ #Technically this test is not precise, but hopefully good enough.
+ $$(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)
# Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
- ifeq ($(2),)
- TARGET_CORE_IMAGE_$(1)_64 := $$(core_image_name)
+ ifeq ($(3),)
+ ifdef TARGET_2ND_ARCH
+ TARGET_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
+ else
+ TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
+ endif
else
- TARGET_CORE_IMAGE_$(1)_32 := $$(core_image_name)
+ TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
endif
TARGET_CORE_IMG_OUTS += $$(core_image_name)
TARGET_CORE_OAT_OUTS += $$(core_oat_name)
@@ -137,8 +178,8 @@
--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) \
- --base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) --instruction-set=$$($(2)TARGET_ARCH) \
- --instruction-set-features=$$($(2)TARGET_INSTRUCTION_SET_FEATURES) \
+ --base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) --instruction-set=$$($(3)TARGET_ARCH) \
+ --instruction-set-features=$$($(3)TARGET_INSTRUCTION_SET_FEATURES) \
--android-root=$$(PRODUCT_OUT)/system --include-patch-information \
$$(PRIVATE_CORE_COMPILE_OPTIONS)
@@ -149,13 +190,20 @@
core_image_name :=
core_oat_name :=
core_infix :=
+ core_pic_infix :=
endef # create-core-oat-target-rules
-ifdef TARGET_2ND_ARCH
-$(eval $(call create-core-oat-target-rules,default,2ND_))
-$(eval $(call create-core-oat-target-rules,optimizing,2ND_))
-$(eval $(call create-core-oat-target-rules,interpreter,2ND_))
-endif
-$(eval $(call create-core-oat-target-rules,default,))
-$(eval $(call create-core-oat-target-rules,optimizing,))
-$(eval $(call create-core-oat-target-rules,interpreter,))
+# $(1): compiler - default, optimizing or interpreter.
+define create-core-oat-target-rule-combination
+ $(call create-core-oat-target-rules,$(1),no-pic,)
+ $(call create-core-oat-target-rules,$(1),pic,)
+
+ ifdef TARGET_2ND_ARCH
+ $(call create-core-oat-target-rules,$(1),no-pic,2ND_)
+ $(call create-core-oat-target-rules,$(1),pic,2ND_)
+ 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))