fanghuilin / rpms / kernel

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