Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp295006rwb; Wed, 28 Sep 2022 02:51:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5m+Di+i6928rVnegwTEzhpIQWHs6yBti3aJoAmP7MGunQo0wOwk0uUx7UDbNoC7Wx8Hl5S X-Received: by 2002:a17:906:7310:b0:782:cfd4:9c07 with SMTP id di16-20020a170906731000b00782cfd49c07mr20879956ejc.708.1664358670267; Wed, 28 Sep 2022 02:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664358670; cv=none; d=google.com; s=arc-20160816; b=N4oySV9xLDbnNs7dG8ZIrMbyBmiZwpx8eFp08OWE35v9SSlY18Pb7a2Cq/h1yEKWVq z1quB+SG9pguzpptLA2HXvlyS0syy5vKNjUP9A8TNQTL1GPKGf0bmeaYWjRiRYBRcHox NDwaCxYdMYOLj0pkPnTFVaYwVJyoDU1Hr9BAy4IMyrcdRa7NvdirXG+/UxkquHMjzwBA hkda64CFBTlTogoRFBIS+0klxOpzEDGi9fQAFsygZqPYL57QBCdhUs866AYca3BZ+qdL j7caC247LPhTWDevSWGszpgjOl5qYVQGcxl7Tupb+OQ4WqC9xvsRoE0CDI94QNiQ1+ui 1Y1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:subject:user-agent:mime-version:date:message-id; bh=PIXBrViv4+aJYNtvU5ERMSfAuLTc0zg5lT8oqQxQlUI=; b=CSSAWCaEG+aS8CMIdz99d3ukAVhCECI4g10IQP319MnlCl/FK5mHNBPj0fBob0Zweo DWzW1qCa0WDZhnVeV8dyBTIX/gizgAybZZ6gV9MebkORJSXjwX2UqER3udmsresrZuWz K0F5QW/oiSIwvF0sGOOUPbi+syhs0K+RjD9nWhtcBbe/MGCu6zACI2FiyD8SoyK2OJZk NkUcbMsudEJUG+A3m6GmTJR9GnVCJbMZ2BQJp66Xj/5wV6Hvc0wnE4cOHusvJIDd3e6Y e4XkK9pyW/VdgMQU/44C888GCBZFf/4d/q6P482kczzuIu6a+S5heLNg8vGWhJiHlKuR P/Bg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m11-20020a056402510b00b00457166171c6si5206924edd.432.2022.09.28.02.50.44; Wed, 28 Sep 2022 02:51:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233520AbiI1JVp (ORCPT + 99 others); Wed, 28 Sep 2022 05:21:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233543AbiI1JVm (ORCPT ); Wed, 28 Sep 2022 05:21:42 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77BA99CCC6; Wed, 28 Sep 2022 02:21:38 -0700 (PDT) Received: from fraeml734-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4McrbG1ywyz6HJT3; Wed, 28 Sep 2022 17:21:30 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml734-chm.china.huawei.com (10.206.15.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 28 Sep 2022 11:21:34 +0200 Received: from [10.126.175.219] (10.126.175.219) by lhrpeml500003.china.huawei.com (7.191.162.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 28 Sep 2022 10:21:33 +0100 Message-ID: Date: Wed, 28 Sep 2022 10:21:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH] perf tools: Fix empty version number when building outside of a git repo To: Will Chandler , , , , , , , , , References: <20220927195228.47304-1-wfc@wfchandler.org> From: John Garry In-Reply-To: <20220927195228.47304-1-wfc@wfchandler.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.126.175.219] X-ClientProxiedBy: lhrpeml100004.china.huawei.com (7.191.162.219) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/09/2022 20:52, Will Chandler wrote: > When perf is built in a full source tree that is not a git repository, > e.g. from a kernel source tarball, `perf version` will print empty tag > and commit strings: > > $ perf version > perf version > > Currently the tag version is only generated from the root Makefile when > building in a git repository. If PERF-VERSION-FILE has not been > generated and the source tree is not in a git repository, then > PERF-VERSION-GEN will return an empty version. > > The problem can be reproduced with the following steps: > > $ wget https://git.kernel.org/torvalds/t/linux-6.0-rc7.tar.gz > $ tar -xf linux-6.0-rc7.tar.gz && cd linux-6.0-rc7 > $ make -C tools/perf > $ tools/perf/perf -v > perf version > > Builds from tarballs generated with `make perf-tar-src-pkg` are not > impacted by this issue as PERF-VERSION-FILE is included in the archive. > > The perf RPM provided by Fedora for 5.18+ is experiencing this problem. > Package build logs[0] show that the build is attempting to fall back on > PERF-VERSION-FILE, but it is not present. > > To resolve this, always use the tag from the root Makefile if available. > > [0] https://kojipkgs.fedoraproject.org/packages/kernel-tools/5.19.4/200.fc36/data/logs/x86_64/build.log > Sorry for the breakage. I only considered perf-tar-src-pkg for out-of-git building. > Fixes: 7572733b8499 ("perf tools: Fix version kernel tag, 2022-02-21") > Signed-off-by: Will Chandler > --- > tools/perf/util/PERF-VERSION-GEN | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN > index 0ee5af529238..43b8a8ea6f53 100755 > --- a/tools/perf/util/PERF-VERSION-GEN > +++ b/tools/perf/util/PERF-VERSION-GEN > @@ -15,10 +15,13 @@ LF=' > # > CID= > TAG= > -if test -d ../../.git -o -f ../../.git > +if test -r ../../Makefile > then > TAG=$(MAKEFLAGS= make -sC ../.. kernelversion) > - CID=$(git log -1 --abbrev=12 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID" > + if test -d ../../.git -o -f ../../.git > + then > + CID=$(git log -1 --abbrev=12 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID" > + fi > else > TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE | sed -e 's/\"//g') > fi This looks ok. But did you consider going back to same flow as pre-7572733b8499 to avoid a Makefile check, like: ---8<---- CID= TAG= if test -d ../../.git -o -f ../../.git then TAG=$(MAKEFLAGS= make -sC ../.. kernelversion) CID=$(git log -1 --abbrev=12 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID" elif test -f ../../PERF-VERSION-FILE then TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE | sed -e 's/\"//g') fi if test -z "$TAG" then TAG=$(MAKEFLAGS= make -sC ../.. kernelversion) fi --->8--- The evaluation for $TAG is not really needed in the first leg since the fallback does the same thing, but just added for clarity. Thanks, John