From: Charlie Jenkins <charlie@rivosinc.com>
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>,
"Namhyung Kim" <namhyung@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: Fri, 28 Feb 2025 14:08:24 -0800 [thread overview]
Message-ID: <Z8Iz2JPpqer00aZ_@ghost> (raw)
In-Reply-To: <20250124-perf-fix-intree-build-v1-1-485dd7a855e4@bootlin.com>
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.
>
> With in-tree builds, the added 'SOURCE = ...' line is executed multiple
> times (I observed 2 during the build plus 2 during installation). This is a
> minor inefficiency, in theory not harmful because symlink creation is
> assumed to be idempotent. But it is not.
>
> Considering with in-tree builds:
>
> srctree=/absolute/path/to/linux
> OUTPUT=/absolute/path/to/linux/tools/perf
>
> here's what happens:
>
> 1. ln -sf $(srctree)/tools/perf $(OUTPUT)/source
> -> creates /absolute/path/to/linux/tools/perf/source
> link to /absolute/path/to/linux/tools/perf
> => OK, that's what was intended
> 2. ln -sf $(srctree)/tools/perf $(OUTPUT)/source # same command as 1
> -> creates /absolute/path/to/linux/tools/perf/perf
> link to /absolute/path/to/linux/tools/perf
> => Not what was intended, not idempotent
> 3. Now the build _should_ create the 'perf' executable, but it fails
>
> The reason is the tricky 'ln' command line. At the first invocation 'ln'
> uses the 1st form:
>
> ln [OPTION]... [-T] TARGET LINK_NAME
>
> and creates a link to TARGET *called LINK_NAME*.
>
> At the second invocation $(OUTPUT)/source exists, so 'ln' uses the 3rd
> form:
>
> ln [OPTION]... TARGET... DIRECTORY
>
> and creates a link to TARGET *called TARGET* inside DIRECTORY.
>
> Fix by adding --no-dereference to "treat LINK_NAME as a normal file if it
> is a symbolic link to a directory", as the manpage says.
>
> Link: https://lore.kernel.org/all/20241125182506.38af9907@booty/
> Fixes: 890a1961c812 ("perf tools: Create source symlink in perf object dir")
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> ---
> tools/perf/Makefile.perf | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index d74241a151313bd09101aabb5d765a5a0a6efc84..bbd799a0fd544db220f29d1e250a819a765d04f3 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -164,7 +164,7 @@ ifneq ($(OUTPUT),)
> VPATH += $(OUTPUT)
> export VPATH
> # create symlink to the original source
> -SOURCE := $(shell ln -sf $(srctree)/tools/perf $(OUTPUT)/source)
> +SOURCE := $(shell ln -sf --no-dereference $(srctree)/tools/perf $(OUTPUT)/source)
The kernel Makefile has:
$(Q)ln -fsn $(srcroot) source
So for parity the --no-dereference could become `n`, but it doesn't
really matter.
> endif
>
> ifeq ($(V),1)
>
> ---
> base-commit: ffd294d346d185b70e28b1a28abe367bbfe53c04
> change-id: 20250124-perf-fix-intree-build-fbd97f560254
>
> Best regards,
> --
> Luca Ceresoli <luca.ceresoli@bootlin.com>
>
Reviewed-by: Charlie Jenkins <charlie@rivosinc.com>
Tested-by: Charlie Jenkins <charlie@rivosinc.com>
next prev parent reply other threads:[~2025-02-28 22:08 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
2025-02-28 22:04 ` Charlie Jenkins
2025-02-28 22:08 ` Charlie Jenkins [this message]
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=Z8Iz2JPpqer00aZ_@ghost \
--to=charlie@rivosinc.com \
--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=namhyung@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).