Skip to content

Commit 121c5d0

Browse files
Mark Wielaardmasahir0y
authored andcommitted
kbuild: Only add -fno-var-tracking-assignments for old GCC versions
Some old GCC versions between 4.5.0 and 4.9.1 might miscompile code with -fvar-tracking-assingments (which is enabled by default with -g -O2). Commit 2062afb ("Fix gcc-4.9.0 miscompilation of load_balance() in scheduler") added -fno-var-tracking-assignments unconditionally to work around this. But newer versions of GCC no longer have this bug, so only add it for versions of GCC before 5.0. This allows various tools such as a perf probe or gdb debuggers or systemtap to resolve variable locations using dwarf locations in more code. Signed-off-by: Mark Wielaard <[email protected]> Acked-by: Ian Rogers <[email protected]> Reviewed-by: Andi Kleen <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 8402ee1 commit 121c5d0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,11 @@ KBUILD_CFLAGS += -ftrivial-auto-var-init=zero
814814
KBUILD_CFLAGS += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
815815
endif
816816

817-
DEBUG_CFLAGS := $(call cc-option, -fno-var-tracking-assignments)
817+
# Workaround for GCC versions < 5.0
818+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801
819+
ifdef CONFIG_CC_IS_GCC
820+
DEBUG_CFLAGS := $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
821+
endif
818822

819823
ifdef CONFIG_DEBUG_INFO
820824

0 commit comments

Comments
 (0)