Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4501480img; Tue, 26 Mar 2019 10:34:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7ttdyDrE5JBccpuiJ2OGcY4xWLAyK7c362VAPb1QFlQgSh1uruOTJs8hKbyum9PitwFMd X-Received: by 2002:a63:6881:: with SMTP id d123mr29714509pgc.10.1553621671888; Tue, 26 Mar 2019 10:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553621671; cv=none; d=google.com; s=arc-20160816; b=Oa1DdddHuKiPdpxS8WWFdvhZZWtdNyDkDf6DWdS1tDemfILEnTgn5yWiSg0OZ9Gk2X 5Djw+8lnQegtG+Hlo7/+M69RzUxhWh58oxt5xkOPqfA7nPNl8Rox60TEjstDnxLqvq65 6NE7qaKn4a/Kge9BVRGCTsEN57kbzfRR7aRaMzf+WQs3jPWt23I7TLzOo1TNBN76JAEr avfj1ATlzTYNzEqHlS8DpttuPnTcR4uYiphXlPRaFhmEuSyNfkuW+1fYzvsfzvwdstbC 5yCQlCJQ6s8tz9il1H/9rh308lLl5F8pDP0rjteL3gCuoUZgEVWUZgQH1sIOudLKIKW5 Yucw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=0IVk/xUiZ3Zw7N+lZ7B5+t3SNJbrL/yTc1377QSDTVc=; b=0bJpxhdJeUNCDiQ/ETSqIYiFHMQNTouxjDnVrpqlFAnDOtbyamjOcobyOK6ylcFh5D EeuFFNd0g3fNNiO5pEYLuKFRU/9GJQkY1ckWeHz4udl6Sd1x57wmeKIUGlJeMqabmAZT eRmZ+SxtNF39biXtPSvUn2Blg5btzxUVL8hkYS7xHBn7lB2i2XbEAUcD7P4C9pH6Y/Cz Y5tnUOU+3Os30Q2CQq+tE5E5YwvvhtMOuN1XSNAY6T3b2D0hOBosH3nOk+PN7ysB54+r dktx7zGNhG9H4iHvLYBObtf3rk4H+DykxEqGd2eEEmUrHKukCj62SaL/0xtkNhkOL3NI eaYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4si15938092pgs.579.2019.03.26.10.34.16; Tue, 26 Mar 2019 10:34:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732441AbfCZRdU (ORCPT + 99 others); Tue, 26 Mar 2019 13:33:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41910 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732431AbfCZRdQ (ORCPT ); Tue, 26 Mar 2019 13:33:16 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83DFE8666B; Tue, 26 Mar 2019 17:33:12 +0000 (UTC) Received: from redhat.com (dhcp-17-208.bos.redhat.com [10.18.17.208]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F2465C28D; Tue, 26 Mar 2019 17:33:10 +0000 (UTC) Date: Tue, 26 Mar 2019 13:33:08 -0400 From: Joe Lawrence To: Masahiro Yamada Cc: Linux Kbuild mailing list , linuxppc-dev , Linux Kernel Mailing List , Michal Marek , Nicholas Piggin , Steven Rostedt Subject: [PATCH v2] kbuild: strip whitespace in cmd_record_mcount findstring Message-ID: <20190326173308.GA26546@redhat.com> References: <20190325160438.8982-1-joe.lawrence@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 26 Mar 2019 17:33:15 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 26, 2019 at 02:29:47PM +0900, Masahiro Yamada wrote: > On Tue, Mar 26, 2019 at 1:05 AM Joe Lawrence wrote: > > > > CC_FLAGS_FTRACE may contain trailing whitespace that interferes with > > findstring. > > > > For example, commit 6977f95e63b9 ("powerpc: avoid -mno-sched-epilog on > > GCC 4.9 and newer") introduced a change such that on my ppc64le box, > > CC_FLAGS_FTRACE="-pg -mprofile-kernel ". (Note the trailing space.) > > When cmd_record_mcount is now invoked, findstring fails as the ftrace > > flags were found at very end of _c_flags, without the trailing space. > > > > _c_flags=" ... -pg -mprofile-kernel" > > CC_FLAGS_FTRACE="-pg -mprofile-kernel " > > ^ > > findstring is looking for this extra space > > > > Remove the redundant whitespaces from CC_FLAGS_FTRACE in > > cmd_record_mcount to avoid this problem. > > > > Fixes: 6977f95e63b9 ("powerpc: avoid -mno-sched-epilog on GCC 4.9 and newer"). > > Signed-off-by: Joe Lawrence > > --- > > > > Standard disclaimer: I'm not a kbuild expert, but this works around the > > problem I reported where ftrace and livepatch self-tests were failing as > > specified object files were not run through the recordmcount.pl script: > > > > ppc64le: ftrace self-tests and $(CC_FLAGS_FTRACE) broken? > > https://lists.ozlabs.org/pipermail/linuxppc-dev/2019-March/187298.html > > > > scripts/Makefile.build | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/scripts/Makefile.build b/scripts/Makefile.build > > index 2554a15ecf2b..74d402b5aa3c 100644 > > --- a/scripts/Makefile.build > > +++ b/scripts/Makefile.build > > @@ -199,10 +199,10 @@ sub_cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ > > "$(if $(part-of-module),1,0)" "$(@)"; > > recordmcount_source := $(srctree)/scripts/recordmcount.pl > > endif # BUILD_C_RECORDMCOUNT > > -cmd_record_mcount = \ > > - if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \ > > - "$(CC_FLAGS_FTRACE)" ]; then \ > > - $(sub_cmd_record_mcount) \ > > +cmd_record_mcount = \ > > + if [ "$(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags))" = \ > > + "$(strip $(CC_FLAGS_FTRACE))" ]; then \ > > + $(sub_cmd_record_mcount) \ > > fi > > endif # CC_USING_RECORD_MCOUNT > > endif # CONFIG_FTRACE_MCOUNT_RECORD > > -- > > 2.20.1 > > > > > > I do not see a point in using the shell command here > in the first place. > > Instead of adding crappy workarounds, > I guess the following simple code should work: > > > index 2554a15..5f13021 100644 > --- a/scripts/Makefile.build > +++ b/scripts/Makefile.build > @@ -199,11 +199,8 @@ sub_cmd_record_mcount = perl > $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ > "$(if $(part-of-module),1,0)" "$(@)"; > recordmcount_source := $(srctree)/scripts/recordmcount.pl > endif # BUILD_C_RECORDMCOUNT > -cmd_record_mcount = \ > - if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \ > - "$(CC_FLAGS_FTRACE)" ]; then \ > - $(sub_cmd_record_mcount) \ > - fi > +cmd_record_mcount = $(if $(findstring $(CC_FLAGS_FTRACE),$(_c_flags)),\ > + $(sub_cmd_record_mcount)) > endif # CC_USING_RECORD_MCOUNT > endif # CONFIG_FTRACE_MCOUNT_RECORD > Hi Masahiro, Agreed on the shell command ugliness, however I still think we need to strip the search pattern here. With your suggestion: % rm -f kernel/trace/trace_selftest_dynamic.o % make kernel/trace/trace_selftest_dynamic.o CALL scripts/checksyscalls.sh CALL scripts/atomic/check-atomics.sh CC kernel/trace/trace_selftest_dynamic.o % eu-readelf --sections kernel/trace/trace_selftest_dynamic.o | grep mcount (nothing) Adding it back as, as below, restores those sections and the self tests work again. Regards, -- Joe -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- From 6a85e8ecf4179b3e80601a327ec43d8d49f0e3cd Mon Sep 17 00:00:00 2001 From: Joe Lawrence Date: Tue, 26 Mar 2019 10:50:28 -0400 Subject: [PATCH v2] kbuild: strip whitespace in cmd_record_mcount findstring CC_FLAGS_FTRACE may contain trailing whitespace that interferes with findstring. For example, commit 6977f95e63b9 ("powerpc: avoid -mno-sched-epilog on GCC 4.9 and newer") introduced a change such that on my ppc64le box, CC_FLAGS_FTRACE="-pg -mprofile-kernel ". (Note the trailing space.) When cmd_record_mcount is now invoked, findstring fails as the ftrace flags were found at very end of _c_flags, without the trailing space. _c_flags=" ... -pg -mprofile-kernel" CC_FLAGS_FTRACE="-pg -mprofile-kernel " ^ findstring is looking for this extra space Remove the redundant whitespaces from CC_FLAGS_FTRACE in cmd_record_mcount to avoid this problem. Suggested-by: Masahiro Yamada (refactoring) Fixes: 6977f95e63b9 ("powerpc: avoid -mno-sched-epilog on GCC 4.9 and newer"). Signed-off-by: Joe Lawrence --- scripts/Makefile.build | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 2554a15ecf2b..76ca30cc4791 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -199,11 +199,8 @@ sub_cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ "$(if $(part-of-module),1,0)" "$(@)"; recordmcount_source := $(srctree)/scripts/recordmcount.pl endif # BUILD_C_RECORDMCOUNT -cmd_record_mcount = \ - if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \ - "$(CC_FLAGS_FTRACE)" ]; then \ - $(sub_cmd_record_mcount) \ - fi +cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)), \ + $(sub_cmd_record_mcount)) endif # CC_USING_RECORD_MCOUNT endif # CONFIG_FTRACE_MCOUNT_RECORD -- 2.20.1