public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Kbuild: Add option to set -femit-struct-debug-baseonly
@ 2010-07-14 13:43 Andi Kleen
  2010-07-14 15:22 ` Michal Marek
  0 siblings, 1 reply; 2+ messages in thread
From: Andi Kleen @ 2010-07-14 13:43 UTC (permalink / raw)
  To: mmarek, linux-kbuild, linux-kernel, ak

Kbuild: Add option to set -femit-struct-debug-baseonly 

Newer gcc has a -femit-struct-debug-baseonly option that dramatically
reduces the size of object files with debug info. What it does
is to only emit type information for structures when the structures
are defined in the same file or in a header file.

This means the type information for most headers are not included.
This is not good when the type information is actually
needed (e.g. with kgdb or systemtap) 

But often kernel hackers only care about line numbers and don't
need all the type information anyways. In this case setting
the option can be a big win:

A build dir for a specific x86-64 configuration with gcc 4.5
shrunk from 2.3G to 1.2G. The compilation was also nearly a minute
faster.

Signed-off-by: Andi Kleen <ak@linux.intel.com>

---
 Makefile          |    4 ++++
 lib/Kconfig.debug |   12 ++++++++++++
 2 files changed, 16 insertions(+)

Index: linux-2.6.34-ak/Makefile
===================================================================
--- linux-2.6.34-ak.orig/Makefile
+++ linux-2.6.34-ak/Makefile
@@ -554,6 +554,10 @@ KBUILD_CFLAGS	+= -g
 KBUILD_AFLAGS	+= -gdwarf-2
 endif
 
+ifdef CONFIG_DEBUG_INFO_REDUCED
+KBUILD_CFLAGS 	+= $(call cc-option, -femit-struct-debug-baseonly)
+endif
+
 ifdef CONFIG_FUNCTION_TRACER
 KBUILD_CFLAGS	+= -pg
 endif
Index: linux-2.6.34-ak/lib/Kconfig.debug
===================================================================
--- linux-2.6.34-ak.orig/lib/Kconfig.debug
+++ linux-2.6.34-ak/lib/Kconfig.debug
@@ -616,6 +616,18 @@ config DEBUG_INFO
 
 	  If unsure, say N.
 
+config DEBUG_INFO_REDUCED
+	bool "Reduce debugging information"
+	depends on DEBUG_INFO
+	help
+	  If you say Y here gcc is instructed to generate less debugging information
+          for structure types. This means that tools that need full debugging information
+          (like kgdb or systemtap) won't be happy. But if you merely need debugging
+          information to resolve line numbers there is no loss.
+          Advantage is that build directory object sizes shrink dramatically over
+          a full DEBUG_INFO build and compile times are reduced too.
+          Only works with newer gcc versions.
+
 config DEBUG_VM
 	bool "Debug VM"
 	depends on DEBUG_KERNEL

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Kbuild: Add option to set -femit-struct-debug-baseonly
  2010-07-14 13:43 [PATCH] Kbuild: Add option to set -femit-struct-debug-baseonly Andi Kleen
@ 2010-07-14 15:22 ` Michal Marek
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Marek @ 2010-07-14 15:22 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-kbuild, linux-kernel, ak

On 07/14/2010 03:43 PM, Andi Kleen wrote:
> Kbuild: Add option to set -femit-struct-debug-baseonly 
> 
> Newer gcc has a -femit-struct-debug-baseonly option that dramatically
> reduces the size of object files with debug info. What it does
> is to only emit type information for structures when the structures
> are defined in the same file or in a header file.
> 
> This means the type information for most headers are not included.
> This is not good when the type information is actually
> needed (e.g. with kgdb or systemtap) 
> 
> But often kernel hackers only care about line numbers and don't
> need all the type information anyways. In this case setting
> the option can be a big win:
> 
> A build dir for a specific x86-64 configuration with gcc 4.5
> shrunk from 2.3G to 1.2G. The compilation was also nearly a minute
> faster.
> 
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> 
> ---
>  Makefile          |    4 ++++
>  lib/Kconfig.debug |   12 ++++++++++++
>  2 files changed, 16 insertions(+)
> 
> Index: linux-2.6.34-ak/Makefile
> ===================================================================
> --- linux-2.6.34-ak.orig/Makefile
> +++ linux-2.6.34-ak/Makefile
> @@ -554,6 +554,10 @@ KBUILD_CFLAGS	+= -g
>  KBUILD_AFLAGS	+= -gdwarf-2
>  endif
>  
> +ifdef CONFIG_DEBUG_INFO_REDUCED
> +KBUILD_CFLAGS 	+= $(call cc-option, -femit-struct-debug-baseonly)
> +endif
> +
>  ifdef CONFIG_FUNCTION_TRACER
>  KBUILD_CFLAGS	+= -pg
>  endif
> Index: linux-2.6.34-ak/lib/Kconfig.debug
> ===================================================================
> --- linux-2.6.34-ak.orig/lib/Kconfig.debug
> +++ linux-2.6.34-ak/lib/Kconfig.debug
> @@ -616,6 +616,18 @@ config DEBUG_INFO
>  
>  	  If unsure, say N.
>  
> +config DEBUG_INFO_REDUCED
> +	bool "Reduce debugging information"
> +	depends on DEBUG_INFO
> +	help
> +	  If you say Y here gcc is instructed to generate less debugging information
> +          for structure types. This means that tools that need full debugging information
> +          (like kgdb or systemtap) won't be happy. But if you merely need debugging
> +          information to resolve line numbers there is no loss.
> +          Advantage is that build directory object sizes shrink dramatically over
> +          a full DEBUG_INFO build and compile times are reduced too.
> +          Only works with newer gcc versions.
> +

I reformatted this help text to not wrap in a 80-column terminal and
applied the patch to the kbuild tree.

thanks,
Michal

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-07-14 15:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-14 13:43 [PATCH] Kbuild: Add option to set -femit-struct-debug-baseonly Andi Kleen
2010-07-14 15:22 ` Michal Marek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox