public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Luca Ceresoli <luca.ceresoli@bootlin.com>
Cc: "Peter Zijlstra" <peterz@infradead.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Arnaldo Carvalho de Melo" <acme@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
	"Jiri Olsa" <jolsa@kernel.org>, "Ian Rogers" <irogers@google.com>,
	"Adrian Hunter" <adrian.hunter@intel.com>,
	"Andi Kleen" <ak@linux.intel.com>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Alexis Lothoré" <alexis.lothore@bootlin.com>,
	"Arnaldo Carvalho de Melo" <acme@redhat.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf build: fix in-tree build
Date: Tue, 28 Jan 2025 10:31:14 -0800	[thread overview]
Message-ID: <Z5kiciNxDk-G-Zhr@google.com> (raw)
In-Reply-To: <20250127144849.744ec7e0@booty>

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@kernel.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


  reply	other threads:[~2025-01-28 18:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-24 13:06 [PATCH] perf build: fix in-tree build Luca Ceresoli
2025-01-26 21:00 ` Namhyung Kim
2025-01-27 13:48   ` Luca Ceresoli
2025-01-28 18:31     ` Namhyung Kim [this message]
2025-02-28 22:04       ` Charlie Jenkins
2025-02-28 22:08 ` Charlie Jenkins
2025-02-28 23:59   ` Namhyung Kim
2025-03-03 16:56 ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z5kiciNxDk-G-Zhr@google.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexis.lothore@bootlin.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox