X86: Makefile: Replace -pg with CC_FLAGS_FTRACE
Subsystems (5)
PATCH v2 1/1 X86: Makefile: Replace -pg with CC_FLAGS_FTRACE
In preparation for x86 supporting ftrace built on other compiler options, let's have the x86 Makefiles remove the $(CC_FLAGS_FTRACE) flags, whatever these may be, rather than assuming '-pg'.
There should be no functional change as a result of this patch.
---
v2: add the same change for the other Makefile in arch/x86 directory.
arch/x86/entry/vdso/Makefile | 8 ++++---- arch/x86/kernel/Makefile | 16 ++++++++-------- arch/x86/kernel/cpu/Makefile | 4 ++-- arch/x86/lib/Makefile | 2 +- arch/x86/mm/Makefile | 4 ++-- arch/x86/xen/Makefile | 6 +++--- 6 files changed, 20 insertions(+), 20 deletions(-)
arch/x86/entry/vdso/Makefile +4 -4
@@ -96,10 +96,10 @@ $(vobjs): KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO) $(GCC_PLUGINS_CFLAGS) $( # # vDSO code runs in userspace and -pg doesn't help with profiling anyway. # -CFLAGS_REMOVE_vclock_gettime.o = -pg -CFLAGS_REMOVE_vdso32/vclock_gettime.o = -pg -CFLAGS_REMOVE_vgetcpu.o = -pg -CFLAGS_REMOVE_vsgx.o = -pg +CFLAGS_REMOVE_vclock_gettime.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_vdso32/vclock_gettime.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_vgetcpu.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_vsgx.o = $(CC_FLAGS_FTRACE) # # X32 processes use x32 vDSO to access 64bit kernel data.
arch/x86/kernel/Makefile +8 -8
@@ -13,14 +13,14 @@ CPPFLAGS_vmlinux.lds += -U$(UTS_MACHINE) ifdef CONFIG_FUNCTION_TRACER # Do not profile debug and lowlevel utilities -CFLAGS_REMOVE_tsc.o = -pg -CFLAGS_REMOVE_paravirt-spinlocks.o = -pg -CFLAGS_REMOVE_pvclock.o = -pg -CFLAGS_REMOVE_kvmclock.o = -pg -CFLAGS_REMOVE_ftrace.o = -pg -CFLAGS_REMOVE_early_printk.o = -pg -CFLAGS_REMOVE_head64.o = -pg -CFLAGS_REMOVE_sev-es.o = -pg +CFLAGS_REMOVE_tsc.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_paravirt-spinlocks.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_pvclock.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_kvmclock.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_early_printk.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_head64.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_sev-es.o = $(CC_FLAGS_FTRACE) endif KASAN_SANITIZE_head$(BITS).o := n
arch/x86/kernel/cpu/Makefile +2 -2
@@ -5,8 +5,8 @@ # Don't trace early stages of a secondary CPU boot ifdef CONFIG_FUNCTION_TRACER -CFLAGS_REMOVE_common.o = -pg -CFLAGS_REMOVE_perf_event.o = -pg +CFLAGS_REMOVE_common.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_perf_event.o = $(CC_FLAGS_FTRACE) endif # If these files are instrumented, boot hangs during the first second.
arch/x86/lib/Makefile +1 -1
@@ -21,7 +21,7 @@ KASAN_SANITIZE_cmdline.o := n KCSAN_SANITIZE_cmdline.o := n ifdef CONFIG_FUNCTION_TRACER -CFLAGS_REMOVE_cmdline.o = -pg +CFLAGS_REMOVE_cmdline.o = $(CC_FLAGS_FTRACE) endif CFLAGS_cmdline.o := -fno-stack-protector -fno-jump-tables
arch/x86/mm/Makefile +2 -2
@@ -12,8 +12,8 @@ KASAN_SANITIZE_mem_encrypt_identity.o := n KCSAN_SANITIZE := n ifdef CONFIG_FUNCTION_TRACER -CFLAGS_REMOVE_mem_encrypt.o = -pg -CFLAGS_REMOVE_mem_encrypt_identity.o = -pg +CFLAGS_REMOVE_mem_encrypt.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_mem_encrypt_identity.o = $(CC_FLAGS_FTRACE) endif obj-y := init.o init_$(BITS).o fault.o ioremap.o extable.o mmap.o \
arch/x86/xen/Makefile +3 -3
@@ -2,9 +2,9 @@ ifdef CONFIG_FUNCTION_TRACER # Do not profile debug and lowlevel utilities -CFLAGS_REMOVE_spinlock.o = -pg -CFLAGS_REMOVE_time.o = -pg -CFLAGS_REMOVE_irq.o = -pg +CFLAGS_REMOVE_spinlock.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_time.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_irq.o = $(CC_FLAGS_FTRACE) endif # Make sure early boot has no stackprotector
Signature · 1 line
2.20.1
Adding Steven Rostedt (ftrace maintainer).
Quoted 128 lines · zhaoxiao
In preparation for x86 supporting ftrace built on other compiler options, let's have the x86 Makefiles remove the $(CC_FLAGS_FTRACE) flags, whatever these may be, rather than assuming '-pg'.
There should be no functional change as a result of this patch.
Signed-off-by zhaoxiao <[email protected]>---
v2: add the same change for the otherMakefileinarch/x86directory.arch/x86/entry/vdso/Makefile | 8 ++++---- arch/x86/kernel/Makefile | 16 ++++++++-------- arch/x86/kernel/cpu/Makefile | 4 ++-- arch/x86/lib/Makefile | 2 +- arch/x86/mm/Makefile | 4 ++-- arch/x86/xen/Makefile | 6 +++--- 6 files changed, 20 insertions(+), 20 deletions(-)arch/x86/entry/vdso/Makefile +4
-4@@ -96,10 +96,10 @@ $(vobjs): KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO) $(GCC_PLUGINS_CFLAGS) $( # # vDSO code runs in userspace and -pg doesn't help with profiling anyway. # -CFLAGS_REMOVE_vclock_gettime.o = -pg -CFLAGS_REMOVE_vdso32/vclock_gettime.o = -pg -CFLAGS_REMOVE_vgetcpu.o = -pg -CFLAGS_REMOVE_vsgx.o = -pg +CFLAGS_REMOVE_vclock_gettime.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_vdso32/vclock_gettime.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_vgetcpu.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_vsgx.o = $(CC_FLAGS_FTRACE) # # X32 processes use x32 vDSO to access 64bit kernel data.arch/x86/kernel/Makefile +8
-8@@ -13,14 +13,14 @@ CPPFLAGS_vmlinux.lds += -U$(UTS_MACHINE) ifdef CONFIG_FUNCTION_TRACER # Do not profile debug and lowlevel utilities -CFLAGS_REMOVE_tsc.o = -pg -CFLAGS_REMOVE_paravirt-spinlocks.o = -pg -CFLAGS_REMOVE_pvclock.o = -pg -CFLAGS_REMOVE_kvmclock.o = -pg -CFLAGS_REMOVE_ftrace.o = -pg -CFLAGS_REMOVE_early_printk.o = -pg -CFLAGS_REMOVE_head64.o = -pg -CFLAGS_REMOVE_sev-es.o = -pg +CFLAGS_REMOVE_tsc.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_paravirt-spinlocks.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_pvclock.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_kvmclock.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_early_printk.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_head64.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_sev-es.o = $(CC_FLAGS_FTRACE) endif KASAN_SANITIZE_head$(BITS).o := narch/x86/kernel/cpu/Makefile +2
-2@@ -5,8 +5,8 @@ # Don't trace early stages of a secondary CPU boot ifdef CONFIG_FUNCTION_TRACER -CFLAGS_REMOVE_common.o = -pg -CFLAGS_REMOVE_perf_event.o = -pg +CFLAGS_REMOVE_common.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_perf_event.o = $(CC_FLAGS_FTRACE) endif # If these files are instrumented, boot hangs during the first second.arch/x86/lib/Makefile +1
-1@@ -21,7 +21,7 @@ KASAN_SANITIZE_cmdline.o := n KCSAN_SANITIZE_cmdline.o := n ifdef CONFIG_FUNCTION_TRACER -CFLAGS_REMOVE_cmdline.o = -pg +CFLAGS_REMOVE_cmdline.o = $(CC_FLAGS_FTRACE) endif CFLAGS_cmdline.o := -fno-stack-protector -fno-jump-tablesarch/x86/mm/Makefile +2
-2@@ -12,8 +12,8 @@ KASAN_SANITIZE_mem_encrypt_identity.o := n KCSAN_SANITIZE := n ifdef CONFIG_FUNCTION_TRACER -CFLAGS_REMOVE_mem_encrypt.o = -pg -CFLAGS_REMOVE_mem_encrypt_identity.o = -pg +CFLAGS_REMOVE_mem_encrypt.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_mem_encrypt_identity.o = $(CC_FLAGS_FTRACE) endif obj-y := init.o init_$(BITS).o fault.o ioremap.o extable.o mmap.o \arch/x86/xen/Makefile +3
-3@@ -2,9 +2,9 @@ ifdef CONFIG_FUNCTION_TRACER # Do not profile debug and lowlevel utilities -CFLAGS_REMOVE_spinlock.o = -pg -CFLAGS_REMOVE_time.o = -pg -CFLAGS_REMOVE_irq.o = -pg +CFLAGS_REMOVE_spinlock.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_time.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_irq.o = $(CC_FLAGS_FTRACE) endif # Make sure early boot has no stackprotectorSignature · 1 line
2.20.1
Signature · 1 line
Josh
Steven Rostedt
Acked-byQuoted 1 line · On Fri, 16 Apr 2021 10:12:58 -0500 Josh Poimboeuf <[email protected]> wrote:
Adding Steven Rostedt (ftrace maintainer).
Thanks.
Quoted 8 lines · zhaoxiao
Quoted 6 lines
In preparation for x86 supporting ftrace built on other compiler options, let's have the x86 Makefiles remove the $(CC_FLAGS_FTRACE) flags, whatever these may be, rather than assuming '-pg'.
There should be no functional change as a result of this patch.
Quoted 11 lines
Quoted 11 lines
Signed-off-by zhaoxiao <[email protected]>---
v2: add the same change for the otherMakefileinarch/x86directory.arch/x86/entry/vdso/Makefile | 8 ++++---- arch/x86/kernel/Makefile | 16 ++++++++-------- arch/x86/kernel/cpu/Makefile | 4 ++-- arch/x86/lib/Makefile | 2 +- arch/x86/mm/Makefile | 4 ++-- arch/x86/xen/Makefile | 6 +++--- 6 files changed, 20 insertions(+), 20 deletions(-)
I'm good with switching "-pg" over to "$(CC_FLAGS_FTRACE)" globally.
-- Steve
Quoted 3 lines · zhaoxiao
In preparation for x86 supporting ftrace built on other compiler options, let's have the x86 Makefiles remove the $(CC_FLAGS_FTRACE) flags, whatever these may be, rather than assuming '-pg'.
s/let's have the/make the/
Quoted 1 line
There should be no functional change as a result of this patch.
Should be? Either you know that there is no functional change or not. If you're unsure why are you posting it at all?
So this wants to be:
No functional change.
Other than that and the fact that this is incomplete as it fails to catch _all_ instances of -pg in arch/x86 and also leaves stale comments around I'm ok with the intent.
# git grep '\-pg' arch/x86/ arch/x86/entry/vdso/Makefile:# vDSO code runs in userspace and -pg doesn't help with profiling anyway. arch/x86/kernel/ftrace_64.S: * gcc -pg option adds a call to 'mcount' in most functions. arch/x86/purgatory/Makefile:# Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That arch/x86/um/vdso/Makefile:# vDSO code runs in userspace and -pg doesn't help with profiling anyway. arch/x86/um/vdso/Makefile:CFLAGS_REMOVE_vdso-note.o = -pg -fprofile-arcs -ftest-coverage arch/x86/um/vdso/Makefile:CFLAGS_REMOVE_um_vdso.o = -pg -fprofile-arcs -ftest-coverage
grep is not rocket science ...
Thanks,
tglx