From patchwork Wed Mar 29 02:07:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 9650829 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 12C2B60349 for ; Wed, 29 Mar 2017 02:07:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02088284E9 for ; Wed, 29 Mar 2017 02:07:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9C0A284EE; Wed, 29 Mar 2017 02:07:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60769284E9 for ; Wed, 29 Mar 2017 02:07:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752006AbdC2CHr (ORCPT ); Tue, 28 Mar 2017 22:07:47 -0400 Received: from conssluserg-02.nifty.com ([210.131.2.81]:62345 "EHLO conssluserg-02.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751943AbdC2CHq (ORCPT ); Tue, 28 Mar 2017 22:07:46 -0400 Received: from mail-yw0-f175.google.com (mail-yw0-f175.google.com [209.85.161.175]) (authenticated) by conssluserg-02.nifty.com with ESMTP id v2T27HX3015536; Wed, 29 Mar 2017 11:07:18 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com v2T27HX3015536 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1490753238; bh=EglcJub+S6Jo5h30T/KPMSV1N8o81zYrZHu4qiGVRL8=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=y8am9AzazqV8KlhfNYQqA4HbfOhKyFG2wmb3dpUlXwHbmlxQL/YLb4uqq2NkUdlvj zGucTTEPyifCuwP+r6ly0a2ov4hDUOKSefJ842oJB9YcgAl6PbcdwARPb1iAr/r8Bw K5G+SVcjJGtRPZi3wyrwgnLunMeXR7pLQQisssUdgJO1NQP2uv02RO4NpVRJqMOcvB tZ9dsJfdF4p1bokILacat5qc97WxEiXOW0rTY1M0qYgFFBavpXk2Lt8AV/836b2O6n mqxIFg2kx2QRsfnVwusqTaVzIv1PojYJJxdSwoAwNt1S8C6Z3mhHboE91c4hBjl/cI 65Q00auWLLkTg== X-Nifty-SrcIP: [209.85.161.175] Received: by mail-yw0-f175.google.com with SMTP id d191so1545504ywe.2; Tue, 28 Mar 2017 19:07:18 -0700 (PDT) X-Gm-Message-State: AFeK/H1uZN3hdZZAwc6ymaK/Gues5ES9AlS/sjt6lIf3Cm4+hvfPBSJq6pQ5wYhPsYCeuYe9bdkqYAG+sa5avw== X-Received: by 10.37.170.233 with SMTP id t96mr3436494ybi.7.1490753236914; Tue, 28 Mar 2017 19:07:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.176.68 with HTTP; Tue, 28 Mar 2017 19:07:16 -0700 (PDT) In-Reply-To: <20170314213724.3836900-1-arnd@arndb.de> References: <20170314213410.3762842-1-arnd@arndb.de> <20170314213724.3836900-1-arnd@arndb.de> From: Masahiro Yamada Date: Wed, 29 Mar 2017 11:07:16 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] [SUBMITTED 20170314] [v333kbuild: disable -ffunction-sections on gcc-4.7 with ftrace To: Arnd Bergmann Cc: Michal Marek , Nicholas Piggin , Namhyung Kim , Linux Kbuild mailing list , Linux Kernel Mailing List , masahiroy@kernel.org Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Arnd, 2017-03-15 6:37 GMT+09:00 Arnd Bergmann : > When ftrace is enabled and we build with gcc-4.7 or older, we > get a warning for each file on architectures that select > CONFIG_LD_DEAD_CODE_DATA_ELIMINATION: > > warning: -ffunction-sections disabled; it makes profiling impossible [enabled by default] > > This turns off function sections in that specific case, leaving > it enabled for all other configurations. > > Fixes: b67067f1176d ("kbuild: allow archs to select link dead code/data elimination") > Signed-off-by: Arnd Bergmann > Cc: Namhyung Kim > --- > v2: accidentally resend the same patch as before > v3: send the exact same patch once more, without doing the change I wanted > v4: actually fixed version number in check as pointed out by Namhyung Kim (I hope) > --- > Makefile | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/Makefile b/Makefile > index 6e7e644a0b84..3a964fa3a787 100644 > --- a/Makefile > +++ b/Makefile > @@ -662,7 +662,11 @@ KBUILD_CFLAGS += -Wextra > KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) > > ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION > +ifdef CONFIG_FUNCTION_TRACER > +KBUILD_CFLAGS += $(call cc-ifversion, -ge,0408,$(call cc-option,-ffunction-sections,)) > +else > KBUILD_CFLAGS += $(call cc-option,-ffunction-sections,) > +endif > KBUILD_CFLAGS += $(call cc-option,-fdata-sections,) > endif > I have two questions. [1] How did you produce this warning? I do not see any architecture that selects this option at this point of time. Did you edit Kconfig locally to select LD_DEAD_CODE_DATA_ELIMINATION? If so, is this patch not so urgent as the "Fixes" tag claims? [2] This question is more technical. The cause of the problem seems that GCC warns it cannot support the two at the same time, but it does handle it as an error. So, cc-option assumes this combination is OK. Is it a good idea to add -Werror to cc-option checking? In my local test, the following patch solved this specific case. You contribute a lot for compile-test, so I'd like you to see if it has side-effects. -x c /dev/null -o "$$TMP",y,n) # cc-option-align # Prefix align with either -falign or -malign diff --git a/Makefile b/Makefile index 231e6a7..5850850 100644 --- a/Makefile +++ b/Makefile @@ -632,11 +632,6 @@ include arch/$(SRCARCH)/Makefile KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) -ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION -KBUILD_CFLAGS += $(call cc-option,-ffunction-sections,) -KBUILD_CFLAGS += $(call cc-option,-fdata-sections,) -endif - ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,) else @@ -767,6 +762,11 @@ ifdef CONFIG_DEBUG_SECTION_MISMATCH KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once) endif +ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION +KBUILD_CFLAGS += $(call cc-option,-ffunction-sections,) +KBUILD_CFLAGS += $(call cc-option,-fdata-sections,) +endif + # arch Makefile may override CC so keep this after arch Makefile is included NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) CHECKFLAGS += $(NOSTDINC_FLAGS) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index d6ca649..558d4f1 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -116,12 +116,12 @@ CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) cc-option = $(call try-run,\ - $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) + $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) # cc-option-yn # Usage: flag := $(call cc-option-yn,-march=winchip-c6) cc-option-yn = $(call try-run,\ - $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) + $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c