Adds PGO_GEN and PGO_USE for libart and libart-compiler.
PGO_GEN=device_path is used to build an instrumented binary. The profile will be stored in the specified path in device.
PGO_USE=host_path is used to build an PGO-optimized binary. The profile should be pre-stored in the specified path in host.
Bug: 16153819
Change-Id: Ib56f8707df009f290608ca66f669db06e65815c1
diff --git a/build/Android.common_build.mk b/build/Android.common_build.mk
index 5cfdbfd..c39bc5d 100644
--- a/build/Android.common_build.mk
+++ b/build/Android.common_build.mk
@@ -207,6 +207,7 @@
$(error LIBART_IMG_TARGET_BASE_ADDRESS unset)
endif
ART_TARGET_CFLAGS := $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS)
+ART_TARGET_LDFLAGS :=
ifeq ($(TARGET_CPU_SMP),true)
ART_TARGET_CFLAGS += -DANDROID_SMP=1
else
@@ -219,6 +220,14 @@
endif
endif
ART_TARGET_CFLAGS += $(ART_DEFAULT_GC_TYPE_CFLAGS)
+ifdef PGO_GEN
+ ART_TARGET_CFLAGS += -fprofile-generate=$(PGO_GEN)
+ ART_TARGET_LDFLAGS += -fprofile-generate=$(PGO_GEN)
+endif
+ifdef PGO_USE
+ ART_TARGET_CFLAGS += -fprofile-use=$(PGO_USE)
+ ART_TARGET_CFLAGS += -fprofile-correction -Wno-error
+endif
# DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES is set in ../build/core/dex_preopt.mk based on
# the TARGET_CPU_VARIANT
@@ -277,6 +286,7 @@
define set-target-local-cflags-vars
LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
LOCAL_CFLAGS_x86 += $(ART_TARGET_CFLAGS_x86)
+ LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS)
art_target_cflags_ndebug_or_debug := $(1)
ifeq ($$(art_target_cflags_ndebug_or_debug),debug)
LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)