ignatenkobrain / rpms / kernel

Forked from rpms/kernel 3 years ago
Clone
e336be
From: Josh Stone <jistone@redhat.com>
e336be
Date: Fri, 21 Nov 2014 10:40:00 -0800
e336be
Subject: [PATCH] Kbuild: Add an option to enable GCC VTA
e336be
MIME-Version: 1.0
e336be
Content-Type: text/plain; charset=UTF-8
e336be
Content-Transfer-Encoding: 8bit
e336be
e336be
Due to recent codegen issues, gcc -fvar-tracking-assignments was
e336be
unconditionally disabled in commit 2062afb4f804a ("Fix gcc-4.9.0
e336be
miscompilation of load_balance() in scheduler").  However, this reduces
e336be
the debuginfo coverage for variable locations, especially in inline
e336be
functions.  VTA is certainly not perfect either in those cases, but it
e336be
is much better than without.  With compiler versions that have fixed the
e336be
codegen bugs, we would prefer to have the better details for SystemTap,
e336be
and surely other debuginfo consumers like perf will benefit as well.
e336be
e336be
This patch simply makes CONFIG_DEBUG_INFO_VTA an option.  I considered
e336be
Frank and Linus's discussion of a cc-option-like -fcompare-debug test,
e336be
but I'm convinced that a narrow test of an arch-specific codegen issue
e336be
is not really useful.  GCC has their own regression tests for this, so
e336be
I'd suggest GCC_COMPARE_DEBUG=-fvar-tracking-assignments-toggle is more
e336be
useful for kernel developers to test confidence.
e336be
e336be
In fact, I ran into a couple more issues when testing for this patch[1],
e336be
although neither of those had any codegen impact.
e336be
 [1] https://bugzilla.redhat.com/show_bug.cgi?id=1140872
e336be
e336be
With gcc-4.9.2-1.fc22, I can now build v3.18-rc5 with Fedora's i686 and
e336be
x86_64 configs, and this is completely clean with GCC_COMPARE_DEBUG.
e336be
e336be
Cc: Frank Ch. Eigler <fche@redhat.com>
e336be
Cc: Jakub Jelinek <jakub@redhat.com>
e336be
Cc: Josh Boyer <jwboyer@fedoraproject.org>
e336be
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
e336be
Cc: Linus Torvalds <torvalds@linux-foundation.org>
e336be
Cc: Andrew Morton <akpm@linux-foundation.org>
e336be
Cc: Markus Trippelsdorf <markus@trippelsdorf.de>
e336be
Cc: Michel Dänzer <michel@daenzer.net>
e336be
Signed-off-by: Josh Stone <jistone@redhat.com>
e336be
---
e336be
 Makefile          |  4 ++++
e336be
 lib/Kconfig.debug | 18 +++++++++++++++++-
e336be
 2 files changed, 21 insertions(+), 1 deletion(-)
e336be
e336be
diff --git a/Makefile b/Makefile
e336be
index 257ef5892ab7..3cc6f4477e78 100644
e336be
--- a/Makefile
e336be
+++ b/Makefile
e336be
@@ -701,7 +701,11 @@ KBUILD_CFLAGS	+= -fomit-frame-pointer
e336be
 endif
e336be
 endif
e336be
 
e336be
+ifdef CONFIG_DEBUG_INFO_VTA
e336be
+KBUILD_CFLAGS   += $(call cc-option, -fvar-tracking-assignments)
e336be
+else
e336be
 KBUILD_CFLAGS   += $(call cc-option, -fno-var-tracking-assignments)
e336be
+endif
e336be
 
e336be
 ifdef CONFIG_DEBUG_INFO
e336be
 ifdef CONFIG_DEBUG_INFO_SPLIT
e336be
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
e336be
index e2894b23efb6..d98afe18f704 100644
e336be
--- a/lib/Kconfig.debug
e336be
+++ b/lib/Kconfig.debug
e336be
@@ -165,7 +165,23 @@ config DEBUG_INFO_DWARF4
e336be
 	  Generate dwarf4 debug info. This requires recent versions
e336be
 	  of gcc and gdb. It makes the debug information larger.
e336be
 	  But it significantly improves the success of resolving
e336be
-	  variables in gdb on optimized code.
e336be
+	  variables in gdb on optimized code.  The gcc docs also
e336be
+	  recommend enabling -fvar-tracking-assignments for maximum
e336be
+	  benefit. (see DEBUG_INFO_VTA)
e336be
+
e336be
+config DEBUG_INFO_VTA
e336be
+	bool "Enable var-tracking-assignments for debuginfo"
e336be
+	depends on DEBUG_INFO
e336be
+	help
e336be
+	  Enable gcc -fvar-tracking-assignments for improved debug
e336be
+	  information on variable locations in optimized code.  Per
e336be
+	  gcc, DEBUG_INFO_DWARF4 is recommended for best use of VTA.
e336be
+
e336be
+	  VTA has been implicated in codegen bugs (gcc PR61801,
e336be
+	  PR61904), so this may deserve some caution.  One can set
e336be
+	  GCC_COMPARE_DEBUG=-fvar-tracking-assignments-toggle in the
e336be
+	  environment to automatically compile everything both ways,
e336be
+	  generating an error if anything differs.
e336be
 
e336be
 config GDB_SCRIPTS
e336be
 	bool "Provide GDB scripts for kernel debugging"