build: Add ability to generate gprof output

Submitted by Cyrill Gorcunov on May 4, 2016, 11:56 a.m.

Details

Message ID 1462363001-17526-1-git-send-email-gorcunov@virtuozzo.com
State Rejected
Series "build: Add ability to generate gprof output"
Headers show

Commit Message

Cyrill Gorcunov May 4, 2016, 11:56 a.m.
Suitable for profiling. We've had this before 2.0.
As earlier, pie code is not profiled as well as
syscalls library.

So simply build as "make GMON=1".

Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
---
 Makefile        | 6 ++++++
 compel/Makefile | 6 +++---
 2 files changed, 9 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/Makefile b/Makefile
index 625cf31..57063c8 100644
--- a/Makefile
+++ b/Makefile
@@ -101,6 +101,12 @@  else
         CFLAGS		+= -O2 -g
 endif
 
+ifeq ($(GMON),1)
+        CFLAGS		+= -pg
+        GMONLDOPT	+= -pg
+export GMON GMONLDOPT
+endif
+
 CFLAGS			+= $(WARNINGS) $(DEFINES)
 
 #
diff --git a/compel/Makefile b/compel/Makefile
index 96709c6..5e4bd7b 100644
--- a/compel/Makefile
+++ b/compel/Makefile
@@ -4,9 +4,9 @@  ccflags-y	+= -iquote criu/include
 ccflags-y	+= -iquote compel/include
 ccflags-y	+= -DCOMPEL_VERSION=\"$(COMPEL_SO_VERSION_MAJOR).$(COMPEL_SO_VERSION_MINOR)\"
 
-host-ccflags-y	+= $(ccflags-y)
-HOSTCFLAGS	+= $(WARNINGS) $(DEFINES)
-HOSTLDFLAGS	+= $(LDFLAGS)
+host-ccflags-y	+= $(filter-out -pg $(CFLAGS-GCOV),$(ccflags-y))
+HOSTCFLAGS	+= $(filter-out -pg $(CFLAGS-GCOV),$(WARNINGS) $(DEFINES))
+HOSTLDFLAGS	+= $(filter-out -pg $(CFLAGS-GCOV),$(LDFLAGS))
 
 hostprogs-y	+= compel
 compel-objs	+= src/main.o

Comments

Dmitry Safonov May 4, 2016, 12:06 p.m.
On 05/04/2016 02:56 PM, Cyrill Gorcunov wrote:
> Suitable for profiling. We've had this before 2.0.
> As earlier, pie code is not profiled as well as
> syscalls library.
>
> So simply build as "make GMON=1".
>
> Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
> ---
>   Makefile        | 6 ++++++
>   compel/Makefile | 6 +++---
>   2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 625cf31..57063c8 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -101,6 +101,12 @@ else
>           CFLAGS		+= -O2 -g
>   endif
>   
> +ifeq ($(GMON),1)
> +        CFLAGS		+= -pg
> +        GMONLDOPT	+= -pg
> +export GMON GMONLDOPT
> +endif
> +
>   CFLAGS			+= $(WARNINGS) $(DEFINES)
>   
>   #
> diff --git a/compel/Makefile b/compel/Makefile
> index 96709c6..5e4bd7b 100644
> --- a/compel/Makefile
> +++ b/compel/Makefile
> @@ -4,9 +4,9 @@ ccflags-y	+= -iquote criu/include
>   ccflags-y	+= -iquote compel/include
>   ccflags-y	+= -DCOMPEL_VERSION=\"$(COMPEL_SO_VERSION_MAJOR).$(COMPEL_SO_VERSION_MINOR)\"
>   
> -host-ccflags-y	+= $(ccflags-y)
> -HOSTCFLAGS	+= $(WARNINGS) $(DEFINES)
> -HOSTLDFLAGS	+= $(LDFLAGS)
> +host-ccflags-y	+= $(filter-out -pg $(CFLAGS-GCOV),$(ccflags-y))
> +HOSTCFLAGS	+= $(filter-out -pg $(CFLAGS-GCOV),$(WARNINGS) $(DEFINES))
> +HOSTLDFLAGS	+= $(filter-out -pg $(CFLAGS-GCOV),$(LDFLAGS))
>   
>   hostprogs-y	+= compel
>   compel-objs	+= src/main.o
Pavel Emelianov May 6, 2016, 12:01 p.m.
Applied