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