[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z5kiciNxDk-G-Zhr@google.com>
Date: Tue, 28 Jan 2025 10:31:14 -0800
From: Namhyung Kim <namhyung@...nel.org>
To: Luca Ceresoli <luca.ceresoli@...tlin.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Andi Kleen <ak@...ux.intel.com>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
Alexis Lothoré <alexis.lothore@...tlin.com>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf build: fix in-tree build
On Mon, Jan 27, 2025 at 02:48:49PM +0100, Luca Ceresoli wrote:
> Hello Namhyung Kim,
>
> thanks for having a look!
>
> On Sun, 26 Jan 2025 13:00:10 -0800
> Namhyung Kim <namhyung@...nel.org> wrote:
>
> > Hello,
> >
> > On Fri, Jan 24, 2025 at 02:06:08PM +0100, Luca Ceresoli wrote:
> > > Building perf in-tree is broken after commit 890a1961c812 ("perf tools:
> > > Create source symlink in perf object dir") which added a 'source' symlink
> > > in the output dir pointing to the source dir.
> >
> > I cannot reproduce it - both `make -C tools/perf` and `cd tools/perf; make`
> > work well for me. What do you mean by in-tree build exactly? Can you
> > please share your command line and the error messages?
>
> I have narrowed down my reproducer script from the initial report to a
> fairly minimal one, and here it is:
>
> ------------------------8<------------------------
> #!/bin/sh
>
> set -eu
>
> OUT_DIR=${1:-$(pwd)/tools/perf}
> DESTDIR=/tmp/aaa
>
> RET=0
>
> echo "Kernel version: $(git describe)"
> echo "OUT_DIR = ${OUT_DIR}"
> echo "DESTDIR = ${DESTDIR}"
> echo
>
> git clean -xdfq
> rm -fr ${DESTDIR}/
>
> # Only for out of tree builds: clear the build dir
> if ! echo ${OUT_DIR} | grep -q "tools/perf"; then
> rm -fr ${OUT_DIR}
> mkdir -p ${OUT_DIR}
> fi
>
> LINUX_MAKE_FLAGS="\
> -C tools/perf \
> O=${OUT_DIR} \
> DESTDIR=${DESTDIR} \
> "
>
> make ${LINUX_MAKE_FLAGS}
> make ${LINUX_MAKE_FLAGS} install
>
> echo
>
> if [ -h ${OUT_DIR}/perf ]; then
> echo "*** ERROR: ${OUT_DIR}/perf is a symlink, should be an exectuable file: ***" >&2
> ls -l ${OUT_DIR}/perf
> RET=255
> fi
>
> if ! find ${DESTDIR}/ -name perf -not -type d | xargs file | grep 'ELF.*executable'; then
> echo "*** ERROR: perf executable not preseint in install dir ${DESTDIR} ***" >&2
> RET=255
> fi
>
> exit $RET
> ------------------------8<------------------------
>
> Just put it outside of your kernel dir (or it will be removed by the
> 'git clean' command) and run it in your kernel source dir. E.g. right
> now I'm doing:
>
> cd <kernel dir>
> git checkout v6.13
> ../build-perf
>
> You should see it failing as:
>
> *** ERROR: /.../linux/tools/perf/perf is a symlink, should be an exectuable file: ***
> lrwxrwxrwx 1 user user 39 Jan 27 14:10 /.../linux/tools/perf/perf -> /.../linux/tools/perf
> *** ERROR: perf executable not preseint in install dir /tmp/aaa ***
>
> Note that in the broken case the kernel build continues and returns 0,
> but there is no perf exectuable.
Thanks for sharing this. I've reproduced it and found it had a
symlink to a directory rather than an executable.
>
> PS:
>
> And after having come up with the above script, I also found that the
> build succeeds with the following change:
>
> ------------------------8<------------------------
> @@ -24,11 +24,10 @@
> LINUX_MAKE_FLAGS="\
> -C tools/perf \
> O=${OUT_DIR} \
> - DESTDIR=${DESTDIR} \
> "
>
> make ${LINUX_MAKE_FLAGS}
> -make ${LINUX_MAKE_FLAGS} install
> +make ${LINUX_MAKE_FLAGS} DESTDIR=${DESTDIR} install
> ------------------------8<------------------------
>
> In other words:
>
> * This fails:
> make ${LINUX_MAKE_FLAGS} DESTDIR=${DESTDIR}
> make ${LINUX_MAKE_FLAGS} DESTDIR=${DESTDIR} install
> * This succeeds:
> make ${LINUX_MAKE_FLAGS}
> make ${LINUX_MAKE_FLAGS} DESTDIR=${DESTDIR} install
>
> The only difference is the presence of 'DESTDIR' in the compile command.
>
> My understanding and expectation is that DESTDIR has no effect on the
> make process except in the 'install' target. This is clearly not
> happening here.
>
> I have not yet found an obvious reason why 'DESTDIR' is special in the
> compilation stage, after a quick look.
Interesting, maybe some install commands were called internally. I'll
take a look.
Thanks,
Namhyung
Powered by blists - more mailing lists