2012-08-13 13:20:58

by Steven Rostedt

[permalink] [raw]
Subject: [PATCH] perf: Let O= makes handle relative paths

When I did a compile of perf using a relative path for the output
directory, the build failed when it tried to compile libtraceevent. This
is because it continues to use the same relative path when the new
working directory is in a different path.

SUBDIR ../lib/traceevent/
/bin/sh: line 0: cd: ../../../nobackup/perf/: No such file or directory
Makefile:74: *** output directory "../../../nobackup/perf/" does not exist. Stop.
make: *** [../../../nobackup/perf///libtraceevent.a] Error 2


Make the path used an absolute path when building perf with O=.

Signed-off-by: Steven Rostedt <[email protected]>

diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index bde8521..9e3e31e 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -1,6 +1,7 @@
ifeq ("$(origin O)", "command line")
- OUTPUT := $(O)/
- COMMAND_O := O=$(O)
+ RAW_O := $(shell cd $(O) ; pwd)
+ OUTPUT := $(RAW_O)/
+ COMMAND_O := O=$(RAW_O)
endif

ifneq ($(OUTPUT),)


2012-08-13 13:24:46

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH] perf: Let O= makes handle relative paths

On Mon, Aug 13, 2012 at 09:20:55AM -0400, Steven Rostedt wrote:
> When I did a compile of perf using a relative path for the output
> directory, the build failed when it tried to compile libtraceevent. This
> is because it continues to use the same relative path when the new
> working directory is in a different path.
>
> SUBDIR ../lib/traceevent/
> /bin/sh: line 0: cd: ../../../nobackup/perf/: No such file or directory
> Makefile:74: *** output directory "../../../nobackup/perf/" does not exist. Stop.
> make: *** [../../../nobackup/perf///libtraceevent.a] Error 2
>
>
> Make the path used an absolute path when building perf with O=.
>
> Signed-off-by: Steven Rostedt <[email protected]>
>
> diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
> index bde8521..9e3e31e 100644
> --- a/tools/scripts/Makefile.include
> +++ b/tools/scripts/Makefile.include
> @@ -1,6 +1,7 @@
> ifeq ("$(origin O)", "command line")
> - OUTPUT := $(O)/
> - COMMAND_O := O=$(O)
> + RAW_O := $(shell cd $(O) ; pwd)
> + OUTPUT := $(RAW_O)/
> + COMMAND_O := O=$(RAW_O)

So wouldn't it make sense to call this ABSOLUTE_O or so then?

Thanks.

--
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551

2012-08-13 14:23:07

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] perf: Let O= makes handle relative paths

On Mon, 2012-08-13 at 15:24 +0200, Borislav Petkov wrote:

> So wouldn't it make sense to call this ABSOLUTE_O or so then?

That's just because you're russian, and are promoting Vodka! ;-)


Done...

----------

When I did a compile of perf using a relative path for the output
directory, the build failed when it tried to compile libtraceevent. This
is because it continues to use the same relative path when the new
working directory is in a different path.

SUBDIR ../lib/traceevent/
/bin/sh: line 0: cd: ../../../nobackup/perf/: No such file or directory
Makefile:74: *** output directory "../../../nobackup/perf/" does not exist. Stop.
make: *** [../../../nobackup/perf///libtraceevent.a] Error 2


Make the path used an absolute path when building perf with O=.

Signed-off-by: Steven Rostedt <[email protected]>

diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index bde8521..e90e1b4 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -1,6 +1,7 @@
ifeq ("$(origin O)", "command line")
- OUTPUT := $(O)/
- COMMAND_O := O=$(O)
+ ABSOLUTE_O := $(shell cd $(O) ; pwd)
+ OUTPUT := $(ABSOLUTE_O)/
+ COMMAND_O := O=$(ABSOLUTE_O)
endif

ifneq ($(OUTPUT),)

2012-08-13 14:29:17

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH] perf: Let O= makes handle relative paths

On Mon, Aug 13, 2012 at 10:23:02AM -0400, Steven Rostedt wrote:
> On Mon, 2012-08-13 at 15:24 +0200, Borislav Petkov wrote:
>
> > So wouldn't it make sense to call this ABSOLUTE_O or so then?
>
> That's just because you're russian, and are promoting Vodka! ;-)
>
>
> Done...
>
> ----------
>
> When I did a compile of perf using a relative path for the output
> directory, the build failed when it tried to compile libtraceevent. This
> is because it continues to use the same relative path when the new
> working directory is in a different path.
>
> SUBDIR ../lib/traceevent/
> /bin/sh: line 0: cd: ../../../nobackup/perf/: No such file or directory
> Makefile:74: *** output directory "../../../nobackup/perf/" does not exist. Stop.
> make: *** [../../../nobackup/perf///libtraceevent.a] Error 2
>
>
> Make the path used an absolute path when building perf with O=.
>
> Signed-off-by: Steven Rostedt <[email protected]>

Acked-by: The Russian Vodka Promoter.

8-).

Thanks and Na Zdorovia!

--
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551

2012-08-13 18:03:03

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH] perf: Let O= makes handle relative paths

Em Mon, Aug 13, 2012 at 04:29:09PM +0200, Borislav Petkov escreveu:
> On Mon, Aug 13, 2012 at 10:23:02AM -0400, Steven Rostedt wrote:
> > On Mon, 2012-08-13 at 15:24 +0200, Borislav Petkov wrote:
> >
> > > So wouldn't it make sense to call this ABSOLUTE_O or so then?
> >
> > That's just because you're russian, and are promoting Vodka! ;-)

Before:

[acme@sandy linux]$ rm -rf ../build/perf
[acme@sandy linux]$ make -j8 -C tools/perf/ LIBUNWIND_DIR=/opt/libunwind O=/home/acme/git/build/perf install
/bin/sh: line 0: cd: /home/acme/git/build/perf/: No such file or directory
make: Entering directory `/home/git/linux/tools/perf'
../scripts/Makefile.include:9: *** output directory "/home/acme/git/build/perf/" does not exist. Stop.
make: Leaving directory `/home/git/linux/tools/perf'
[acme@sandy linux]$

Now:

[acme@sandy linux]$ rm -rf ../build/perf
[acme@sandy linux]$ make -j8 -C tools/perf/ LIBUNWIND_DIR=/opt/libunwind O=/home/acme/git/build/perf install
/bin/sh: line 0: cd: /home/acme/git/build/perf: No such file or directory
make: Entering directory `/home/git/linux/tools/perf'
GEN perf-archive
GEN /home/git/linux/tools/perf/python/perf.so
make[1]: Entering directory `/home/git/linux/tools/lib/traceevent'
make[2]: warning: jobserver unavailable: using -j1. Add `+' to parent make rule.
* new build flags or cross compiler
CC /home/git/linux/tools/perf/perf.o
CC /home/git/linux/tools/perf/builtin-annotate.o
CC /home/git/linux/tools/perf/builtin-bench.o
CC /home/git/linux/tools/perf/bench/sched-messaging.o
CC /home/git/linux/tools/perf/bench/sched-pipe.o

I.e. it should stop if the O= provided directory is not there.

Can you fix this? Avoid vodka while doing it :-P

- Arnaldo

2012-08-15 10:27:35

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH] perf: Let O= makes handle relative paths

On Mon, Aug 13, 2012 at 03:02:49PM -0300, Arnaldo Carvalho de Melo wrote:
> [acme@sandy linux]$ rm -rf ../build/perf
> [acme@sandy linux]$ make -j8 -C tools/perf/ LIBUNWIND_DIR=/opt/libunwind O=/home/acme/git/build/perf install
> /bin/sh: line 0: cd: /home/acme/git/build/perf: No such file or directory
> make: Entering directory `/home/git/linux/tools/perf'
> GEN perf-archive
> GEN /home/git/linux/tools/perf/python/perf.so
> make[1]: Entering directory `/home/git/linux/tools/lib/traceevent'
> make[2]: warning: jobserver unavailable: using -j1. Add `+' to parent make rule.
> * new build flags or cross compiler
> CC /home/git/linux/tools/perf/perf.o
> CC /home/git/linux/tools/perf/builtin-annotate.o
> CC /home/git/linux/tools/perf/builtin-bench.o
> CC /home/git/linux/tools/perf/bench/sched-messaging.o
> CC /home/git/linux/tools/perf/bench/sched-pipe.o
>
> I.e. it should stop if the O= provided directory is not there.

Why stop? Don't we want to make the directory instead and continue
building in there?

--
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551

2012-08-15 13:06:54

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH] perf: Let O= makes handle relative paths

Em Wed, Aug 15, 2012 at 12:27:22PM +0200, Borislav Petkov escreveu:
> On Mon, Aug 13, 2012 at 03:02:49PM -0300, Arnaldo Carvalho de Melo wrote:
> > [acme@sandy linux]$ rm -rf ../build/perf
> > [acme@sandy linux]$ make -j8 -C tools/perf/ LIBUNWIND_DIR=/opt/libunwind O=/home/acme/git/build/perf install
> > /bin/sh: line 0: cd: /home/acme/git/build/perf: No such file or directory
> > make: Entering directory `/home/git/linux/tools/perf'
> > GEN perf-archive
> > GEN /home/git/linux/tools/perf/python/perf.so
> > make[1]: Entering directory `/home/git/linux/tools/lib/traceevent'
> > * new build flags or cross compiler
> > CC /home/git/linux/tools/perf/perf.o

> > I.e. it should stop if the O= provided directory is not there.

> Why stop? Don't we want to make the directory instead and continue
> building in there?

That was the case in the past, but IIRC PeterZ advocated not to and I
agreed.

- Arnaldo

2012-08-15 13:18:15

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH] perf: Let O= makes handle relative paths

On Wed, Aug 15, 2012 at 10:06:34AM -0300, Arnaldo Carvalho de Melo wrote:
> That was the case in the past, but IIRC PeterZ advocated not to and I
> agreed.

Maybe you guys need to explain yourselves :) I mean, the dir is not
present so we're not overwriting anything. And since we say "O=..." on
the command line, it is actually expected that we really mean it... why
type it, otherwise?

Hmmm.

--
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551

2012-08-15 14:38:19

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH] perf: Let O= makes handle relative paths

On Wed, 2012-08-15 at 15:18 +0200, Borislav Petkov wrote:
> On Wed, Aug 15, 2012 at 10:06:34AM -0300, Arnaldo Carvalho de Melo wrote:
> > That was the case in the past, but IIRC PeterZ advocated not to and I
> > agreed.
>
> Maybe you guys need to explain yourselves :) I mean, the dir is not
> present so we're not overwriting anything. And since we say "O=..." on
> the command line, it is actually expected that we really mean it... why
> type it, otherwise?

Because you're an idiot and made a typo ;-) Happens to me all the time.

The regular kernel build doesn't create non-existent O= targets either
iirc.

2012-08-15 14:43:05

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH] perf: Let O= makes handle relative paths

On Wed, Aug 15, 2012 at 04:38:05PM +0200, Peter Zijlstra wrote:
> Because you're an idiot and made a typo ;-) Happens to me all the time.

I'm not an idiot - I'm perfection at its purest! :-)

> The regular kernel build doesn't create non-existent O= targets either
> iirc.

Ok, I see. The kernel needs to protect itself against the people who
wrote it :-).

--
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551

2012-08-15 14:59:50

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH] perf: Let O= makes handle relative paths

Em Wed, Aug 15, 2012 at 04:42:55PM +0200, Borislav Petkov escreveu:
> On Wed, Aug 15, 2012 at 04:38:05PM +0200, Peter Zijlstra wrote:
> > Because you're an idiot and made a typo ;-) Happens to me all the time.
>
> I'm not an idiot - I'm perfection at its purest! :-)
>
> > The regular kernel build doesn't create non-existent O= targets either
> > iirc.
>
> Ok, I see. The kernel needs to protect itself against the people who
> wrote it :-).

Of course! Those are the ultimate kernel killers!

- Arnaldo

2012-08-15 16:39:32

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH] perf: Let O= makes handle relative paths

On Wed, Aug 15, 2012 at 11:59:35AM -0300, Arnaldo Carvalho de Melo wrote:
> Of course! Those are the ultimate kernel killers!

Haha, this is what I'm answering next time I'm asked about what I do for
a living :-).

How about this?

--
From: Steven Rostedt <[email protected]>
Date: Mon, 13 Aug 2012 10:23:02 -0400
Subject: [PATCH] perf: Let O= makes handle relative paths

When I did a compile of perf using a relative path for the output
directory, the build failed when it tried to compile libtraceevent. This
is because it continues to use the same relative path when the new
working directory is in a different path.

SUBDIR ../lib/traceevent/
/bin/sh: line 0: cd: ../../../nobackup/perf/: No such file or directory
Makefile:74: *** output directory "../../../nobackup/perf/" does not exist. Stop.
make: *** [../../../nobackup/perf///libtraceevent.a] Error 2

Make the path used an absolute path when building perf with O=.

Boris:

Teach Makefile to check whether the supplied O= directory exists and
bail out if not. Reportedly, kernel dudes are idiots and need to be
guarded so as not to shoot themselves in the foot when playing in the
sandbox.

Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
---
tools/scripts/Makefile.include | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index bde8521d56bb..96ce80a3743b 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -1,6 +1,8 @@
ifeq ("$(origin O)", "command line")
- OUTPUT := $(O)/
- COMMAND_O := O=$(O)
+ dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),)
+ ABSOLUTE_O := $(shell cd $(O) ; pwd)
+ OUTPUT := $(ABSOLUTE_O)/
+ COMMAND_O := O=$(ABSOLUTE_O)
endif

ifneq ($(OUTPUT),)
--
1.7.11.rc1

--
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551

2012-08-16 16:07:59

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] perf: Let O= makes handle relative paths

On Wed, 2012-08-15 at 18:39 +0200, Borislav Petkov wrote:

> diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
> index bde8521d56bb..96ce80a3743b 100644
> --- a/tools/scripts/Makefile.include
> +++ b/tools/scripts/Makefile.include
> @@ -1,6 +1,8 @@
> ifeq ("$(origin O)", "command line")
> - OUTPUT := $(O)/
> - COMMAND_O := O=$(O)
> + dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),)
> + ABSOLUTE_O := $(shell cd $(O) ; pwd)
> + OUTPUT := $(ABSOLUTE_O)/
> + COMMAND_O := O=$(ABSOLUTE_O)
> endif
>

Acked-by: Steven Rostedt <[email protected]>

Arnaldo, can you pick this patch? Keep both the Signed-off-bys that
Boris placed.

Thanks!

-- Steve

2012-08-16 17:13:05

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH] perf: Let O= makes handle relative paths

Em Thu, Aug 16, 2012 at 12:07:54PM -0400, Steven Rostedt escreveu:
> Acked-by: Steven Rostedt <[email protected]>
>
> Arnaldo, can you pick this patch? Keep both the Signed-off-bys that
> Boris placed.

ack, done,

- Arnaldo

2012-08-21 16:20:29

by Steven Rostedt

[permalink] [raw]
Subject: [tip:perf/core] perf tools: Let O= makes handle relative paths

Commit-ID: c883122acc0d97648d8b8f4726709017674e4420
Gitweb: http://git.kernel.org/tip/c883122acc0d97648d8b8f4726709017674e4420
Author: Steven Rostedt <[email protected]>
AuthorDate: Mon, 13 Aug 2012 10:23:02 -0400
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 16 Aug 2012 14:11:11 -0300

perf tools: Let O= makes handle relative paths

When I did a compile of perf using a relative path for the output
directory, the build failed when it tried to compile libtraceevent. This
is because it continues to use the same relative path when the new
working directory is in a different path.

SUBDIR ../lib/traceevent/
/bin/sh: line 0: cd: ../../../nobackup/perf/: No such file or directory
Makefile:74: *** output directory "../../../nobackup/perf/" does not exist. Stop.
make: *** [../../../nobackup/perf///libtraceevent.a] Error 2

Make the path used an absolute path when building perf with O=.

Boris:

Teach Makefile to check whether the supplied O= directory exists and
bail out if not. Reportedly, kernel dudes are idiots and need to be
guarded so as not to shoot themselves in the foot when playing in the
sandbox.

Signed-off-by: Borislav Petkov <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
Acked-by: Steven Rostedt <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/scripts/Makefile.include | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index bde8521..96ce80a 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -1,6 +1,8 @@
ifeq ("$(origin O)", "command line")
- OUTPUT := $(O)/
- COMMAND_O := O=$(O)
+ dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),)
+ ABSOLUTE_O := $(shell cd $(O) ; pwd)
+ OUTPUT := $(ABSOLUTE_O)/
+ COMMAND_O := O=$(ABSOLUTE_O)
endif

ifneq ($(OUTPUT),)