From patchwork Wed Sep 5 22:35:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zanoni, Paulo R" X-Patchwork-Id: 10589595 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27344175A for ; Wed, 5 Sep 2018 22:36:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05EBB2A44C for ; Wed, 5 Sep 2018 22:36:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8C6A2A33F; Wed, 5 Sep 2018 22:36:33 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 3920428D29 for ; Wed, 5 Sep 2018 22:36:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727623AbeIFDIu (ORCPT ); Wed, 5 Sep 2018 23:08:50 -0400 Received: from mga14.intel.com ([192.55.52.115]:2871 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727364AbeIFDIu (ORCPT ); Wed, 5 Sep 2018 23:08:50 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Sep 2018 15:36:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,334,1531810800"; d="scan'208";a="83384346" Received: from przanoni-mobl.jf.intel.com ([10.24.9.77]) by fmsmga002.fm.intel.com with ESMTP; 05 Sep 2018 15:36:22 -0700 From: Paulo Zanoni To: linux-kbuild@vger.kernel.org Cc: Paulo Zanoni , Vasily Gorbik , Michal Marek , Steven Rostedt , Ingo Molnar , Tvrtko Ursulin Subject: [RFC 1/2] tracing/Makefile: fix handling redefinition of CC_FLAGS_FTRACE Date: Wed, 5 Sep 2018 15:35:59 -0700 Message-Id: <20180905223600.20994-1-paulo.r.zanoni@intel.com> X-Mailer: git-send-email 2.14.4 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 As a Kernel developer, I make heavy use of "make targz-pkg" in order to locally compile and remotely install my development Kernels. The nice feature I rely on is that after a normal "make", "make targz-pkg" only generates the tarball without having to recompile everything. That was true until commit f28bc3c32c05 ("tracing: Handle CC_FLAGS_FTRACE more accurately"). After it, running "make targz-pkg" after "make" will recompile the whole Kernel tree, making my development workflow much slower. The Kernel is choosing to recompile everything because it claims the command line has changed. A diff of the .cmd files show a repeated -mfentry in one of the files. It seems that something on make targz-pkg triggers the double -mfentry but not the double -pg. So this patch attempts to deal with that problem by handling -mfentry and others just like we handle -pg: don't append them if CC_FLAGS_FTRACE is already defined. I'm not a Makefile expert and so I can't claim this won't break anything else, hopefully if this patch gets applied it will have a Reviewed-by tag from some actual Makefile expert. I can claim this patch fixes the specific regression I reported. Fixes: commit f28bc3c32c05 ("tracing: Handle CC_FLAGS_FTRACE more accurately") Cc: Vasily Gorbik Cc: Michal Marek Cc: Steven Rostedt (VMware) Cc: Ingo Molnar Cc: Tvrtko Ursulin Cc: linux-kbuild@vger.kernel.org Signed-off-by: Paulo Zanoni --- Makefile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 19948e556941..2c8df481b4f1 100644 --- a/Makefile +++ b/Makefile @@ -755,28 +755,30 @@ KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ endif ifdef CONFIG_FUNCTION_TRACER -ifndef CC_FLAGS_FTRACE -CC_FLAGS_FTRACE := -pg -endif +cc_flags_ftrace_ := -pg ifdef CONFIG_FTRACE_MCOUNT_RECORD # gcc 5 supports generating the mcount tables directly ifeq ($(call cc-option-yn,-mrecord-mcount),y) - CC_FLAGS_FTRACE += -mrecord-mcount + cc_flags_ftrace_ += -mrecord-mcount export CC_USING_RECORD_MCOUNT := 1 endif ifdef CONFIG_HAVE_NOP_MCOUNT ifeq ($(call cc-option-yn, -mnop-mcount),y) - CC_FLAGS_FTRACE += -mnop-mcount + cc_flags_ftrace_ += -mnop-mcount CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT endif endif endif ifdef CONFIG_HAVE_FENTRY ifeq ($(call cc-option-yn, -mfentry),y) - CC_FLAGS_FTRACE += -mfentry + cc_flags_ftrace_ += -mfentry CC_FLAGS_USING += -DCC_USING_FENTRY endif endif + +ifndef CC_FLAGS_FTRACE + CC_FLAGS_FTRACE := $(cc_flags_ftrace_) +endif export CC_FLAGS_FTRACE KBUILD_CFLAGS += $(CC_FLAGS_FTRACE) $(CC_FLAGS_USING) KBUILD_AFLAGS += $(CC_FLAGS_USING)