[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADHxFxT3TfdfLUYUqDqnx2ZBzn9uiSoDpo+R-u_t2U9OCoHRew@mail.gmail.com>
Date: Fri, 5 Dec 2025 14:29:53 +0800
From: hupu <hupu.gm@...il.com>
To: Leo Yan <leo.yan@....com>
Cc: namhyung@...nel.org, acme@...nel.org, adrian.hunter@...el.com,
alexander.shishkin@...ux.intel.com, irogers@...gle.com, jolsa@...nel.org,
justinstitt@...gle.com, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org, mark.rutland@....com, mingo@...hat.com,
morbo@...gle.com, nathan@...nel.org, nick.desaulniers+lkml@...il.com,
peterz@...radead.org
Subject: Re: [RFC] perf build: Use self-contained headers from kernel source
when compiling
Hi Leo,
Thank you for your reply.
On Wed, Nov 26, 2025 at 12:39 AM Leo Yan <leo.yan@....com> wrote:
>
[...]
>
> This doesn't work if use the commands:
>
> make -j `nproc` Image O=$OUT
> make headers_install O=$OUT
> make O=$OUT -C tools/perf VF=1 CORESIGHT=1 DEBUG=1
>
Oh, yes, I followed the steps you provided and was able to reproduce
the issue exactly as described. Thank you very much for pointing it
out.
> Maybe it is good to search possible paths:
>
> $(abspath ../../usr/include) => Build in local folder
> $(abspath $(OUTPUT)usr/include) => Build in a specified folder
>
> > +BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(LIBBPF_INCLUDE) \
> > + -I$(KHDR_INCLUDES) $(CLANG_SYS_INCLUDES)
>
I agree with your suggestion, but I think the following search path
order might be more suitable.
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 47c906b807ef..0f1113b8552c 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -1202,7 +1202,13 @@ 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 := -I$(abspath $(OUTPUT)../../usr/include) \
+-I$(abspath $(OUTPUT)../../arch/$(SRCARCH)/include/generated/uapi) \
+-I$(abspath $(OUTPUT)../../arch/$(SRCARCH)/include/uapi)
+
+BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(LIBBPF_INCLUDE) \
+ $(KHDR_INCLUDES) $(CLANG_SYS_INCLUDES)
TOOLS_UAPI_INCLUDE := -I$(srctree)/tools/include/uapi
ifneq ($(WERROR),0)
It’s worth noting that if the 'O=XXX' parameter is not specified
during the build, the OUTPUT variable will be empty. In this case, the
header files will be searched under the kernel source tree, which
corresponds to the 'local folder' scenario you mentioned above.
I have tested the patch in both scenarios below, and it works
correctly in each case:
Case 1: Build with 'O=$BUILD_DIR' specified
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE Image O=$BUILD_DIR -j$JOBS
make headers_install O=$BUILD_DIR
make perf ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE O=$BUILD_DIR -j$JOBS
Case 2: Build without O=$BUILD_DIR specified
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE Image -j$JOBS
make headers_install
make perf ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE -j$JOBS
> Why the issue only happens for eBPF skel build but not for perf binary
> build? As I said in another reply, I'd consolidate options for both
> cases.
>
Regarding your question — “Why does the issue only occur for eBPF skel
build, but not for perf binary build?” — here is my personal opinion:
As I mentioned in my previous reply (link below), eBPF skel and perf
binary are built using different toolchains — clang for the former,
and gcc or a cross-compilation toolchain for the latter. Without
deliberate unification, they will naturally use different compiler
options during the build process.
https://lore.kernel.org/all/CADHxFxQ2kb2pRhn0-_PJwmo9pykHzDMJDPQay5GaqmmZF1nwSw@mail.gmail.com/#t
Thanks,
hupu
Powered by blists - more mailing lists