From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B0C3C433DF for ; Sat, 17 Oct 2020 12:02:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01A692072D for ; Sat, 17 Oct 2020 12:02:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437800AbgJQMCK (ORCPT ); Sat, 17 Oct 2020 08:02:10 -0400 Received: from wildebeest.demon.nl ([212.238.236.112]:35340 "EHLO gnu.wildebeest.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388231AbgJQMCH (ORCPT ); Sat, 17 Oct 2020 08:02:07 -0400 Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 873AA30291AC; Sat, 17 Oct 2020 14:02:03 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id E2344401658F; Sat, 17 Oct 2020 14:02:02 +0200 (CEST) From: Mark Wielaard To: linux-kernel@vger.kernel.org, Masahiro Yamada , Michal Marek , linux-kbuild@vger.kernel.org Cc: Ian Rogers , Andi Kleen , Mark Wielaard , linux-toolchains@vger.kernel.org, Nick Desaulniers , Segher Boessenkool , Florian Weimer , Sedat Dilek Subject: [PATCH V2] Only add -fno-var-tracking-assignments workaround for old GCC versions. Date: Sat, 17 Oct 2020 14:01:35 +0200 Message-Id: <20201017120135.4004-1-mark@klomp.org> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20201014110132.2680-1-mark@klomp.org> References: <20201014110132.2680-1-mark@klomp.org> Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org 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 2062afb4f 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. Changes in V2: - Update commit message explaining purpose. - Explicitly mention GCC version in comment. - Wrap workaround in ifdef CONFIG_CC_IS_GCC Signed-off-by: Mark Wielaard Acked-by: Ian Rogers Reviewed-by: Andi Kleen Cc: linux-toolchains@vger.kernel.org Cc: Nick Desaulniers Cc: Segher Boessenkool Cc: Florian Weimer Cc: Sedat Dilek --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 51540b291738..964754b4cedf 100644 --- a/Makefile +++ b/Makefile @@ -813,7 +813,11 @@ KBUILD_CFLAGS += -ftrivial-auto-var-init=zero KBUILD_CFLAGS += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang endif -DEBUG_CFLAGS := $(call cc-option, -fno-var-tracking-assignments) +# Workaround for GCC versions < 5.0 +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801 +ifdef CONFIG_CC_IS_GCC +DEBUG_CFLAGS := $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments)) +endif ifdef CONFIG_DEBUG_INFO ifdef CONFIG_DEBUG_INFO_SPLIT -- 2.18.4