diff options
author | Will Chandler <wfc@wfchandler.org> | 2022-09-30 18:11:57 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2022-10-06 14:03:52 +0300 |
commit | 81935f10e694e390c7d23055952ebe0ac2173d1d (patch) | |
tree | 6fd70c1954c4e345017a56b0f71a407983cc0f6e /tools/perf/util | |
parent | 20b2194eeee3ff8df8f2bbf7631e7278fced404a (diff) | |
download | linux-81935f10e694e390c7d23055952ebe0ac2173d1d.tar.xz |
perf tools: Fix empty version number when building outside of a git repo
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: 7572733b84997d23 ("perf tools: Fix version kernel tag")
Reviewed-by: John Garry <john.garry@huawei.com>
Signed-off-by: Will Chandler <wfc@wfchandler.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.garry@huawei.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220930151157.529674-1-wfc@wfchandler.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rwxr-xr-x | tools/perf/util/PERF-VERSION-GEN | 10 |
1 files 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" |