Subject: x86: Add an option to compile with -ffunction-sections -fdata-sections
Date: Wed, 4 Feb 2009 05:26:04 -0500 (EST)
From: Anders Kaseorg <andersk@MIT.EDU>

On Wed, 4 Feb 2009, Rusty Russell wrote:
> You need to make this depend on X86, otherwise allmodconfig will turn it on
> and break other archs.

Okay.

> What's the conflict with FTRACE?

This actually should have changed from FTRACE to FUNCTION_TRACER as of
commit 606576ce816603d9fe1fb453a88bc6eea16ca709 in v2.6.28-rc3.

The conflict is that FUNCTION_TRACER enables KBUILD_CFLAGS += -pg, and
passing -pg to current gcc causes it to emit a warning and disable
-ffunction-sections:
  <http://gcc.gnu.org/ml/gcc-help/2008-11/msg00128.html>

(If this gcc problem is resolved in the future, the code should work fine
with FUNCTION_TRACER.  A small amount of extra matching code is needed to
handle DYNAMIC_FTRACE.)

Patch for these two issues:
---
 arch/x86/Kconfig  |    1 +
 lib/Kconfig.debug |    6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -28,6 +28,7 @@ config X86
 	select HAVE_KPROBES
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARCH_WANT_FRAME_POINTERS
+	select HAVE_FUNCTION_DATA_SECTIONS
 	select HAVE_KRETPROBES
 	select HAVE_FTRACE_MCOUNT_RECORD
 	select HAVE_DYNAMIC_FTRACE
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -591,9 +591,13 @@ config FRAME_POINTER
 	  larger and slower, but it gives very useful debugging information
 	  in case of kernel bugs. (precise oopses/stacktraces/warnings)
 
+config HAVE_FUNCTION_DATA_SECTIONS
+	bool
+
 config FUNCTION_DATA_SECTIONS
 	bool "Compile with -ffunction-sections -fdata-sections"
-	depends on !FTRACE
+	depends on HAVE_FUNCTION_DATA_SECTIONS
+	depends on !FUNCTION_TRACER
 	help
 	  If you say Y here the compiler will give each function
 	  and data structure its own ELF section.
