linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] perf build: Allow passing extra Clang flags via EXTRA_CLANG_FLAGS
@ 2025-10-13  8:06 hupu
  2025-10-13  8:07 ` hupu
  0 siblings, 1 reply; 41+ messages in thread
From: hupu @ 2025-10-13  8:06 UTC (permalink / raw)
  To: namhyung, irogers, peterz, mingo, acme, mark.rutland,
	alexander.shishkin, jolsa, adrian.hunter, nathan,
	nick.desaulniers+lkml, morbo, justinstitt, linux-kernel,
	linux-perf-users
  Cc: hupu.gm

When cross-compiling perf with the BPF option enabled, Clang is used
during the build process. Some environments may require additional
compiler options such as `--sysroot` or custom include paths. This patch
adds a new make variable, `EXTRA_CLANG_FLAGS`, which appends user-specified
options to `CLANG_OPTIONS` during BPF skeleton builds.

Example:

  EXTRA_CLANG_FLAGS="--sysroot=$SYSROOT"
  make perf ARCH=arm64 EXTRA_CLANG_FLAGS="$EXTRA_CLANG_FLAGS"

This enables more flexible cross-compilation setups without modifying
Makefile.perf directly.

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..b0da7314a0d8 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_CLANG_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


^ permalink raw reply related	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2025-12-12  6:12 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).