[CRIU] [PATCH] Add ability to compile program with gprof output
Cyrill Gorcunov
gorcunov at openvz.org
Fri Feb 7 08:46:45 PST 2014
To be able to profile CRIU with gprof support we need a special flag
passed to the compiler and linker. But same time we can't build parasite
code with prof support because it'll call for mcount() service routine
for which we don't have any stub yet (and even if we had there are
other tech details involved). Thus PIE code won't be profiled.
To compile with prof support make it as
make DEBUG=1 GMON=1
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
Makefile | 7 ++++++-
pie/Makefile | 8 ++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index f8ee59a6af4a..41748f188e97 100644
--- a/Makefile
+++ b/Makefile
@@ -100,6 +100,11 @@ else
CFLAGS += -O2
endif
+ifeq ($(GMON),1)
+ CFLAGS += -pg
+ GMONLDOPT = -pg
+endif
+
CFLAGS += $(WARNINGS) $(DEFINES)
SYSCALL-LIB := arch/$(ARCH)/syscalls.built-in.o
ARCH-LIB := arch/$(ARCH)/crtools.built-in.o
@@ -167,7 +172,7 @@ PROGRAM-BUILTINS += $(ARCH_DIR)/vdso-pie.o
$(PROGRAM): $(SYSCALL-LIB) $(ARCH-LIB) $(PROGRAM-BUILTINS)
$(E) " LINK " $@
- $(Q) $(CC) $(CFLAGS) $^ $(LIBS) $(LDFLAGS) -rdynamic -o $@
+ $(Q) $(CC) $(CFLAGS) $^ $(LIBS) $(LDFLAGS) $(GMONLDOPT) -rdynamic -o $@
zdtm: all
$(Q) $(MAKE) -C test/zdtm all
diff --git a/pie/Makefile b/pie/Makefile
index dbe6d6bba8a8..c7cf76289d25 100644
--- a/pie/Makefile
+++ b/pie/Makefile
@@ -14,6 +14,14 @@ restorer-obj-e += $(ARCH_DIR)/restorer.o
restorer-obj-e += $(ARCH_DIR)/vdso-pie.o
restorer-libs-e += $(SYSCALL-LIB)
+#
+# We can't provide proper mount implementation
+# in parasite code -- it requires run-time rellocation
+# applications, which is not the target of the
+# project.
+#
+CFLAGS := $(filter-out -pg,$(CFLAGS))
+
cflags-y += -DCR_NOGLIBC -fpie -Wa,--noexecstack -fno-stack-protector
ifeq ($(ARCH), arm)
cflags-y += -marm
--
1.8.3.1
More information about the CRIU
mailing list