From: hupu <hupu.gm@gmail.com>
To: Ian Rogers <irogers@google.com>
Cc: Leo Yan <leo.yan@arm.com>,
namhyung@kernel.org, peterz@infradead.org, mingo@redhat.com,
acme@kernel.org, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@kernel.org,
adrian.hunter@intel.com, nathan@kernel.org,
nick.desaulniers+lkml@gmail.com, morbo@google.com,
justinstitt@google.com, linux-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org
Subject: Re: [RFC] perf build: Allow passing extra Clang flags via EXTRA_CLANG_FLAGS
Date: Tue, 14 Oct 2025 09:57:21 +0800 [thread overview]
Message-ID: <CADHxFxR_S43zzrStKVvbFjwkqFFOjMY8xcFK41Fc1U2xYvYJmA@mail.gmail.com> (raw)
In-Reply-To: <CAP-5=fXykcQ7n3rw6RX3S+dLoLUC9BZKh=BP8yx8ak+f623aEg@mail.gmail.com>
Hi lan,
Thank you very much for your reply.
On Mon, Oct 13, 2025 at 11:46 PM Ian Rogers <irogers@google.com> wrote:
>
> On Mon, Oct 13, 2025 at 1:08 AM hupu <hupu.gm@gmail.com> wrote:
> >
> > Hi Maintainer,
> >
> > I encountered some issues while cross-compiling perf (ARCH=arm64),
> > particularly when enabling the BPF option. During the build, Clang
> > fails to compile BPF programs due to missing header files. The
> > relevant error messages are as follows:
>
> Thanks for reporting this issue! There has been some recent work in
> this area by Leo:
> https://lore.kernel.org/lkml/20251006-perf_build_android_ndk-v3-0-4305590795b2@arm.com/
> The patches are in Linux v6.18-rc1. Perhaps you could try repeating
> your build with this tree and reporting issues?
>
My local code is already updated to the latest version, and the
current commit is exactly at tag: v6.18-rc1:
commit 3a8660878839faadb4f1a6dd72c3179c1df56787 (tag: v6.18-rc1,
origin/master, origin/HEAD)
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date: Sun Oct 12 13:42:36 2025 -0700
Linux 6.18-rc1
However, building with this version still gives the same error as
before — when Clang tries to compile the BPF programs, it fails due to
a missing asm/ioctl.h header file.
----------------------------------------------------------
INSTALL libsubcmd_headers
INSTALL libsymbol_headers
SYSHDR /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/arch/arm64/include/generated/uapi/asm/unistd_64.h
INSTALL libapi_headers
INSTALL libperf_headers
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/evsel.o
INSTALL libbpf_headers
CLANG /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bpf_prog_profiler.bpf.o
CLANG /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bperf_leader.bpf.o
CLANG /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bperf_follower.bpf.o
In file included from <built-in>:2:
In file included from ./util/bpf_skel/perf_version.h:6:
In file included from
/home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/../vmlinux.h:7:
In file included from
/home/hupu/work/code/explore/linux-mainline/tools/include/uapi/linux/perf_event.h:19:
/usr/include/linux/ioctl.h:5:10: fatal error: 'asm/ioctl.h' file not found
5 | #include <asm/ioctl.h>
| ^~~~~~~~~~~~~
In file included from <built-in>:2:
In file included from ./util/bpf_skel/perf_version.h:6:
In file included from
/home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/../vmlinux.h:7:
In file included from
/home/hupu/work/code/explore/linux-mainline/tools/include/uapi/linux/perf_event.h:19:
/usr/include/linux/ioctl.h:5:10: fatal error: 'asm/ioctl.h' file not found
5 | #include <asm/ioctl.h>
| ^~~~~~~~~~~~~
In file included from <built-in>:2:
In file included from ./util/bpf_skel/perf_version.h:6:
In file included from
/home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/../vmlinux.h:7:
In file included from
/home/hupu/work/code/explore/linux-mainline/tools/include/uapi/linux/perf_event.h:19:
/usr/include/linux/ioctl.h:5:10: fatal error: 'asm/ioctl.h' file not found
5 | #include <asm/ioctl.h>
| ^~~~~~~~~~~~~
11 error generated.
error generated.
make[3]: *** [Makefile.perf:1259:
/home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bperf_leader.bpf.o]
Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [Makefile.perf:1259:
/home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bpf_prog_profiler.bpf.o]
Error 1
1 error generated.
make[3]: *** [Makefile.perf:1259:
/home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bperf_follower.bpf.o]
Error 1
LD /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/libperf-in.o
AR /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/libperf.a
make[2]: *** [Makefile.perf:289: sub-make] Error 2
make[1]: *** [Makefile:76: all] Error 2
make: *** [Makefile:93: perf] Error 2
----------------------------------------------------------
However, when I apply the previous PATCH and explicitly specify the
sysroot of the cross toolchain via the EXTRA_CLANG_FLAGS setting, the
build succeeds:
SYSROOT=$(${CROSS_COMPILE}gcc --print-sysroot)
EXTRA_CLANG_FLAGS="--sysroot=$SYSROOT"
make perf ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE
EXTRA_CLANG_FLAGS="$EXTRA_CLANG_FLAGS"
Please let me know if you need any more details or testing.
Thanks,
hupu
prev parent reply other threads:[~2025-10-14 1:57 UTC|newest]
Thread overview: 6+ 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-14 1:57 ` hupu [this message]
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=CADHxFxR_S43zzrStKVvbFjwkqFFOjMY8xcFK41Fc1U2xYvYJmA@mail.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=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=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;
as well as URLs for NNTP newsgroup(s).