* [PATCH] perf tools: Fix empty version number when building outside of a git repo
@ 2022-09-27 19:52 Will Chandler
2022-09-28 9:21 ` John Garry
2022-09-30 15:11 ` [PATCH v2] " Will Chandler
0 siblings, 2 replies; 10+ messages in thread
From: Will Chandler @ 2022-09-27 19:52 UTC (permalink / raw)
To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
namhyung, linux-perf-users, linux-kernel
Cc: john.garry, wfc
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
Fixes: 7572733b8499 ("perf tools: Fix version kernel tag, 2022-02-21")
Signed-off-by: Will Chandler <wfc@wfchandler.org>
---
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
--
2.37.3
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] perf tools: Fix empty version number when building outside of a git repo
2022-09-27 19:52 [PATCH] perf tools: Fix empty version number when building outside of a git repo Will Chandler
@ 2022-09-28 9:21 ` John Garry
2022-09-28 17:26 ` Will Chandler
2022-09-30 15:11 ` [PATCH v2] " Will Chandler
1 sibling, 1 reply; 10+ messages in thread
From: John Garry @ 2022-09-28 9:21 UTC (permalink / raw)
To: Will Chandler, peterz, mingo, acme, mark.rutland,
alexander.shishkin, jolsa, namhyung, linux-perf-users,
linux-kernel
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 <wfc@wfchandler.org>
> ---
> 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
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] perf tools: Fix empty version number when building outside of a git repo
2022-09-28 9:21 ` John Garry
@ 2022-09-28 17:26 ` Will Chandler
2022-09-29 10:09 ` John Garry
0 siblings, 1 reply; 10+ messages in thread
From: Will Chandler @ 2022-09-28 17:26 UTC (permalink / raw)
To: John Garry
Cc: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
namhyung, linux-perf-users, linux-kernel
On 28 Sep 2022, at 5:21, John Garry wrote:
> 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.
I think that would be fine as well. I don't have a strong opinion on which one
is easier to follow.
Looking at this more closely, there is a slight difference between the two
approaches. In the problem scenario my patch will always use `make kernelversion`,
while pre-7572733b8499 starts with PERF-VERSION-FILE if available, falling
back to the Makefile.
With the old approach PERF-VERSION-FILE could be used to manually
override the version, but this is inconsistent with how the version is
generated when building in a git repo. Is this relevant?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] perf tools: Fix empty version number when building outside of a git repo
2022-09-28 17:26 ` Will Chandler
@ 2022-09-29 10:09 ` John Garry
2022-09-29 19:06 ` Will Chandler
0 siblings, 1 reply; 10+ messages in thread
From: John Garry @ 2022-09-29 10:09 UTC (permalink / raw)
To: Will Chandler
Cc: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
namhyung, linux-perf-users, linux-kernel
On 28/09/2022 18:26, Will Chandler wrote:
> On 28 Sep 2022, at 5:21, John Garry wrote:
>
>> 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.
>
> I think that would be fine as well. I don't have a strong opinion on which one
> is easier to follow.
>
> Looking at this more closely, there is a slight difference between the two
> approaches. In the problem scenario my patch will always use `make kernelversion`,
> while pre-7572733b8499 starts with PERF-VERSION-FILE if available, falling
> back to the Makefile.
>
> With the old approach PERF-VERSION-FILE could be used to manually
> override the version, but this is inconsistent with how the version is
> generated when building in a git repo. Is this relevant?
Hmmm... maybe someone would want to customise PERF-VERSION-FILE for
their own distro. Not sure. But then fiddling with PERF-VERSION-FILE
might break the parsing so...I guess not.
BTW, is there any other method of building the perf code not considered?
So far I know:
a. in git tree
b. perf-tar-src-pkg
c. tarball
Thanks,
John
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] perf tools: Fix empty version number when building outside of a git repo
2022-09-29 10:09 ` John Garry
@ 2022-09-29 19:06 ` Will Chandler
2022-09-29 19:16 ` Arnaldo Carvalho de Melo
2022-09-30 10:23 ` John Garry
0 siblings, 2 replies; 10+ messages in thread
From: Will Chandler @ 2022-09-29 19:06 UTC (permalink / raw)
To: John Garry
Cc: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
namhyung, linux-perf-users, linux-kernel
On 29 Sep 2022, at 6:09, John Garry wrote:
> Hmmm... maybe someone would want to customise PERF-VERSION-FILE for their own distro. Not sure. But then fiddling with PERF-VERSION-FILE might break the parsing so...I guess not.
Yeah, seems like a bad idea. Doing a quick search, Void Linux does seem to be
trying to set a custom version string in their build script[0], but I don't
think passing PERF_VERSION as an argument to make has worked since 2013 with
3cecaa200227 ("perf tools: Do not include PERF-VERSION-FILE to Makefile, 2013-01-16").
[0] https://github.com/void-linux/void-packages/blob/fdb3515c33f2bb997392ea6992e6bbb82c4376c5/srcpkgs/linux-tools/template#L56
> BTW, is there any other method of building the perf code not considered? So far I know:
> a. in git tree
> b. perf-tar-src-pkg
> c. tarball
Those are all that come to mind for me as well.
Let me know if you'd like me to re-roll the patch using the pre-7572733b8499
approach.
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] perf tools: Fix empty version number when building outside of a git repo
2022-09-29 19:06 ` Will Chandler
@ 2022-09-29 19:16 ` Arnaldo Carvalho de Melo
2022-09-30 10:23 ` John Garry
1 sibling, 0 replies; 10+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-09-29 19:16 UTC (permalink / raw)
To: Will Chandler
Cc: John Garry, peterz, mingo, mark.rutland, alexander.shishkin,
jolsa, namhyung, linux-perf-users, linux-kernel
Em Thu, Sep 29, 2022 at 03:06:06PM -0400, Will Chandler escreveu:
> On 29 Sep 2022, at 6:09, John Garry wrote:
>
> > Hmmm... maybe someone would want to customise PERF-VERSION-FILE for their own distro. Not sure. But then fiddling with PERF-VERSION-FILE might break the parsing so...I guess not.
>
> Yeah, seems like a bad idea. Doing a quick search, Void Linux does seem to be
> trying to set a custom version string in their build script[0], but I don't
> think passing PERF_VERSION as an argument to make has worked since 2013 with
> 3cecaa200227 ("perf tools: Do not include PERF-VERSION-FILE to Makefile, 2013-01-16").
>
> [0] https://github.com/void-linux/void-packages/blob/fdb3515c33f2bb997392ea6992e6bbb82c4376c5/srcpkgs/linux-tools/template#L56
>
> > BTW, is there any other method of building the perf code not considered? So far I know:
> > a. in git tree
> > b. perf-tar-src-pkg
> > c. tarball
>
> Those are all that come to mind for me as well.
>
> Let me know if you'd like me to re-roll the patch using the pre-7572733b8499
> approach.
Discussion is going well, proceed, reach a conclusion and from what I'm
seeing, I'll just have to apply it 8-)
- Arnaldo
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] perf tools: Fix empty version number when building outside of a git repo
2022-09-29 19:06 ` Will Chandler
2022-09-29 19:16 ` Arnaldo Carvalho de Melo
@ 2022-09-30 10:23 ` John Garry
1 sibling, 0 replies; 10+ messages in thread
From: John Garry @ 2022-09-30 10:23 UTC (permalink / raw)
To: Will Chandler
Cc: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
namhyung, linux-perf-users, linux-kernel
On 29/09/2022 20:06, Will Chandler wrote:
> On 29 Sep 2022, at 6:09, John Garry wrote:
>
>> Hmmm... maybe someone would want to customise PERF-VERSION-FILE for their own distro. Not sure. But then fiddling with PERF-VERSION-FILE might break the parsing so...I guess not.
> Yeah, seems like a bad idea. Doing a quick search, Void Linux does seem to be
> trying to set a custom version string in their build script[0], but I don't
> think passing PERF_VERSION as an argument to make has worked since 2013 with
> 3cecaa200227 ("perf tools: Do not include PERF-VERSION-FILE to Makefile, 2013-01-16").
>
> [0]https://github.com/void-linux/void-packages/blob/fdb3515c33f2bb997392ea6992e6bbb82c4376c5/srcpkgs/linux-tools/template#L56
>
>> BTW, is there any other method of building the perf code not considered? So far I know:
>> a. in git tree
>> b. perf-tar-src-pkg
>> c. tarball
> Those are all that come to mind for me as well.
>
> Let me know if you'd like me to re-roll the patch using the pre-7572733b8499
> approach.
> .
I have a slight preference that you do like pre-7572733b8499 if that is
ok. The reason is that way was a bit more tried and tested.
Thanks,
John
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2] perf tools: Fix empty version number when building outside of a git repo
2022-09-27 19:52 [PATCH] perf tools: Fix empty version number when building outside of a git repo Will Chandler
2022-09-28 9:21 ` John Garry
@ 2022-09-30 15:11 ` Will Chandler
2022-09-30 16:14 ` John Garry
1 sibling, 1 reply; 10+ messages in thread
From: Will Chandler @ 2022-09-30 15:11 UTC (permalink / raw)
To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
namhyung, linux-perf-users, linux-kernel
Cc: john.garry, wfc
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 <wfc@wfchandler.org>
---
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"
--
2.37.3
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v2] perf tools: Fix empty version number when building outside of a git repo
2022-09-30 15:11 ` [PATCH v2] " Will Chandler
@ 2022-09-30 16:14 ` John Garry
2022-09-30 16:43 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 10+ messages in thread
From: John Garry @ 2022-09-30 16:14 UTC (permalink / raw)
To: Will Chandler, peterz, mingo, acme, mark.rutland,
alexander.shishkin, jolsa, namhyung, linux-perf-users,
linux-kernel
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 <wfc@wfchandler.org>
This looks fine, thanks.
Reviewed-by: John Garry <john.garry@huawei.com>
> ---
> 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"
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v2] perf tools: Fix empty version number when building outside of a git repo
2022-09-30 16:14 ` John Garry
@ 2022-09-30 16:43 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 10+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-09-30 16:43 UTC (permalink / raw)
To: John Garry
Cc: Will Chandler, peterz, mingo, mark.rutland, alexander.shishkin,
jolsa, namhyung, linux-perf-users, linux-kernel
Em Fri, Sep 30, 2022 at 05:14:43PM +0100, John Garry escreveu:
> 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 <wfc@wfchandler.org>
>
> This looks fine, thanks.
>
> Reviewed-by: John Garry <john.garry@huawei.com>
Tested, fixed the problem, applied.
- Arnaldo
> > ---
> > 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"
--
- Arnaldo
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-09-30 16:43 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-27 19:52 [PATCH] perf tools: Fix empty version number when building outside of a git repo Will Chandler
2022-09-28 9:21 ` John Garry
2022-09-28 17:26 ` Will Chandler
2022-09-29 10:09 ` John Garry
2022-09-29 19:06 ` Will Chandler
2022-09-29 19:16 ` Arnaldo Carvalho de Melo
2022-09-30 10:23 ` John Garry
2022-09-30 15:11 ` [PATCH v2] " Will Chandler
2022-09-30 16:14 ` John Garry
2022-09-30 16:43 ` Arnaldo Carvalho de Melo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.