mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: hupu <hupu.gm@gmail.com>
To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
	namhyung@kernel.org, mark.rutland@arm.com,
	alexander.shishkin@linux.intel.com, jolsa@kernel.org,
	irogers@google.com, adrian.hunter@intel.com,
	james.clark@linaro.org, nathan@kernel.org,
	nick.desaulniers+lkml@gmail.com, morbo@google.com,
	justinstitt@google.com, linux-perf-users@vger.kernel.org,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
	hupu.gm@gmail.com
Subject: [RFC 2/2] perf build: Prefer kernel source headers for BPF skeletons
Date: Tue, 23 Dec 2025 16:43:35 +0800	[thread overview]
Message-ID: <20251223084337.3789-3-hupu.gm@gmail.com> (raw)
In-Reply-To: <20251223084337.3789-1-hupu.gm@gmail.com>

When building eBPF skeletons with Clang, prefer header files provided by
the kernel source tree over headers installed on the host system.

While host-installed UAPI headers can be sufficient today, they are
tightly coupled to the host environment and may diverge from the target
kernel version over time as the kernel evolves. Relying on kernel source
headers helps ensure that the headers used during the build remain
consistent with the target kernel version and reduces dependence on the
host build environment.

This change adds the kernel source UAPI and generated header paths to
the BPF include list and places them before the system include paths,
while still keeping host headers (CLANG_SYS_INCLUDES) as a fallback.

Signed-off-by: hupu <hupu.gm@gmail.com>
---
 tools/perf/Makefile.perf | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 8b8647fd4f41..57c73ab98703 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -1203,7 +1203,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)
-- 
2.43.0


  parent reply	other threads:[~2025-12-23  8:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-23  8:43 [RFC 0/2] perf build: Improve header handling for BPF skeleton cross-builds hupu
2025-12-23  8:43 ` [RFC 1/2] perf build: Allow passing extra Clang flags via EXTRA_BPF_FLAGS hupu
2025-12-23 18:20   ` Namhyung Kim
2026-02-10  5:54     ` hupu
2026-02-11 16:27       ` Arnaldo Carvalho de Melo
2025-12-23  8:43 ` hupu [this message]
2026-01-12  1:46   ` [RFC 2/2] perf build: Prefer kernel source headers for BPF skeletons hupu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251223084337.3789-3-hupu.gm@gmail.com \
    --to=hupu.gm@gmail.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=justinstitt@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=morbo@google.com \
    --cc=namhyung@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®