Re: [PATCH] perf build: Support passing extra Clang options via EXTRA_BPF_FLAGS
From: hupu
Date: Wed Nov 19 2025 - 04:43:55 EST
RESEND
On Tue, Nov 18, 2025 at 3:28 PM hupu <hupu.gm@xxxxxxxxx> wrote:
>
> Hi Leo and Namhyung,
>
> On Tue, Nov 18, 2025 at 3:18 PM hupu <hupu.gm@xxxxxxxxx> wrote:
> >
> > I then added KHDR_INCLUDES to BPF_INCLUDE, pointing it to the kernel’s
> > self-contained header directory so that the build prefers headers
> > provided by the kernel.
> >
> >
> > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> > index 47c906b807ef..65c6e871988b 100644
> > --- a/tools/perf/Makefile.perf
> > +++ b/tools/perf/Makefile.perf
> > @@ -1202,7 +1202,8 @@ endif
> >
> > CLANG_OPTIONS = -Wall
> > CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
> > -BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES)
> > +KHDR_INCLUDES := $(abspath $(OUTPUT)/../../usr/include)
> > +BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(LIBBPF_INCLUDE)
> > -I$(KHDR_INCLUDES) $(CLANG_SYS_INCLUDES)
> > TOOLS_UAPI_INCLUDE := -I$(srctree)/tools/include/uapi
> >
> > ifneq ($(WERROR),0)
> >
> >
> > With this change verified, perf compiles successfully even without
> > explicitly specifying the cross-toolchain sysroot in the compile
> > command.
> >
>
> As an additional suggestion, I’d prefer to keep both the above patch
> and the previously discussed PATCH v3, which would mean submitting two
> PRs. From my perspective, allowing users to pass custom compilation
> options via EXTRA_BPF_FLAGS is more flexible than only configuring
> headers, so I’d like to hear your thoughts.
>
> Thanks,
> hupu