[PATCH][build] Support profiling, enable by LOCAL_PROFILE_MODULE flag

10 views
Skip to first unread message

Kito Cheng

unread,
Nov 14, 2011, 10:43:56 AM11/14/11
to 0xlab...@googlegroups.com
Change-Id: I4ec330b6975ec21b4424429e828ce06eeb2c7267
---
core/binary.mk | 14 ++++++++++++++
core/clear_vars.mk | 1 +
core/shared_library.mk | 3 +++
3 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/core/binary.mk b/core/binary.mk
index 8d41e94..353581f 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -47,6 +47,20 @@ ifeq ($(strip $(LOCAL_NO_FDO_SUPPORT)),)
LOCAL_LDFLAGS += $(TARGET_FDO_CFLAGS)
endif

+####################################################
+## Add -pg flags if profiling is turned on
+####################################################
+ifeq ($(strip $(LOCAL_PROFILE_MODULE)),true)
+ ifeq ($(TARGET_ARCH),arm)
+ LOCAL_CFLAGS += -fno-function-sections -fno-omit-frame-pointer -pg
+ # Prevent unresolve symbol from libgmon, so add libc to
+ # LOCAL_STATIC_LIBRARIES.
+ LOCAL_STATIC_LIBRARIES += libgmon libc
+ else
+ $(warning Profiling only support arm on current implementation.)
+ endif
+endif
+
###########################################################
## Define PRIVATE_ variables from global vars
###########################################################
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index ee28f21..709ff61 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -75,6 +75,7 @@ LOCAL_COPY_HEADERS:=
LOCAL_FORCE_STATIC_EXECUTABLE:=
LOCAL_ADDITIONAL_DEPENDENCIES:=
LOCAL_PRELINK_MODULE:=
+LOCAL_PROFILE_MODULE:=
LOCAL_COMPRESS_MODULE_SYMBOLS:=
LOCAL_STRIP_MODULE:=
LOCAL_POST_PROCESS_COMMAND:=true
diff --git a/core/shared_library.mk b/core/shared_library.mk
index 77d253f..7da2990 100644
--- a/core/shared_library.mk
+++ b/core/shared_library.mk
@@ -20,6 +20,9 @@ ifneq ($(strip $(OVERRIDE_BUILT_MODULE_PATH)),)
$(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
endif

+# Profiling don't support shared library
+LOCAL_PROFILE_MODULE := false
+
# Put the built targets of all shared libraries in a common directory
# to simplify the link line.
OVERRIDE_BUILT_MODULE_PATH := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)
--
1.7.4.4

Kito Cheng

unread,
Nov 15, 2011, 11:19:29 AM11/15/11
to 0xlab...@googlegroups.com, ever...@0xlab.org
Change-Id: I2bcc44bd076a0dbfb169e4efe27a283939ff7988
---
core/binary.mk | 15 +++++++++++++++

core/clear_vars.mk | 1 +
core/shared_library.mk | 3 +++
3 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/core/binary.mk b/core/binary.mk
index 8d41e94..b86594d 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -47,6 +47,21 @@ ifeq ($(strip $(LOCAL_NO_FDO_SUPPORT)),)
LOCAL_LDFLAGS += $(TARGET_FDO_CFLAGS)
endif

+####################################################
+## Add -pg flags if profiling is turned on
+####################################################
+ifeq ($(strip $(LOCAL_PROFILE_MODULE)),true)
+ ifeq ($(TARGET_ARCH),arm)

+ # -ffunction-sections and -fomit-frame-pointer are conflict with -pg

Reply all
Reply to author
Forward
0 new messages