[PATCH] tools/perf/build: Fix redirection printouts

From: Ingo Molnar
Date: Thu Oct 10 2013 - 01:43:15 EST



* Arnaldo Carvalho de Melo <acme@xxxxxxxxxxxxxxxxxx> wrote:

> So while merging what I have in my perf/core branch I got to Vitillo's, as
> peterz called it, "inlining" of addr2line, i.e. using libbfd to do that work,
> it will look if lbfd is in EXTLIBS and if so, use it, otherwise we continue
> exec'in the addr2line tool.
>
> Since this appears when doing the feature check:
>
> ... libbfd: [ on ]
>
> I wanted to build just one object file that is related to this:
>
> [acme@sandy linux]$ ls -la /tmp/build/perf/util/util/srcline.o
> ls: cannot access /tmp/build/perf/util/util/srcline.o: No such file or directory
> [acme@sandy linux]$ ls -la tools/perf/util/srcline.c
> -rw-rw-r--. 1 acme acme 1777 Oct 9 16:06 tools/perf/util/srcline.c
> [acme@sandy linux]$ ls -la tools/perf/util/srcline.*
> -rw-rw-r--. 1 acme acme 1777 Oct 9 16:06 tools/perf/util/srcline.c
> [acme@sandy linux]$ make V=1 O=/tmp/build/perf -C tools/perf/ util/srcline.o
> make: Entering directory `/home/acme/git/linux/tools/perf'
> BUILD: Doing 'make -j8' parallel build
> # Redirected target util/srcline.o => /tmp/build/perf/util/util/srcline.o
> make: Leaving directory `/home/acme/git/linux/tools/perf'
> [acme@sandy linux]$
> [acme@sandy linux]$ ls -la /tmp/build/perf/util/util/srcline.o
> ls: cannot access /tmp/build/perf/util/util/srcline.o: No such file or directory
> [acme@sandy linux]$ make V=1 O=/tmp/build/perf -C tools/perf/ /tmp/build/perf/util/util/srcline.o
> make: Entering directory `/home/acme/git/linux/tools/perf'
> BUILD: Doing 'make -j8' parallel build
> make[1]: *** No rule to make target `/tmp/build/perf/util/util/srcline.o'. Stop.
> make: *** [/tmp/build/perf/util/util/srcline.o] Error 2
> make: Leaving directory `/home/acme/git/linux/tools/perf'
> [acme@sandy linux]$ ls -la tools/perf/util/srcline.*
> -rw-rw-r--. 1 acme acme 1777 Oct 9 16:06 tools/perf/util/srcline.c
> [acme@sandy linux]$
>
> What am I doing wrong here while trying to build just one .o file?
>
> Back to checking why it is not using the 'inline' addr2line...
>
> - Arnaldo

There's two things that I can see here.

1)

The printout is a bit off, duplicating util/util. The fix below should
help with that.

2)

This issue is more difficult: if tools/perf/util/srcline.o exists, then
the redirection will not happen and make just says:

comet:~/tip/tools/perf> rm -f /tmp/build/perf/util/pager.o
comet:~/tip/tools/perf> make O=/tmp/build/perf/ util/pager.o
make: `util/pager.o' is up to date.

comet:~/tip/tools/perf> ll /tmp/build/perf/util/pager.o
ls: cannot access /tmp/build/perf/util/pager.o: No such file or directory
comet:~/tip/tools/perf> ll util/pager.o
-rw-rw-r-- 1 mingo mingo 297488 Oct 10 07:34 util/pager.o

So the redirection quirks will only work in a clean tree. I think that
should be fine - people who build via O= generally do it to keep their
source trees clean.

Thanks,

Ingo

======================>