[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADHxFxQ2kb2pRhn0-_PJwmo9pykHzDMJDPQay5GaqmmZF1nwSw@mail.gmail.com>
Date: Wed, 26 Nov 2025 21:44:02 +0800
From: hupu <hupu.gm@...il.com>
To: Leo Yan <leo.yan@....com>
Cc: Namhyung Kim <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: [PATCH] perf build: Support passing extra Clang options via EXTRA_BPF_FLAGS
Hi Leo,
Thank you for your reply.
On Wed, Nov 26, 2025 at 12:10 AM Leo Yan <leo.yan@....com> wrote:
>
> On Tue, Nov 25, 2025 at 09:07:26PM +0800, hupu wrote:
>
> [...]
>
> > --- a/tools/perf/Makefile.perf
> > +++ b/tools/perf/Makefile.perf
> > @@ -35,6 +35,9 @@ include ../scripts/utilities.mak
> > #
> > # Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for
> > cross-builds.
> > #
> > +# Define EXTRA_BPF_FLAGS="--sysroot=<path>" or other custom include paths for
> > +# cross-compiling BPF skeletons
> > +#
> > # Define EXCLUDE_EXTLIBS=-lmylib to exclude libmylib from the auto-generated
> > # EXTLIBS.
> > #
> > @@ -1252,7 +1255,7 @@ endif
> > $(SKEL_TMP_OUT)/%.bpf.o: $(OUTPUT)PERF-VERSION-FILE
> > util/bpf_skel/perf_version.h | $(SKEL_TMP_OUT)
> > $(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) $(SKEL_OUT)/vmlinux.h
> > $(QUIET_CLANG)$(CLANG) -g -O2 -fno-stack-protector --target=bpf \
> > - $(CLANG_OPTIONS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \
> > + $(CLANG_OPTIONS) $(EXTRA_BPF_FLAGS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \
>
> I am concerned for this change.
>
> How can you only build eBPF skel program with "--sysroot" but not
> applying the same build env on perf binary and associated libs (libperf,
> bpftool, etc) ?
>
> For a convinced solution, I'd expect we can apply PKG_CONFIG_SYSROOT_DIR
> for both normal perf build and eBPF skel build. More important, please
>
I understand your concern, and I will explain it with reference to the
current source code.
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.
1252 $(SKEL_TMP_OUT)/%.bpf.o: $(OUTPUT)PERF-VERSION-FILE
util/bpf_skel/perf_version.h | $(SKEL_TMP_OUT)
1253 $(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF)
$(SKEL_OUT)/vmlinux.h
1254 $(QUIET_CLANG)$(CLANG) -g -O2 -fno-stack-protector --target=bpf \
1255 $(CLANG_OPTIONS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \
1256 -include $(OUTPUT)PERF-VERSION-FILE -include
util/bpf_skel/perf_version.h \
1257 -c $(filter util/bpf_skel/%.bpf.c,$^) -o $@
I added some debugging output to inspect the contents of BPF_INCLUDE:
BPF_INCLUDE:
-I/home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/..
-I/home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/include
-idirafter /usr/lib/llvm-18/lib/clang/18/include
-idirafter /usr/local/include
-idirafter /usr/include
The perf binary and its associated libraries (such as libperf) are
built with the cross toolchain. Their dependency headers and library
paths are determined by CFLAGS/LDFLAGS and resolved via pkg-config. In
this case, PKG_CONFIG_SYSROOT_DIR is indeed the correct control point.
802 $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN)
803 $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) \
804 $(PERF_IN) $(LIBS) -o $@
971 $(LIBPERF): FORCE | $(LIBPERF_OUTPUT)
972 $(Q)$(MAKE) -C $(LIBPERF_DIR) O=$(LIBPERF_OUTPUT) \
973 DESTDIR=$(LIBPERF_DESTDIR) prefix= subdir= \
974 $@ install_headers
>From the current build logic, there is no strict requirement for the
skeleton and the perf binary to use exactly the same headers, because
we cannot guarantee that the headers in the host’s /usr/local/include
and /usr/include are fully consistent with the kernel source.
If the goal is to enforce header consistency, my other proposed patch
— “perf build: Use self-contained headers from kernel source when
compiling” — explicitly ensures that the skeleton uses UAPI headers
from the kernel source tree, thus aligning the skeleton’s headers with
those used by the perf binary.
Finally, introducing EXTRA_BPF_FLAGS offers a controlled, optional
extension point for the skeleton build, rather than solely passing
--sysroot. This allows users to add additional options such as -I or
-D to address specific include resolution needs in certain
environments. It is more flexible than hardcoding paths, and does not
modify the existing pkg-config managed search paths used for
user-space builds.
> for both normal perf build and eBPF skel build. More important, please
> provide steps for how to build perf with a SDK.
>
(I apologize in advance — I may paste some build log output below.
This could make the email appear somewhat cluttered, and may also
cause line wrapping or truncation in some mail clients.)
If EXTRA_BPF_FLAGS is not specified during the perf build (example
command shown below), the compilation will fail:
make perf ARCH=arm64 CROSS_COMPILE=aarch64-dumpstack-linux-gnu-
LDFLAGS="-L/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib/aarch64-linux-gnu
-L/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib
-static" O=/home/hupu/work/code/explore/output/build-mainline -j8
The full build failure log is as follows:
21:38:16 (00:00:00) - INFO : Starting build perf tools for arm64 ...
21:38:16 (00:00:00) - INFO : make perf ARCH=arm64
CROSS_COMPILE=aarch64-dumpstack-linux-gnu-
LDFLAGS="-L/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib/aarch64-linux-gnu
-L/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib
-static" O=/home/hupu/work/code/explore/output/build-mainline -j8
BUILD: Doing 'make -j4' parallel build
Warning: Kernel ABI header differences:
diff -u tools/arch/arm64/include/asm/cputype.h
arch/arm64/include/asm/cputype.h
diff -u tools/perf/trace/beauty/include/uapi/linux/mount.h
include/uapi/linux/mount.h
Makefile.config:590: No elfutils/debuginfod.h found, no debuginfo
server support, please install
libdebuginfod-dev/elfutils-debuginfod-client-devel or equivalent
Makefile.config:633: No sys/sdt.h found, no SDT events are defined,
please install systemtap-sdt-devel or systemtap-sdt-dev
Makefile.config:881: No 'Python.h' was found: disables Python support
- please install python-devel/python-dev
Makefile.config:989: No libllvm 13+ found, slower source file
resolution, please install llvm-devel/llvm-dev
Makefile.config:1099: No libbabeltrace found, disables 'perf data' CTF
format support, please install
libbabeltrace-dev[el]/libbabeltrace-ctf-dev
Makefile.config:1142: No alternatives command found, you need to set
JDIR= to point to the root of your Java directory
Makefile.config:1173: libpfm4 not found, disables libpfm4 support.
Please install libpfm-devel or libpfm4-dev
Auto-detecting system features:
... libdw: [ on ]
... glibc: [ on ]
... libelf: [ on ]
... libnuma: [ on ]
... numa_num_possible_cpus: [ on ]
... libpython: [ OFF ]
... libcapstone: [ on ]
... llvm-perf: [ OFF ]
... zlib: [ on ]
... lzma: [ on ]
... get_cpuid: [ OFF ]
... bpf: [ on ]
... libaio: [ on ]
... libzstd: [ on ]
GEN /home/hupu/work/code/explore/output/build-mainline/tools/perf/common-cmds.h
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/dlfilters/dlfilter-test-api-v0.o
GEN /home/hupu/work/code/explore/output/build-mainline/tools/perf/arch/arm64/include/generated/asm/sysreg-defs.h
PERF_VERSION = 6.18.rc7.g30f09200cc4a
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/dlfilters/dlfilter-test-api-v2.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/dlfilters/dlfilter-show-cycles.o
MKDIR /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/fd/
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/fd/array.o
SYSHDR /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/arch/arm64/include/generated/uapi/asm/unistd_64.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/include/perf/bpf_perf.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/include/perf/core.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/include/perf/cpumap.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/include/perf/threadmap.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/include/perf/evlist.h
LD /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/fd/libapi-in.o
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/include/perf/evsel.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/include/perf/event.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/include/perf/mmap.h
MKDIR /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/fs/
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/include/internal/cpumap.h
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/fs/fs.o
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/include/internal/evlist.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsubcmd/include/subcmd/exec-cmd.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/include/internal/evsel.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsubcmd/include/subcmd/help.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/include/internal/lib.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/include/internal/mmap.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsubcmd/include/subcmd/pager.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/include/internal/rc_check.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsubcmd/include/subcmd/parse-options.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/include/internal/threadmap.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/include/internal/xyarray.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsubcmd/include/subcmd/run-command.h
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/core.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsubcmd/exec-cmd.o
INSTALL libsubcmd_headers
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/include/api/cpu.h
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/cpu.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/cpumap.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/debug.o
MKDIR /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/fs/
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/fs/tracing_path.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsubcmd/help.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/fs/cgroup.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/str_error_r.o
LD /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/fs/libapi-in.o
INSTALL libperf_headers
LD /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/libapi-in.o
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/include/api/debug.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/include/api/io.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/include/api/io_dir.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/include/api/fd/array.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/include/api/fs/fs.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/include/api/fs/tracing_path.h
AR /home/hupu/work/code/explore/output/build-mainline/tools/perf/libapi/libapi.a
INSTALL libapi_headers
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/threadmap.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsymbol/kallsyms.o
LD /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsymbol/libsymbol-in.o
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsymbol/include/symbol/kallsyms.h
AR /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsymbol/libsymbol.a
INSTALL libsymbol_headers
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsubcmd/pager.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/evsel.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsubcmd/parse-options.o
GEN /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/bpf_helper_defs.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/include/bpf/bpf.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/include/bpf/libbpf.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/include/bpf/btf.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/include/bpf/libbpf_common.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/include/bpf/libbpf_legacy.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/include/bpf/bpf_helpers.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/include/bpf/bpf_tracing.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/include/bpf/bpf_endian.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/include/bpf/bpf_core_read.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/include/bpf/skel_internal.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/include/bpf/libbpf_version.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/include/bpf/usdt.bpf.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/include/bpf/bpf_helper_defs.h
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/libbpf.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/evlist.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsubcmd/run-command.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsubcmd/sigchain.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsubcmd/subcmd-config.o
LD /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsubcmd/libsubcmd-in.o
AR /home/hupu/work/code/explore/output/build-mainline/tools/perf/libsubcmd/libsubcmd.a
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/bpf.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/mmap.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/nlattr.o
INSTALL libbpf_headers
GEN perf-archive
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/zalloc.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/btf.o
GEN perf-iostat
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/xyarray.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libperf/lib.o
LINK /home/hupu/work/code/explore/output/build-mainline/tools/perf/dlfilters/dlfilter-test-api-v0.so
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/libbpf_utils.o
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
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/netlink.o
LINK /home/hupu/work/code/explore/output/build-mainline/tools/perf/dlfilters/dlfilter-test-api-v2.so
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/bpf_prog_linfo.o
LINK /home/hupu/work/code/explore/output/build-mainline/tools/perf/dlfilters/dlfilter-show-cycles.so
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/libbpf_probes.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/hashmap.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/btf_dump.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/ringbuf.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/strset.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/linker.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/gen_loader.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/relo_core.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/usdt.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/zip.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/elf.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/features.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/btf_iter.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/btf_relocate.o
LD /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/staticobjs/libbpf-in.o
LINK /home/hupu/work/code/explore/output/build-mainline/tools/perf/libbpf/libbpf.a
Auto-detecting system features:
... clang-bpf-co-re: [ on ]
... llvm: [ OFF ]
... libcap: [ on ]
... libbfd: [ OFF ]
MKDIR /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf
MKDIR /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/
MKDIR /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/hashmap.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/relo_core.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf_internal.h
GEN /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/bpf_helper_defs.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/btf.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf_common.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf_legacy.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_helpers.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_tracing.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_endian.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_core_read.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/skel_internal.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf_version.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/usdt.bpf.h
INSTALL /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_helper_defs.h
INSTALL libbpf_headers
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/libbpf.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/bpf.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/nlattr.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/btf.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/libbpf_utils.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/netlink.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/bpf_prog_linfo.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/libbpf_probes.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/hashmap.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/btf_dump.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/ringbuf.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/strset.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/linker.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/gen_loader.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/relo_core.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/usdt.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/zip.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/elf.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/features.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/btf_iter.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/btf_relocate.o
LD /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/libbpf-in.o
LINK /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/libbpf/libbpf.a
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/main.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/common.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/json_writer.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/gen.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/btf.o
CC /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/sign.o
LINK /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bootstrap/bpftool
/usr/bin/ld: skipping incompatible
/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib/aarch64-linux-gnu/libelf.a
when searching for -lelf
/usr/bin/ld: skipping incompatible
/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib/aarch64-linux-gnu/libelf.a
when searching for -lelf
/usr/bin/ld: skipping incompatible
/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib/aarch64-linux-gnu/libz.a
when searching for -lz
/usr/bin/ld: skipping incompatible
/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib/aarch64-linux-gnu/libz.a
when searching for -lz
/usr/bin/ld: skipping incompatible
/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a
when searching for -lcrypto
/usr/bin/ld: skipping incompatible
/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a
when searching for -lcrypto
/usr/bin/ld: skipping incompatible
/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib/aarch64-linux-gnu/libzstd.a
when searching for -lzstd
/usr/bin/ld: skipping incompatible
/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib/aarch64-linux-gnu/libzstd.a
when searching for -lzstd
/usr/bin/ld: skipping incompatible
/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib/libc.a
when searching for -lc
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/libcrypto.a(libcrypto-lib-dso_dlfcn.o):
in function `dlfcn_globallookup':
(.text+0x1f): warning: Using 'dlopen' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/libcrypto.a(libcrypto-lib-bio_addr.o):
in function `BIO_lookup_ex':
(.text+0xdbc): warning: Using 'getaddrinfo' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/libcrypto.a(libcrypto-lib-bio_sock.o):
in function `BIO_gethostbyname':
(.text+0x85): warning: Using 'gethostbyname' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
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
CLANG /home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bperf_cgroup.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>
| ^~~~~~~~~~~~~
1 error generated.
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>
| ^~~~~~~~~~~~~
1 error generated.
make[3]: *** [Makefile.perf:1254:
/home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bpf_prog_profiler.bpf.o]
Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [Makefile.perf:1254:
/home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bperf_leader.bpf.o]
Error 1
1 error generated.
make[3]: *** [Makefile.perf:1254:
/home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bperf_follower.bpf.o]
Error 1
1 error generated.
make[3]: *** [Makefile.perf:1254:
/home/hupu/work/code/explore/output/build-mainline/tools/perf/util/bpf_skel/.tmp/bperf_cgroup.bpf.o]
Error 1
make[2]: *** [Makefile.perf:289: sub-make] Error 2
make[1]: *** [Makefile:76: all] Error 2
make: *** [Makefile:93: perf] Error 2
However, when applying the patch “perf build: Support passing extra
Clang options via EXTRA_BPF_FLAGS”, running the following command
successfully builds perf:
make perf ARCH=arm64 CROSS_COMPILE=aarch64-dumpstack-linux-gnu-
EXTRA_BPF_FLAGS="--sysroot=/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot"
LDFLAGS="-L/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib/aarch64-linux-gnu
-L/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib
-static" O=/home/hupu/work/code/explore/output/build-mainline -j8
Similarly, when applying the patch “perf build: Use self-contained
headers from kernel source when compiling”, perf can also be
successfully built without specifying EXTRA_BPF_FLAGS:
make perf ARCH=arm64 CROSS_COMPILE=aarch64-dumpstack-linux-gnu-
LDFLAGS="-L/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib/aarch64-linux-gnu
-L/home/hupu/work/tools/x-tools/aarch64-dumpstack-linux-gnu/bin/../aarch64-dumpstack-linux-gnu/sysroot/usr/lib
-static" O=/home/hupu/work/code/explore/output/build-mainline -j8
Therefore, both patches are valid approaches to successfully build perf.
Thanks,
hupu
Powered by blists - more mailing lists