[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251020024049.6877-1-hupu.gm@gmail.com>
Date: Mon, 20 Oct 2025 10:40:49 +0800
From: hupu <hupu.gm@...il.com>
To: hupu.gm@...il.com
Cc: acme@...nel.org,
adrian.hunter@...el.com,
alexander.shishkin@...ux.intel.com,
irogers@...gle.com,
jolsa@...nel.org,
justinstitt@...gle.com,
leo.yan@....com,
linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org,
mark.rutland@....com,
mingo@...hat.com,
morbo@...gle.com,
namhyung@...nel.org,
nathan@...nel.org,
nick.desaulniers+lkml@...il.com,
peterz@...radead.org
Subject: [PATCH] perf build: Support passing extra Clang options via EXTRA_BPF_FLAGS
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:
EXTRA_BPF_FLAGS="--sysroot=$SYSROOT"
make perf ARCH="$ARCH" EXTRA_BPF_FLAGS="$EXTRA_BPF_FLAGS"
Change history:
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@...il.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..f1f2efdbab8c 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -1249,6 +1249,11 @@ else
$(Q)cp "$(VMLINUX_H)" $@
endif
+# Allow users to specify additional Clang options (e.g. --sysroot)
+# when cross-compiling BPF skeletons, enabling more flexible
+# build configurations.
+CLANG_OPTIONS += $(EXTRA_BPF_FLAGS)
+
$(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 \
--
2.43.0
Powered by blists - more mailing lists