linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: hupu <hupu.gm@gmail.com>
Cc: leo.yan@arm.com, acme@kernel.org, adrian.hunter@intel.com,
	alexander.shishkin@linux.intel.com, irogers@google.com,
	jolsa@kernel.org, justinstitt@google.com,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	mark.rutland@arm.com, mingo@redhat.com, morbo@google.com,
	nathan@kernel.org, nick.desaulniers+lkml@gmail.com,
	peterz@infradead.org
Subject: Re: [PATCH] perf build: Support passing extra Clang options via EXTRA_BPF_FLAGS
Date: Tue, 25 Nov 2025 00:13:52 -0800	[thread overview]
Message-ID: <aSVlQHJ9xcGcZULp@google.com> (raw)
In-Reply-To: <20251124073445.3709-1-hupu.gm@gmail.com>

Hello,

On Mon, Nov 24, 2025 at 03:34:45PM +0800, hupu wrote:
> When cross-compiling perf with BPF enabled, Clang is invoked during the
> build. Some cross-compilation environments require additional compiler
> options, such as `--sysroot` or custom include paths.
> 
> This patch introduces a new Make variable, `EXTRA_BPF_FLAGS`. During BPF
> skeleton builds, it appends user-provided options to `CLANG_OPTIONS`,
> allowing extra Clang flags to be set without modifying Makefile.perf
> directly.
> 
> Example usage:
>     make perf ARCH="arm64" EXTRA_BPF_FLAGS="--sysroot=..."
> 
> Change history:
>   v3:
>     - Move the variable description comment to the top of Makefile.perf
>     - Update commit message
>   v2:
>     - Rename EXTRA_CLANG_FLAGS to EXTRA_BPF_FLAGS
>     - Update commit message
>   v1:
>     - Introduce EXTRA_CLANG_FLAGS to allow passing extra Clang options
> 
> Signed-off-by: hupu <hupu.gm@gmail.com>
> ---
>  tools/perf/Makefile.perf | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index 47c906b807ef..c1a66cf3d1a7 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -35,6 +35,9 @@ include ../scripts/utilities.mak
>  #
>  # Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
>  #
> +# Define EXTRA_BPF_FLAGS="--sysroot=<path>" or other custom include paths for
> +# cross-compiling BPF skeletons
> +#
>  # Define EXCLUDE_EXTLIBS=-lmylib to exclude libmylib from the auto-generated
>  # EXTLIBS.
>  #
> @@ -1249,6 +1252,8 @@ else
>  	$(Q)cp "$(VMLINUX_H)" $@
>  endif
>  
> +CLANG_OPTIONS += $(EXTRA_BPF_FLAGS)

While it seems CLANG_OPTIONS is used only for BPF skeletons, I think
it's better to add it directly to the below lines instead of adding it
to CLANG_OPTIONS like following.

> +
>  $(SKEL_TMP_OUT)/%.bpf.o: $(OUTPUT)PERF-VERSION-FILE util/bpf_skel/perf_version.h | $(SKEL_TMP_OUT)
>  $(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) $(SKEL_OUT)/vmlinux.h
>  	$(QUIET_CLANG)$(CLANG) -g -O2 -fno-stack-protector --target=bpf \

	  $(CLANG_OPTIONS) $(EXTRA_BPF_FLAGS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \

Thanks,
Namhyung

  reply	other threads:[~2025-11-25  8:13 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-13  8:06 [RFC] perf build: Allow passing extra Clang flags via EXTRA_CLANG_FLAGS hupu
2025-10-13  8:07 ` hupu
2025-10-13 15:46   ` Ian Rogers
2025-10-13 16:14     ` Leo Yan
2025-10-14  2:31       ` hupu
2025-10-15  9:30         ` Leo Yan
2025-10-15 11:47           ` hupu
2025-10-15 12:55             ` Leo Yan
2025-10-18 10:05             ` hupu
2025-10-19  2:30               ` Namhyung Kim
2025-10-19  7:57                 ` hupu
2025-10-20  1:16                   ` Namhyung Kim
2025-10-20  2:38                     ` hupu
2025-10-20  2:40                       ` [PATCH] perf build: Support passing extra Clang options via EXTRA_BPF_FLAGS hupu
2025-10-20  4:16                         ` Namhyung Kim
2025-10-20  8:00                           ` hupu
2025-10-20  8:02                             ` hupu
2025-10-20 10:15                           ` Leo Yan
2025-10-20 12:51                             ` hupu
2025-10-20 13:02                               ` hupu
2025-10-21  3:11                                 ` hupu
2025-11-18  7:18                                   ` hupu
2025-11-18  7:28                                     ` hupu
2025-11-19  9:43                                       ` hupu
2025-11-20 19:22                                         ` Namhyung Kim
2025-11-21 10:17                                           ` hupu
2025-11-24  7:26                                             ` hupu
2025-11-24  7:34                                               ` hupu
2025-11-25  8:13                                                 ` Namhyung Kim [this message]
2025-11-25 12:52                                                   ` hupu
2025-11-25 13:07                                                     ` hupu
2025-11-25 16:10                                                       ` Leo Yan
2025-11-26 13:44                                                         ` hupu
2025-12-05  6:33                                                           ` hupu
2025-12-08  9:05                                                             ` hupu
2025-12-10 10:24                                                               ` hupu
2025-12-11 10:39                                                           ` Leo Yan
2025-12-12  6:12                                                             ` hupu
2025-10-20 13:50                               ` Leo Yan
2025-10-20  2:45                       ` hupu
2025-10-14  1:57     ` [RFC] perf build: Allow passing extra Clang flags via EXTRA_CLANG_FLAGS hupu

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=aSVlQHJ9xcGcZULp@google.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=hupu.gm@gmail.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=justinstitt@google.com \
    --cc=leo.yan@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=peterz@infradead.org \
    /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).