From 6ecf0ef7447adbc1bd2f8b591f62d37bd8164255 Mon Sep 17 00:00:00 2001 From: synergydev Date: Thu, 8 Aug 2013 13:08:26 -0700 Subject: [PATCH] FDO: support linux-x86 target Change-Id: I4a3a1d298176da109df316cf9128f19e77490bc9 --- core/combo/TARGET_linux-x86.mk | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk index 5c9a76bb1a..159fbe1b5b 100644 --- a/core/combo/TARGET_linux-x86.mk +++ b/core/combo/TARGET_linux-x86.mk @@ -63,6 +63,8 @@ endif ifneq ($(wildcard $(TARGET_CC)),) TARGET_LIBGCC := \ $(shell $(TARGET_CC) -m32 -print-file-name=libgcc.a) +target_libgcov := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \ + -print-file-name=libgcov.a) endif TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined @@ -72,6 +74,34 @@ libm_root := bionic/libm libstdc++_root := bionic/libstdc++ libthread_db_root := bionic/libthread_db +# Define FDO (Feedback Directed Optimization) options. + +TARGET_FDO_CFLAGS:= +TARGET_FDO_LIB:= + +ifneq ($(strip $(BUILD_FDO_INSTRUMENT)),) + # Set BUILD_FDO_INSTRUMENT=true to turn on FDO instrumentation. + # The profile will be generated on /data/local/tmp/profile on the device. + TARGET_FDO_CFLAGS := -fprofile-generate=/data/local/tmp/profile -DANDROID_FDO + TARGET_FDO_LIB := $(target_libgcov) +else + # If BUILD_FDO_INSTRUMENT is turned off, then consider doing the FDO optimizations. + # Set TARGET_FDO_PROFILE_PATH to set a custom profile directory for your build. + ifeq ($(strip $(TARGET_FDO_PROFILE_PATH)),) + TARGET_FDO_PROFILE_PATH := fdo/profiles/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT) + else + ifeq ($(strip $(wildcard $(TARGET_FDO_PROFILE_PATH))),) + $(warning Custom TARGET_FDO_PROFILE_PATH supplied, but directory does not exist. Turn off FDO.) + endif + endif + + # If the FDO profile directory can't be found, then FDO is off. + ifneq ($(strip $(wildcard $(TARGET_FDO_PROFILE_PATH))),) + TARGET_FDO_CFLAGS := -fprofile-use=$(TARGET_FDO_PROFILE_PATH) -DANDROID_FDO + TARGET_FDO_LIB := $(target_libgcov) + endif +endif + # unless CUSTOM_KERNEL_HEADERS is defined, we're going to use # symlinks located in out/ to point to the appropriate kernel # headers. see 'config/kernel_headers.make' for more details @@ -191,6 +221,7 @@ $(hide) $(PRIVATE_CXX) \ $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ $(PRIVATE_TARGET_LIBGCC) \ + $(PRIVATE_TARGET_FDO_LIB) \ $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ -o $@ \ $(PRIVATE_LDFLAGS) \ @@ -216,6 +247,7 @@ $(hide) $(PRIVATE_CXX) \ $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ $(PRIVATE_TARGET_LIBGCC) \ + $(PRIVATE_TARGET_FDO_LIB) \ $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ -o $@ \ $(PRIVATE_LDFLAGS) \ @@ -237,6 +269,7 @@ $(hide) $(PRIVATE_CXX) \ -Wl,--no-whole-archive \ -Wl,--start-group \ $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ + $(PRIVATE_TARGET_FDO_LIB) \ $(PRIVATE_TARGET_LIBGCC) \ -Wl,--end-group \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O))