Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3932901rwb; Fri, 30 Sep 2022 10:13:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ulPO91EPio0RmfRqWgxNLO1CJMLCIEsNb+4Q3vrS8+jTlgYhJx4P6TQvjFvmPclGNWA2x X-Received: by 2002:a17:90b:368f:b0:208:1675:8b4c with SMTP id mj15-20020a17090b368f00b0020816758b4cmr10111257pjb.162.1664558012588; Fri, 30 Sep 2022 10:13:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664558012; cv=none; d=google.com; s=arc-20160816; b=BY6oKLgRrEaaZjqYxBSYwNPFICS5MGOom34Rkmnev4x2L2JU76QJVfAOJWGHVjEgtH RYqc6fdA6dBx2/2UBYnsbUSvEa6wI0c/xdJDXVuVKfA2IHAux6PyN7Fbw4GB6Kr7FThW VIEzpofSw3Pf5zZXYbGKE3qf5j+My6eue4n149rSD0A6GYB338fzzGSyWuOHEcPVGCb5 j3szfk/GKqGKW8qbhxchhwEoOUuM7zbMLLheDbZoPBVf5QLWYJIRjKHNj8S1m2v4vI1d cAimvbX8YcEEzVkwJh0CC3FQ+3MZfuE+1aKNdVTPl2fS7KKrQ+3mdNzcv/5sQOcKr67X HeEQ== 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:references :to:subject:from:user-agent:mime-version:date:message-id; bh=9MdLXbbfOtctZllPAd9zSnC2gVHCMSJGjQcqVZ/QMiE=; b=SVXZm4S64YxnCxczu0qdMhi8I36U8AEoMbgIU8hnEJyFXDlCPYQIJ3++dHkZm6tdh+ 96OT8lU+USQFzXjSU5vXGqv2eKPHktnn4ZckBre4Lh/xsD3OxVQLQKlFkJVYfgvtLw6a H+otmGF/PxXDYMNLr2F/EXdZqm9kWy/f8ka1jA6JCmBFf1x65lnh938Kaw+jt0rTE252 lmwRtUtIgQbvfyozSxUTkv/zO52lyl5lh9bs8kfDJqms8mGI9VmTom/ejvtmbzpZ/zNz wrIPD0a0MVlXIEhPf7wZslw2Ep/EPx4Cw5tg4XM0hKWCkuYKDN7lLAR+6Sx/t46RyooC /q5w== 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 x15-20020a170902ec8f00b001781675f417si4054586plg.258.2022.09.30.10.13.21; Fri, 30 Sep 2022 10:13:32 -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 S231953AbiI3QOt (ORCPT + 99 others); Fri, 30 Sep 2022 12:14:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230512AbiI3QOr (ORCPT ); Fri, 30 Sep 2022 12:14:47 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAD42634E; Fri, 30 Sep 2022 09:14:41 -0700 (PDT) Received: from fraeml739-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MfFdZ2fnrz67XMQ; Sat, 1 Oct 2022 00:13:22 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml739-chm.china.huawei.com (10.206.15.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 30 Sep 2022 18:14:39 +0200 Received: from [10.126.175.8] (10.126.175.8) 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; Fri, 30 Sep 2022 17:14:38 +0100 Message-ID: <30a2631b-341c-8c41-52dd-becb40bfc4be@huawei.com> Date: Fri, 30 Sep 2022 17:14:43 +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 From: John Garry Subject: Re: [PATCH v2] perf tools: Fix empty version number when building outside of a git repo To: Will Chandler , , , , , , , , , References: <20220927195228.47304-1-wfc@wfchandler.org> <20220930151157.529674-1-wfc@wfchandler.org> In-Reply-To: <20220930151157.529674-1-wfc@wfchandler.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.126.175.8] X-ClientProxiedBy: lhrpeml100005.china.huawei.com (7.191.160.25) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.8 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 30/09/2022 16:11, 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, revert back to the previous logic of using the kernel > Makefile version if not in a git repository and PERF-VERSION-FILE does > not exist. > > [0] https://kojipkgs.fedoraproject.org/packages/kernel-tools/5.19.4/200.fc36/data/logs/x86_64/build.log > > Fixes: 7572733b8499 ("perf tools: Fix version kernel tag, 2022-02-21") > Signed-off-by: Will Chandler This looks fine, thanks. Reviewed-by: John Garry > --- > Range-diff against v1: > 1: 8195a5ccd82d < -: ------------ perf tools: Fix empty version number when building outside of a git repo > -: ------------ > 1: a3beccdab700 perf tools: Fix empty version number when building outside of a git repo > > tools/perf/util/PERF-VERSION-GEN | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN > index 0ee5af529238..3cc42821d9b3 100755 > --- a/tools/perf/util/PERF-VERSION-GEN > +++ b/tools/perf/util/PERF-VERSION-GEN > @@ -11,7 +11,8 @@ LF=' > ' > > # > -# Always try first to get the version from the kernel Makefile > +# Use version from kernel Makefile unless not in a git repository and > +# PERF-VERSION-FILE exists > # > CID= > TAG= > @@ -19,9 +20,14 @@ 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" > -else > +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 > > VN="$TAG$CID" > if test -n "$CID"