Skip to contentSkip to conversation

perf: Fix version when building out of tree

PATCH In review David Ahern 2 participants 6 messages Nov 6, 2013 – Nov 11, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: Fix version when building out of tree

When building perf out of tree
make perf-tar-src-pkg
tar -xf perf-<ver>.tar -C /tmp
cd /tmp/perf<ver>
make -C tools/perf

you get the warning message:
make[1]: *** No rule to make target `kernelversion'. Stop.

Fix by saving the perf version in the tar file and using that for the out of tree builds.

---
 scripts/package/Makefile         |    4 +++-
 tools/perf/util/PERF-VERSION-GEN |   16 +++++++++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)
scripts/package/Makefile +3 -1
index a4f31c900fa6..e44653986e0a 100644
@@ -115,7 +115,9 @@ git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/         \
 	-o $(perf-tar).tar;                                         \
 mkdir -p $(perf-tar);                                               \
 git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD;    \
-tar rf $(perf-tar).tar $(perf-tar)/HEAD;                            \
+(cd $(srctree)/tools/perf;                                          \
+util/PERF-VERSION-GEN short ../../$(perf-tar)/ 2>/dev/null);        \
+tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
 rm -r $(perf-tar);                                                  \
 $(if $(findstring tar-src,$@),,                                     \
 $(if $(findstring bz2,$@),bzip2,                                    \
tools/perf/util/PERF-VERSION-GEN +15 -1
index 15a77b7c0e36..142d7dcccfd2 100755
@@ -1,5 +1,12 @@
 #!/bin/sh
 
+SHORT_FORM=no
+
+if [ "$1" = "short" ]  ; then
+	SHORT_FORM=yes
+	shift
+fi
+
 if [ $# -eq 1 ]  ; then
 	OUTPUT=$1
 fi
@@ -19,6 +26,9 @@ if test -d ../../.git -o -f ../../.git
 then
 	TAG=$(git describe --abbrev=0 --match "v[0-9].[0-9]*" 2>/dev/null )
 	CID=$(git log -1 --abbrev=4 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID"
+elif test -f ../../PERF-VERSION-FILE
+then
+	TAG=$(cat ../../PERF-VERSION-FILE)
 fi
 if test -z "$TAG"
 then
@@ -41,7 +51,11 @@ else
 fi
 test "$VN" = "$VC" || {
 	echo >&2 "PERF_VERSION = $VN"
-	echo "#define PERF_VERSION \"$VN\"" >$GVF
+	if [ "$SHORT_FORM" = "yes" ]; then
+		echo "$VN" >$GVF
+	else
+		echo "#define PERF_VERSION \"$VN\"" >$GVF
+	fi
 }
 
 
Signature · 1 line
1.7.10.1
#1 lore raw
Quoted 65 lines · David Ahern

When building perf out of tree
make perf-tar-src-pkg
tar -xf perf-<ver>.tar -C /tmp
cd /tmp/perf<ver>
make -C tools/perf

you get the warning message:
make[1]: *** No rule to make target `kernelversion'. Stop.

Fix by saving the perf version in the tar file and using that for the out of tree builds.

---
 scripts/package/Makefile         |    4 +++-
 tools/perf/util/PERF-VERSION-GEN |   16 +++++++++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)
scripts/package/Makefile +3 -1
index a4f31c900fa6..e44653986e0a 100644
@@ -115,7 +115,9 @@ git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/         \
 	-o $(perf-tar).tar;                                         \
 mkdir -p $(perf-tar);                                               \
 git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD;    \
-tar rf $(perf-tar).tar $(perf-tar)/HEAD;                            \
+(cd $(srctree)/tools/perf;                                          \
+util/PERF-VERSION-GEN short ../../$(perf-tar)/ 2>/dev/null);        \
+tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
 rm -r $(perf-tar);                                                  \
 $(if $(findstring tar-src,$@),,                                     \
 $(if $(findstring bz2,$@),bzip2,                                    \
tools/perf/util/PERF-VERSION-GEN +10 -0
index 15a77b7c0e36..142d7dcccfd2 100755
@@ -1,5 +1,12 @@
 #!/bin/sh
 
+SHORT_FORM=no
+
+if [ "$1" = "short" ]  ; then
+	SHORT_FORM=yes
+	shift
+fi
+
 if [ $# -eq 1 ]  ; then
 	OUTPUT=$1
 fi
@@ -19,6 +26,9 @@ if test -d ../../.git -o -f ../../.git
 then
 	TAG=$(git describe --abbrev=0 --match "v[0-9].[0-9]*" 2>/dev/null )
 	CID=$(git log -1 --abbrev=4 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID"
+elif test -f ../../PERF-VERSION-FILE
+then
+	TAG=$(cat ../../PERF-VERSION-FILE)
 fi
 if test -z "$TAG"
 then

tools/perf/util/PERF-VERSION-GEN else · line 59

Quoted 10 lines
tools/perf/util/PERF-VERSION-GEN +5 -1
@@ -41,7 +51,11 @@ else
 fi
 test "$VN" = "$VC" || {
 	echo >&2 "PERF_VERSION = $VN"
-	echo "#define PERF_VERSION \"$VN\"" >$GVF
+	if [ "$SHORT_FORM" = "yes" ]; then
+		echo "$VN" >$GVF
+	else
+		echo "#define PERF_VERSION \"$VN\"" >$GVF
+	fi
 }

I think you could avoid the 'short' complication altogether by doing something like this:

tools/perf/util/PERF-VERSION-GEN if test -d ../../.git -o -f ../../.git

Quoted 3 lines
tools/perf/util/PERF-VERSION-GEN +3 -0
+elif test -f ../../PERF-VERSION-FILE
+then
+	TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE)

That extracts 'TAG' as a true sha1 and makes GVF correct on out of tree builds as well.

haven't tested it though.

Thanks,

Ingo

#2 lore raw
Quoted 9 lines · Ingo Molnar

I think you could avoid the 'short' complication altogether by doing something like this:

tools/perf/util/PERF-VERSION-GEN if test -d ../../.git -o -f ../../.git

Quoted 3 lines
tools/perf/util/PERF-VERSION-GEN +3 -0
+elif test -f ../../PERF-VERSION-FILE
+then
+	TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE)

That extracts 'TAG' as a true sha1 and makes GVF correct on out of tree builds as well.

Certainly. I was trying to make PERF-VERSION-FILE readable as a standalone file -- a better version descriptor than HEAD file.

David

#3 lore raw
Quoted 11 lines · David Ahern
Quoted 9 lines · Ingo Molnar

I think you could avoid the 'short' complication altogether by doing something like this:

tools/perf/util/PERF-VERSION-GEN if test -d ../../.git -o -f ../../.git

Quoted 3 lines
tools/perf/util/PERF-VERSION-GEN +3 -0
+elif test -f ../../PERF-VERSION-FILE
+then
+	TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE)

That extracts 'TAG' as a true sha1 and makes GVF correct on out of tree builds as well.

Quoted 2 lines

Certainly. I was trying to make PERF-VERSION-FILE readable as a standalone file -- a better version descriptor than HEAD file.

Do you mean that instead of:

  comet:~/tip/tools/perf> cat PERF-VERSION-FILE 
  #define PERF_VERSION "3.12.g953bfb"

we should put a plain version into it? (the 'short' form you introduced earlier)

And then this:

  Makefile.perf:  $(QUIET_CC)$(CC) -include $(OUTPUT)PERF-VERSION-FILE \

Could be replaced with:

  Makefile.perf:  $(QUIET_CC)$(CC) -D $(shell cat $(OUTPUT)PERF-VERSION-FILE) \

or so?

Thanks,

Ingo

#4 lore raw
Quoted 14 lines · Ingo Molnar
Quoted 11 lines · David Ahern
Quoted 9 lines · Ingo Molnar

I think you could avoid the 'short' complication altogether by doing something like this:

tools/perf/util/PERF-VERSION-GEN if test -d ../../.git -o -f ../../.git

Quoted 3 lines
tools/perf/util/PERF-VERSION-GEN +3 -0
+elif test -f ../../PERF-VERSION-FILE
+then
+	TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE)

That extracts 'TAG' as a true sha1 and makes GVF correct on out of tree builds as well.

Quoted 7 lines
Quoted 2 lines

Certainly. I was trying to make PERF-VERSION-FILE readable as a standalone file -- a better version descriptor than HEAD file.

Do you mean that instead of:

   comet:~/tip/tools/perf> cat PERF-VERSION-FILE
   #define PERF_VERSION "3.12.g953bfb"

no. I was thinking instead of
cat PERF-VERSION-FILE
#define PERF_VERSION "3.12.g953bfb"

you have
cat PERF-VERSION-FILE
3.12.g953bfb

But remember this is a new PERF-VERSION-FILE at the top of tree -- just like the HEAD file that contains the top commit id. Both are generated as part of the make perf-tar-src-pkg to keep track of the origin of the source. The new file becomes the basis of $(OUTPUT)PERF-VERSION-FILE.

Quoted 5 lines

we should put a plain version into it? (the 'short' form you introduced earlier)

And then this:

Quoted 7 lines
   Makefile.perf:  $(QUIET_CC)$(CC) -include $(OUTPUT)PERF-VERSION-FILE \

Could be replaced with:

   Makefile.perf:  $(QUIET_CC)$(CC) -D $(shell cat $(OUTPUT)PERF-VERSION-FILE) \

or so?

something like that could be done too.

David

#5 lore raw
Quoted 31 lines · David Ahern
Quoted 14 lines · Ingo Molnar
Quoted 11 lines · David Ahern
Quoted 9 lines · Ingo Molnar

I think you could avoid the 'short' complication altogether by doing something like this:

tools/perf/util/PERF-VERSION-GEN if test -d ../../.git -o -f ../../.git

Quoted 3 lines
tools/perf/util/PERF-VERSION-GEN +3 -0
+elif test -f ../../PERF-VERSION-FILE
+then
+	TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE)

That extracts 'TAG' as a true sha1 and makes GVF correct on out of tree builds as well.

Quoted 7 lines
Quoted 2 lines

Certainly. I was trying to make PERF-VERSION-FILE readable as a standalone file -- a better version descriptor than HEAD file.

Do you mean that instead of:

  comet:~/tip/tools/perf> cat PERF-VERSION-FILE
  #define PERF_VERSION "3.12.g953bfb"

no. I was thinking instead of
cat PERF-VERSION-FILE
#define PERF_VERSION "3.12.g953bfb"

you have
cat PERF-VERSION-FILE
3.12.g953bfb

Quoted 5 lines

But remember this is a new PERF-VERSION-FILE at the top of tree -- just like the HEAD file that contains the top commit id. Both are generated as part of the make perf-tar-src-pkg to keep track of the origin of the source. The new file becomes the basis of $(OUTPUT)PERF-VERSION-FILE.

Hm, I think this is confusing.

I think this should be a special file name, only generated into the tarball, one which never shows up in a regular build.

It must be possible to build perf in a read-only source repository (with O= pointing elsewhere) for example.

Thanks,

Ingo