Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross compile failed with aarch64-none-linux-gnu #129

Open
KevinChau9527 opened this issue Nov 29, 2022 · 3 comments
Open

Cross compile failed with aarch64-none-linux-gnu #129

KevinChau9527 opened this issue Nov 29, 2022 · 3 comments

Comments

@KevinChau9527
Copy link

Hi, I'm using buildroot to cross compile bptfool and I get some error

2022-11-29T12:30:29 
2022-11-29T12:30:29 Auto-detecting system features:
2022-11-29T12:30:29 ...                        libbfd: [ on  ]
2022-11-29T12:30:29 ...        disassembler-four-args: [ on  ]
2022-11-29T12:30:29 ...                          zlib: [ on  ]
2022-11-29T12:30:29 ...                        libcap: [ on  ]
2022-11-29T12:30:29 ...               clang-bpf-co-re: [ on  ]
2022-11-29T12:30:29 
2022-11-29T12:30:31 CC       map_perf_ring.o
2022-11-29T12:30:32 CC       xlated_dumper.o
2022-11-29T12:30:33 CC       iter.o
2022-11-29T12:30:35 CC       btf.o
2022-11-29T12:30:36 CC       tracelog.o
2022-11-29T12:30:38 CC       link.o
2022-11-29T12:30:39 CC       perf.o
2022-11-29T12:30:40 CC       cfg.o
2022-11-29T12:30:41 CC       btf_dumper.o
2022-11-29T12:30:43 CC       net.o
2022-11-29T12:30:44 CC       struct_ops.o
2022-11-29T12:30:46 CC       netlink_dumper.o
2022-11-29T12:30:47 CC       common.o
2022-11-29T12:30:48 CC       cgroup.o
2022-11-29T12:30:50 CC       gen.o
2022-11-29T12:30:51 CC       main.o
2022-11-29T12:30:52 CC       json_writer.o
2022-11-29T12:30:53 
2022-11-29T12:30:53 Auto-detecting system features:
2022-11-29T12:30:53 ...                        libelf: [ on  ]
2022-11-29T12:30:53 ...                          zlib: [ on  ]
2022-11-29T12:30:53 ...                           bpf: [ on  ]
2022-11-29T12:30:53 
2022-11-29T12:30:53 GEN      bpf_helper_defs.h
2022-11-29T12:30:53 MKDIR    staticobjs/
2022-11-29T12:30:53 CC       staticobjs/libbpf.o
2022-11-29T12:30:55 CC       staticobjs/bpf.o
2022-11-29T12:30:55 CC       staticobjs/nlattr.o
2022-11-29T12:30:55 CC       staticobjs/btf.o
2022-11-29T12:30:56 CC       staticobjs/libbpf_errno.o
2022-11-29T12:30:56 CC       staticobjs/str_error.o
2022-11-29T12:30:56 CC       staticobjs/netlink.o
2022-11-29T12:30:56 CC       staticobjs/bpf_prog_linfo.o
2022-11-29T12:30:56 CC       staticobjs/libbpf_probes.o
2022-11-29T12:30:56 CC       staticobjs/xsk.o
2022-11-29T12:30:56 CC       staticobjs/hashmap.o
2022-11-29T12:30:56 CC       staticobjs/btf_dump.o
2022-11-29T12:30:57 CC       staticobjs/ringbuf.o
2022-11-29T12:30:57 LD       staticobjs/libbpf-in.o
2022-11-29T12:30:57 LINK     libbpf.a
2022-11-29T12:30:58 LINK     bpftool-bootstrap
2022-11-29T12:30:58 GEN      vmlinux.h
2022-11-29T12:30:58 ./bpftool-bootstrap: error while loading shared libraries: libelf.so.1: cannot open shared object file: No such file or directory
2022-11-29T12:30:58 make[2]: *** [Makefile:140: vmlinux.h] Error 127

It seems an error occurred when executing the bpftool-bootstrap program to generate vmlinux.h .

What should I do to skip this operation, or is there any way to fix it ?

Device:

HOST kernel version:

$ uname -a
Linux KEVIN 5.15.0-53-generic #59~20.04.1-Ubuntu SMP Thu Oct 20 15:10:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Target kernel version:
VERSION = 5
PATCHLEVEL = 10
SUBLEVEL = 66

My cross-compile toolchain:

gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu

$ aarch64-none-linux-gnu-gcc --version
aarch64-none-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)) 10.3.1 20210621
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@anakryiko
Copy link
Member

We are using bootstrap version of bpftool (as it's smaller and builds faster), but it will be built for host system. So for cross-compilation we'd need to use final bpftool version, probably. Can you try adjusting Makefile to build full bpftool version and give it a try in your environment?

@woodpenker
Copy link
Contributor

It seems that libelf.so.1 is missing from the build env. If you are using an arm rootfs to do cross-compile, you may need to chroot into it and install the libelf.

@JiaHuann
Copy link

https://github.com/JiaHuann/libbpf-bootstrap-android This may help you to crosscompile to aarch64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants