From: "Frank Ch. Eigler" <fche@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: "Josh Stone" <jistone@redhat.com>,
"Jakub Jelinek" <jakub@redhat.com>,
"Josh Boyer" <jwboyer@fedoraproject.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Markus Trippelsdorf" <markus@trippelsdorf.de>,
"Michel Dänzer" <michel@daenzer.net>,
"Frank Ch. Eigler" <fche@redhat.com>
Subject: [PATCH] Kbuild: Add an option to enable GCC VTA
Date: Thu, 23 Apr 2015 17:25:29 -0400 [thread overview]
Message-ID: <1429824329-40690-1-git-send-email-fche@redhat.com> (raw)
In-Reply-To: <1416595200-22359-1-git-send-email-jistone@redhat.com>
From: Josh Stone <jistone@redhat.com>
Due to isolated gcc codegen issues, gcc -fvar-tracking-assignments
was unconditionally disabled in commit 2062afb4f804 ("Fix gcc-4.9.0
miscompilation of load_balance() in scheduler").
However, this reduces the debuginfo coverage for variable locations,
especially in inline functions. VTA is certainly not perfect either
in those cases, but it is much better than without. With compiler
versions that have fixed the codegen bugs, we would prefer to have the
better details for SystemTap, and surely other debuginfo consumers
like perf will benefit as well.
This patch simply makes CONFIG_DEBUG_INFO_VTA an option. I considered
Frank and Linus's discussion of a cc-option-like -fcompare-debug test,
but I'm convinced that a narrow test of an arch-specific codegen issue
is not really useful. GCC has their own regression tests for this, so
I'd suggest GCC_COMPARE_DEBUG=-fvar-tracking-assignments-toggle is more
useful for kernel developers to test confidence.
In fact, I ran into a couple more issues when testing for this patch[1],
although neither of those had any codegen impact.
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1140872
With gcc-4.9.2-1.fc22, I can now build v3.18-rc5 with Fedora's i686 and
x86_64 configs, and this is completely clean with GCC_COMPARE_DEBUG.
Cc: Jakub Jelinek <jakub@redhat.com>
Cc: Josh Boyer <jwboyer@fedoraproject.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Markus Trippelsdorf <markus@trippelsdorf.de>
Cc: Michel Dänzer <michel@daenzer.net>
Signed-off-by: Josh Stone <jistone@redhat.com>
Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
---
Makefile | 8 ++++++--
lib/Kconfig.debug | 21 ++++++++++++++++++++-
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 6cc5b2434224..c8e1fcfdb41a 100644
--- a/Makefile
+++ b/Makefile
@@ -704,8 +704,6 @@ KBUILD_CFLAGS += -fomit-frame-pointer
endif
endif
-KBUILD_CFLAGS += $(call cc-option, -fno-var-tracking-assignments)
-
ifdef CONFIG_DEBUG_INFO
ifdef CONFIG_DEBUG_INFO_SPLIT
KBUILD_CFLAGS += $(call cc-option, -gsplit-dwarf, -g)
@@ -718,6 +716,12 @@ ifdef CONFIG_DEBUG_INFO_DWARF4
KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,)
endif
+ifdef CONFIG_DEBUG_INFO_VTA
+KBUILD_CFLAGS += $(call cc-option, -fvar-tracking-assignments)
+else
+KBUILD_CFLAGS += $(call cc-option, -fno-var-tracking-assignments)
+endif
+
ifdef CONFIG_DEBUG_INFO_REDUCED
KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \
$(call cc-option,-fno-var-tracking)
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 17670573dda8..e8d072d2b402 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -165,7 +165,26 @@ config DEBUG_INFO_DWARF4
Generate dwarf4 debug info. This requires recent versions
of gcc and gdb. It makes the debug information larger.
But it significantly improves the success of resolving
- variables in gdb on optimized code.
+ variables in gdb on optimized code. The gcc docs also
+ recommend enabling -fvar-tracking-assignments for maximum
+ benefit. (see DEBUG_INFO_VTA)
+
+config DEBUG_INFO_VTA
+ bool "Enable var-tracking-assignments for debuginfo"
+ depends on DEBUG_INFO
+ help
+ Enable gcc -fvar-tracking-assignments for improved debug
+ information on variable locations in optimized code. Per
+ gcc, DEBUG_INFO_DWARF4 is recommended for best use of VTA,
+ and allows maximal access to local variables in tracers
+ and debuggers like perf, systemtap, kgdb, and crash.
+
+ VTA has been implicated in codegen bugs (gcc PR61801,
+ PR61904, both fixed in 2014-08), so this flag may be used
+ to exclude this rare class of problem. One can also set
+ GCC_COMPARE_DEBUG=-fvar-tracking-assignments-toggle in the
+ environment to automatically compile everything both ways,
+ generating an error if anything differs.
config GDB_SCRIPTS
bool "Provide GDB scripts for kernel debugging"
--
2.1.0
next prev parent reply other threads:[~2015-04-23 21:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-21 18:40 [PATCH RESEND] Kbuild: Add an option to enable GCC VTA Josh Stone
2014-11-24 21:46 ` Michal Marek
2014-11-24 23:46 ` Josh Stone
2014-11-25 21:05 ` Michal Marek
2014-11-25 21:24 ` Josh Boyer
2015-04-23 21:25 ` Frank Ch. Eigler [this message]
2015-04-24 12:40 ` [PATCH] " Josh Boyer
2015-04-24 13:42 ` Frank Ch. Eigler
-- strict thread matches above, loose matches on Subject: below --
2014-08-05 23:59 [PATCH 3.15 33/37] Fix gcc-4.9.0 miscompilation of load_balance() in scheduler Linus Torvalds
2014-10-06 21:05 ` [PATCH] Kbuild: Add an option to enable GCC VTA Josh Stone
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1429824329-40690-1-git-send-email-fche@redhat.com \
--to=fche@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=gregkh@linuxfoundation.org \
--cc=jakub@redhat.com \
--cc=jistone@redhat.com \
--cc=jwboyer@fedoraproject.org \
--cc=linux-kernel@vger.kernel.org \
--cc=markus@trippelsdorf.de \
--cc=michel@daenzer.net \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).