Re: [PATCH] perf build: Support passing extra Clang options via EXTRA_BPF_FLAGS
From: Leo Yan
Date: Tue Nov 25 2025 - 11:20:06 EST
On Tue, Nov 25, 2025 at 09:07:26PM +0800, hupu wrote:
[...]
> --- 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.
> #
> @@ -1252,7 +1255,7 @@ endif
> $(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) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \
> + $(CLANG_OPTIONS) $(EXTRA_BPF_FLAGS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \
I am concerned for this change.
How can you only build eBPF skel program with "--sysroot" but not
applying the same build env on perf binary and associated libs (libperf,
bpftool, etc) ?
For a convinced solution, I'd expect we can apply PKG_CONFIG_SYSROOT_DIR
for both normal perf build and eBPF skel build. More important, please
provide steps for how to build perf with a SDK.
Thanks,
Leo