From: Namhyung Kim <namhyung@kernel.org>
To: hupu <hupu.gm@gmail.com>
Cc: Leo Yan <leo.yan@arm.com>,
acme@kernel.org, adrian.hunter@intel.com,
alexander.shishkin@linux.intel.com, irogers@google.com,
jolsa@kernel.org, justinstitt@google.com,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
mark.rutland@arm.com, mingo@redhat.com, morbo@google.com,
nathan@kernel.org, nick.desaulniers+lkml@gmail.com,
peterz@infradead.org
Subject: Re: [PATCH] perf build: Support passing extra Clang options via EXTRA_BPF_FLAGS
Date: Mon, 15 Dec 2025 21:58:37 -0800 [thread overview]
Message-ID: <aUD1DXHh_PrCjZ96@google.com> (raw)
In-Reply-To: <CADHxFxRayyDK5qO3j-GtQAuWruk8UtQ-6EcvYb-3iKtE8ooJUQ@mail.gmail.com>
Hello,
On Fri, Dec 12, 2025 at 02:12:09PM +0800, hupu wrote:
> Hi Leo,
> On Thu, Dec 11, 2025 at 6:40 PM Leo Yan <leo.yan@arm.com> wrote:
> >
> > On Wed, Nov 26, 2025 at 09:44:02PM +0800, hupu wrote:
> >
> > Please don't spam on mailing list as you did. It is really bad practice.
> > You could find resources [1][2] to learn upstreaming and co-work on the
> > ML.
> >
>
> I apologize for the inconvenience caused by my frequent emails. I only
> hoped to bring this nearly two-month-long discussion to a conclusion
> sooner.
Sorry for the delay. But sometimes it takes time to get a consensus in
an open discussion. And it's been in a merge window + travelling for
LPC 2025. Please don't hurry up.
>
>
> > > The eBPF skeleton is compiled via clang --target=bpf, and its header
> > > file search paths mainly come from BPF_INCLUDE and TOOLS_UAPI_INCLUDE.
> > > It also uses '-idirafter' to include the host’s /usr/local/include and
> > > /usr/include directories in the search path. This process is not
> > > directly coupled with cross-compilation managed via pkg-config, which
> > > means PKG_CONFIG_SYSROOT_DIR does not affect how the skeleton resolves
> > > its headers.
> >
> > Based on my limited knowledge, Clang does not provide its own headers.
> > It needs to rely on GCC's headers for compilation. I do see the
> > Makefile does right thing for finding headers:
> >
> > Makefile.perf:1203: ***
> > CLANG_SYS_INCLUDES=-idirafter /usr/lib/llvm-18/lib/clang/18/include
> > -idirafter /usr/local/include
> > -idirafter /usr/bin/../lib/gcc-cross/aarch64-linux-gnu/14/../../../../aarch64-linux-gnu/include
> > -idirafter /usr/include/aarch64-linux-gnu
> > -idirafter /usr/include
> >
> > It is mess to add some random include paths and feed to clang. We
> > already have provided a reliable way for building eBPF skelton program
> > - keep in mind, eBPF skeleton program is not any aarch64 cross
> > compilation, we just use clang for building bpf target.
> >
> > My understanding is you don't have a sane setting up on your local
> > building env.
> >
>
> Although I have explained my view in earlier emails, it seems the
> discussion has returned to the initial state.
>
> Indeed, as you mentioned in the early discussion, running the
> following commands on the host to install certain packages can
> successfully compile perf:
> > $ sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
> > $ sudo apt-get install libc6-dev-aarch64-cross linux-libc-dev-aarch64-cross
> > $ sudo apt-get install libc6-dev-arm64-cross linux-libc-dev-arm64-cross
At this point, I'm confused whether we are talking about general
cross-build or just BPF skeleton. I agree with Leo that the skeleton
build should not require any host specific information rather than
vmlinux.h.
>
>
> However, I don’t think relying on the host build environment is the
> best approach, for several reasons:
>
> a) These commands install UAPI header files on the host, especially
> `linux-libc-dev-aarch64-cross` and `linux-libc-dev-arm64-cross`. These
> headers originate from the kernel source tree’s `include/uapi/` and
> `arch/arm64/include/uapi/` directories, and their versions are tied to
> the *HOST* kernel version. If the target kernel version is different,
> mismatches may cause compilation errors or even runtime failures.
>
> b) Even if `perf` can be compiled and run successfully now, there is
> no guarantee that the kernel source headers will always match the
> host-installed UAPI headers as the upstream kernel evolves.
>
> c) In scenarios where the host acts as a general build server and
> needs to build multiple target kernel versions, it is not possible to
> ensure that the host UAPI headers are compatible with all target
> versions.
>
> d) As you pointed out, `CLANG_SYS_INCLUDES` does include host headers,
> but it uses `-idirafter` instead of `-I`. This means the host headers
> have lower priority. This change was introduced in commit a2af0f6b8ef7
> ("perf build: Add system include paths to BPF builds"); as noted in
> the commit message, the preferred approach is to use kernel source
> headers rather than potentially older ones from the system.
>
>
> Based on this, I propose the following include order:
> - Prefer kernel source headers
> [RFC] perf build: Use self-contained headers from kernel source when compiling
> https://lore.kernel.org/all/20251124072310.3592-1-hupu.gm@gmail.com/
>
> - Allow users to specify header search paths matching the target
> kernel version (eg. via `EXTRA_BPF_FLAGS`)
> [PATCH] perf build: Support passing extra Clang options via EXTRA_BPF_FLAGS
> https://lore.kernel.org/all/20251013080609.2070555-1-hupu.gm@gmail.com/
I'm ok with this part - not only to pass header search paths, it can do
anything user wants to add to the compiler. You may want to send it out
in a separate thread with all comments addressed.
>
> - Fall back to the host build environment only if necessary
>
>
> In summary, while relying on the host build environment can fix the
> current build issue, I believe it is not the optimal solution.
>
> Anyway, regardless of the final decision, I will respect it. Before
> concluding, I hope we can explore this further and involve more
> maintainers in the discussion. As for your comment, "you don't have a
> sane setting up on your local building env", I am not yet fully
> convinced by this reason.
>
> Lastly, I once again apologize for any disturbance caused by my
> frequent emails, and I sincerely thank both you and Namhyung for your
> involvement throughout this process. I also hope this discussion will
> attract more attention so that additional maintainers can participate.
Thanks for your understanding,
Namhyung
next prev parent reply other threads:[~2025-12-16 5:58 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
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-12-16 5:58 ` Namhyung Kim [this message]
2025-12-16 12:29 ` hupu
2025-12-17 15:35 ` Namhyung Kim
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
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=aUD1DXHh_PrCjZ96@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=hupu.gm@gmail.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=justinstitt@google.com \
--cc=leo.yan@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.