Discussion:
[PATCH 1/4] kbuild: Create new CFLAGS_REMOVE_(basename).o option
(too old to reply)
Steven Rostedt
2008-05-15 01:40:05 UTC
Permalink
We currently have a way to add special CFLAGS to code, but we do not have a
way to remove them if needed.

With the case of ftrace, some files should simply not be profiled. Adding
the -pg flag to these files is simply a waste, and adding "notrace" to each
and every function is ugly.

Currently we put in "Makefile turd" [1] to stop the compiler from adding -pg
to certain files. This was clumsy and awkward.

This patch now adds the revese of CFLAGS_(basename).o with
CFLAGS_REMOVE_(basename).o. This allows developers to prevent certain
CFLAGS from being used to compile files. For example, we can now do

CFLAGS_REMOVE_string.o = -pg

to remove the -pg option from the string.o file in the lib directory.

Note: a space delimited list of options may be added to the REMOVE macro.

[1] - what David Miller called the workaronud to remove -pg

Signed-off-by: Steven Rostedt <***@redhat.com>
---
scripts/Makefile.lib | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-sched-devel.git/scripts/Makefile.lib
===================================================================
--- linux-sched-devel.git.orig/scripts/Makefile.lib 2008-05-14 18:12:22.000000000 -0700
+++ linux-sched-devel.git/scripts/Makefile.lib 2008-05-14 18:12:26.000000000 -0700
@@ -96,7 +96,8 @@ basename_flags = -D"KBUILD_BASENAME=KBUI
modname_flags = $(if $(filter 1,$(words $(modname))),\
-D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")

-_c_flags = $(KBUILD_CFLAGS) $(ccflags-y) $(CFLAGS_$(basetarget).o)
+orig_c_flags = $(KBUILD_CFLAGS) $(ccflags-y) $(CFLAGS_$(basetarget).o)
+_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
_a_flags = $(KBUILD_AFLAGS) $(asflags-y) $(AFLAGS_$(basetarget).o)
_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Steven Rostedt
2008-05-15 01:40:07 UTC
Permalink
This patch removes the Makefile turd and uses the nice CFLAGS_REMOVE macro
in the x86/kernel directory.

Signed-off-by: Steven Rostedt <***@redhat.com>
---
arch/x86/kernel/Makefile | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

Index: linux-sched-devel.git/arch/x86/kernel/Makefile
===================================================================
--- linux-sched-devel.git.orig/arch/x86/kernel/Makefile 2008-05-14 18:12:21.000000000 -0700
+++ linux-sched-devel.git/arch/x86/kernel/Makefile 2008-05-14 18:24:43.000000000 -0700
@@ -8,10 +8,9 @@ CPPFLAGS_vmlinux.lds += -U$(UTS_MACHINE)

ifdef CONFIG_FTRACE
# Do not profile debug utilities
-ORIG_CFLAGS := $(KBUILD_CFLAGS)
-KBUILD_CFLAGS = $(if $(filter-out tsc_64 tsc_32 rtc,$(basename $(notdir $@))), \
- $(ORIG_CFLAGS), \
- $(subst -pg,,$(ORIG_CFLAGS)))
+CFLAGS_REMOVE_tsc_64.o = -pg
+CFLAGS_REMOVE_tsc_32.o = -pg
+CFLAGS_REMOVE_rtc.o = -pg
endif

#
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Steven Rostedt
2008-05-15 01:40:07 UTC
Permalink
This patch removes the Makefile turd and uses the nice CFLAGS_REMOVE macro
in the lib directory.

Signed-off-by: Steven Rostedt <***@redhat.com>
---
lib/Makefile | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-sched-devel.git/lib/Makefile
===================================================================
--- linux-sched-devel.git.orig/lib/Makefile 2008-05-14 18:24:01.000000000 -0700
+++ linux-sched-devel.git/lib/Makefile 2008-05-14 18:24:13.000000000 -0700
@@ -10,11 +10,11 @@ lib-y := ctype.o string.o vsprintf.o cmd

ifdef CONFIG_FTRACE
# Do not profile string.o, since it may be used in early boot or vdso
+CFLAGS_REMOVE_string.o = -pg
# Also do not profile any debug utilities
-ORIG_CFLAGS := $(KBUILD_CFLAGS)
-KBUILD_CFLAGS = $(if $(filter-out %debug debug% string%,$(basename $(notdir $@))), \
- $(ORIG_CFLAGS), \
- $(subst -pg,,$(ORIG_CFLAGS)))
+CFLAGS_REMOVE_spinlock_debug.o = -pg
+CFLAGS_REMOVE_list_debug.o = -pg
+CFLAGS_REMOVE_debugobjects.o = -pg
endif

lib-$(CONFIG_MMU) += ioremap.o
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Steven Rostedt
2008-05-15 01:40:11 UTC
Permalink
This patch removes the Makefile turd and uses the nice CFLAGS_REMOVE macro
in the kernel directory.

Signed-off-by: Steven Rostedt <***@redhat.com>
---
kernel/Makefile | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

Index: linux-sched-devel.git/kernel/Makefile
===================================================================
--- linux-sched-devel.git.orig/kernel/Makefile 2008-05-14 18:22:29.000000000 -0700
+++ linux-sched-devel.git/kernel/Makefile 2008-05-14 18:22:34.000000000 -0700
@@ -11,12 +11,16 @@ obj-y = sched.o fork.o exec_domain.o
hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \
notifier.o ksysfs.o pm_qos_params.o sched_clock.o

+CFLAGS_REMOVE_sched.o = -pg -mno-spe
+
ifdef CONFIG_FTRACE
-# Do not profile debug utilities
-ORIG_CFLAGS := $(KBUILD_CFLAGS)
-KBUILD_CFLAGS = $(if $(filter-out lockdep% %debug sched_clock,$(basename $(notdir $@))), \
- $(ORIG_CFLAGS), \
- $(subst -pg,,$(ORIG_CFLAGS)))
+# Do not trace debug files and internal ftrace files
+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_cgroup-debug.o = -pg
+CFLAGS_REMOVE_sched_clock.o = -pg
endif

obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Andi Kleen
2008-05-15 09:10:15 UTC
Permalink
Recently David Miller ported ftrace over to the sparc64. When I mentioned
to him a way to remove the "notrace" from all the functions in some
files done by using a dirty little hack, David (correctly) called it
"Makefile turd" and told us to stop doing that.
I then asked if a CFLAGS_REMOVE_foo.o = -pg would be more pleasing, and he
agreed.
Very nice. You should use that for the scheduler case to get rid of
"-fno-omit-frame-pointer"

-Andi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Loading...