From nobody Sun Apr 28 15:02:05 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA5D4C433FE for ; Fri, 30 Sep 2022 15:15:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230371AbiI3PPW (ORCPT ); Fri, 30 Sep 2022 11:15:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231743AbiI3PPO (ORCPT ); Fri, 30 Sep 2022 11:15:14 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B9C8357FA; Fri, 30 Sep 2022 08:15:06 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 3ABE15C0152; Fri, 30 Sep 2022 11:15:02 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 30 Sep 2022 11:15:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wfchandler.org; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1664550902; x= 1664637302; bh=7ybg3nygxexcalhGkErIErfbpCmI7RsWlhy3369WZl4=; b=d mUWXPZDjuHbt2NyX/KmxCb2IyQCDshCaBsDgOgvxQFDcxpo4YriENNC6PRazqazu 0EshSJRb/YgDTtpu1bMmjr0czaBxB2bDXsL9U9QMG8F7reDq/MzgysLJOXpxNeno rytuXQMrtxwDl3n7hRaZ6W1h88YsAsscQlm6VHbauglX51E0owC5dBdw55NImfU9 xyKAbMSBgFKWZk6v+3CH7OUYd92GeKXg5D5U3t2fRZkE5VDCkK3bEu17X1hmwaUr QBHAvugiuQvn3s2cuWm8H/UHv18MgJnJprq0cZozbC3aZApXuMAg1Zn30GbEnQWR SkWsNJnVFocQDBOwXjmzA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1664550902; x=1664637302; bh=7ybg3nygxexca lhGkErIErfbpCmI7RsWlhy3369WZl4=; b=uporRloMRiFQf3jMpoxNGv5NU1P8q q3iWFcUUi9Y8de1WBNdgNomytpup9K1VJ5bnOtq44Ca4eFCjHVJYM1Ckv+Uv+ErW tiVV+/LwMbtZh6KVstdKw+ut2cJH6cpo6kd4W7kb6cwNu856NNnvoSlkpLuBULRS pVLliOUVVq90yyxPuaiT5YOR7P9FID1hCFLOsi1XXXFM/8NuP+i+kNyQg9Gwc/Yu Lcg8JW7igc9gNW84CtmKkoxCN6JCX0uKl4v0qbc+ZD7eCCdzHH6Q/53+5rz9RSgI cazqmbvoWOzlXml/9CcKG2ktRWdcPNrWCZ5I615RIB4cub0NwyQ8pcSEg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeehvddgkeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpeghihhllhcuvehhrghnughlvghruceofihftgesfihftghh rghnughlvghrrdhorhhgqeenucggtffrrghtthgvrhhnpefhkedvueefvdeuffefvdfhve evkeeuhfevueeuhefhleejtdevgefgueeihfeuudenucffohhmrghinhepkhgvrhhnvghl rdhorhhgpdhfvgguohhrrghprhhojhgvtghtrdhorhhgnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepfihftgesfihftghhrghnughlvghrrdho rhhg X-ME-Proxy: Feedback-ID: ica594744:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 30 Sep 2022 11:15:00 -0400 (EDT) From: Will Chandler To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: john.garry@huawei.com, wfc@wfchandler.org Subject: [PATCH v2] perf tools: Fix empty version number when building outside of a git repo Date: Fri, 30 Sep 2022 11:11:57 -0400 Message-Id: <20220930151157.529674-1-wfc@wfchandler.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220927195228.47304-1-wfc@wfchandler.org> References: <20220927195228.47304-1-wfc@wfchandler.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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.fc3= 6/data/logs/x86_64/build.log Fixes: 7572733b8499 ("perf tools: Fix version kernel tag, 2022-02-21") Signed-off-by: Will Chandler Reviewed-by: John Garry --- Range-diff against v1: 1: 8195a5ccd82d < -: ------------ perf tools: Fix empty version number wh= en building outside of a git repo -: ------------ > 1: a3beccdab700 perf tools: Fix empty version number wh= en 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-VERSIO= N-GEN index 0ee5af529238..3cc42821d9b3 100755 --- a/tools/perf/util/PERF-VERSION-GEN +++ b/tools/perf/util/PERF-VERSION-GEN @@ -11,7 +11,8 @@ LF=3D' ' =20 # -# 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=3D TAG=3D @@ -19,9 +20,14 @@ if test -d ../../.git -o -f ../../.git then TAG=3D$(MAKEFLAGS=3D make -sC ../.. kernelversion) CID=3D$(git log -1 --abbrev=3D12 --pretty=3Dformat:"%h" 2>/dev/null) && C= ID=3D"-g$CID" -else +elif test -f ../../PERF-VERSION-FILE +then TAG=3D$(cut -d' ' -f3 ../../PERF-VERSION-FILE | sed -e 's/\"//g') fi +if test -z "$TAG" +then + TAG=3D$(MAKEFLAGS=3D make -sC ../.. kernelversion) +fi =20 VN=3D"$TAG$CID" if test -n "$CID" --=20 2.37.3