ftrace: allow architectures to specify ftrace compile options
authorHeiko Carstens <heiko.carstens@de.ibm.com>
Fri, 9 Jan 2015 12:06:33 +0000 (13:06 +0100)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Thu, 29 Jan 2015 08:19:19 +0000 (09:19 +0100)
If the kernel is compiled with function tracer support the -pg compile option
is passed to gcc to generate extra code into the prologue of each function.

This patch replaces the "open-coded" -pg compile flag with a CC_FLAGS_FTRACE
makefile variable which architectures can override if a different option
should be used for code generation.

Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Makefile
kernel/Makefile
kernel/events/Makefile
kernel/locking/Makefile
kernel/sched/Makefile
kernel/trace/Makefile
lib/Makefile
scripts/Makefile.build

index fd80c6e9bc2367f79f47edebb15649d23d341791..11c6fe8f708fee45d9c2ffde5aefa10b58a1bc08 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -724,10 +724,14 @@ KBUILD_CFLAGS     += $(call cc-option, -femit-struct-debug-baseonly) \
 endif
 
 ifdef CONFIG_FUNCTION_TRACER
+ifndef CC_FLAGS_FTRACE
+CC_FLAGS_FTRACE := -pg
+endif
+export CC_FLAGS_FTRACE
 ifdef CONFIG_HAVE_FENTRY
 CC_USING_FENTRY        := $(call cc-option, -mfentry -DCC_USING_FENTRY)
 endif
-KBUILD_CFLAGS  += -pg $(CC_USING_FENTRY)
+KBUILD_CFLAGS  += $(CC_FLAGS_FTRACE) $(CC_USING_FENTRY)
 KBUILD_AFLAGS  += $(CC_USING_FENTRY)
 ifdef CONFIG_DYNAMIC_FTRACE
        ifdef CONFIG_HAVE_C_RECORDMCOUNT
index a59481a3fa6cffeb4e8d6a040df6be524394bbb9..13af308f2460325c392997d2aa08cdc499310354 100644 (file)
@@ -13,8 +13,8 @@ obj-y     = fork.o exec_domain.o panic.o \
 
 ifdef CONFIG_FUNCTION_TRACER
 # Do not trace debug files and internal ftrace files
-CFLAGS_REMOVE_cgroup-debug.o = -pg
-CFLAGS_REMOVE_irq_work.o = -pg
+CFLAGS_REMOVE_cgroup-debug.o = $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_irq_work.o = $(CC_FLAGS_FTRACE)
 endif
 
 # cond_syscall is currently not LTO compatible
index 103f5d147b2f9f483b8c3920178d4bdbfb74e400..2925188f50eabe18bd14d2d3752651dcc67b59ef 100644 (file)
@@ -1,5 +1,5 @@
 ifdef CONFIG_FUNCTION_TRACER
-CFLAGS_REMOVE_core.o = -pg
+CFLAGS_REMOVE_core.o = $(CC_FLAGS_FTRACE)
 endif
 
 obj-y := core.o ring_buffer.o callchain.o
index 8541bfdfd232bb4213629f265cbb68a6bfb50c72..4caca3f7af533bed0ebf0f674f0dbb9651162f44 100644 (file)
@@ -2,10 +2,10 @@
 obj-y += mutex.o semaphore.o rwsem.o mcs_spinlock.o
 
 ifdef CONFIG_FUNCTION_TRACER
-CFLAGS_REMOVE_lockdep.o = -pg
-CFLAGS_REMOVE_lockdep_proc.o = -pg
-CFLAGS_REMOVE_mutex-debug.o = -pg
-CFLAGS_REMOVE_rtmutex-debug.o = -pg
+CFLAGS_REMOVE_lockdep.o = $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_lockdep_proc.o = $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_mutex-debug.o = $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_rtmutex-debug.o = $(CC_FLAGS_FTRACE)
 endif
 
 obj-$(CONFIG_DEBUG_MUTEXES) += mutex-debug.o
index ab32b7b0db5c6b30b4cc64e61e6a857fb51c87e6..46be8702487561cd88a7895fea8c6401d72e9ce6 100644 (file)
@@ -1,5 +1,5 @@
 ifdef CONFIG_FUNCTION_TRACER
-CFLAGS_REMOVE_clock.o = -pg
+CFLAGS_REMOVE_clock.o = $(CC_FLAGS_FTRACE)
 endif
 
 ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y)
index 67d6369ddf83e632dcd014358c7d71bd17816fe7..9a7e0e60a1a89e51463c83e6ab32462548af9794 100644 (file)
@@ -3,11 +3,11 @@
 
 ifdef CONFIG_FUNCTION_TRACER
 ORIG_CFLAGS := $(KBUILD_CFLAGS)
-KBUILD_CFLAGS = $(subst -pg,,$(ORIG_CFLAGS))
+KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS))
 
 ifdef CONFIG_FTRACE_SELFTEST
 # selftest needs instrumentation
-CFLAGS_trace_selftest_dynamic.o = -pg
+CFLAGS_trace_selftest_dynamic.o = $(CC_FLAGS_FTRACE)
 obj-y += trace_selftest_dynamic.o
 endif
 endif
index 3c3b30b9e020d2e4bc02edc73575555641aad057..f3f73e50519a87e7f837e4d5e909273bd0561503 100644 (file)
@@ -4,7 +4,7 @@
 
 ifdef CONFIG_FUNCTION_TRACER
 ORIG_CFLAGS := $(KBUILD_CFLAGS)
-KBUILD_CFLAGS = $(subst -pg,,$(ORIG_CFLAGS))
+KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS))
 endif
 
 lib-y := ctype.o string.o vsprintf.o cmdline.o \
index 649ce68440331cdd5c5446ac76e01a487d2bcf6a..01df30af4d4a50f7ffec08993115b2e412128d1f 100644 (file)
@@ -234,8 +234,9 @@ sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH
        "$(if $(part-of-module),1,0)" "$(@)";
 recordmcount_source := $(srctree)/scripts/recordmcount.pl
 endif
-cmd_record_mcount =                                            \
-       if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then    \
+cmd_record_mcount =                                            \
+       if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" =   \
+            "$(CC_FLAGS_FTRACE)" ]; then                       \
                $(sub_cmd_record_mcount)                        \
        fi;
 endif