Closed huogd1999 closed 6 months ago
@qmonnet I think libbpf has linux/err.h inside its our include/ files, can you please check that bpftool passes correct -I to libbpf during its own build?
Taking a look. I can't reproduce, but I do get an error if I run make
from examples/c
:
$ cd examples/c
$ make
LIB libbpf.a
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/bpf.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/btf.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/libbpf.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/libbpf_errno.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/netlink.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/nlattr.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/libbpf_probes.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/btf_dump.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/hashmap.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/ringbuf.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/strset.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/linker.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/gen_loader.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/relo_core.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/usdt.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/zip.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/elf.o
CC /tmp/libbpf-bootstrap/examples/c/.output//libbpf/staticobjs/features.o
AR /tmp/libbpf-bootstrap/examples/c/.output//libbpf/libbpf.a
INSTALL bpf.h libbpf.h btf.h libbpf_common.h libbpf_legacy.h bpf_helpers.h bpf_helper_defs.h bpf_tracing.h bpf_endian.h bpf_core_read.h skel_internal.h libbpf_version.h usdt.bpf.h
INSTALL /tmp/libbpf-bootstrap/examples/c/.output//libbpf/libbpf.pc
INSTALL /tmp/libbpf-bootstrap/examples/c/.output//libbpf/libbpf.a
BPFTOOL bpftool/bootstrap/bpftool
... libbfd: [ on ]
... clang-bpf-co-re: [ on ]
... llvm: [ on ]
... libcap: [ on ]
make[1]: *** No rule to make target '/tmp/libbpf-bootstrap/bpftool/libbpf/src/hashmap.h', needed by '/tmp/libbpf-bootstrap/examples/c/.output/bpftool/bootstrap/libbpf/include/bpf/hashmap.h'. Stop.
make: *** [Makefile:a08b97804db0bcde6c6eca45cef58e436288fe3494: /tmp/libbpf-bootstrap/examples/c/.output/bpftool/bootstrap/bpftool] Error 2
This happens ever since bpftool was added to the repo in commit a08b97804db0bcde6c6eca45cef58e436288fe34. I could be doing something wrong, I'd find it surprising if the examples had been totally broken for so long :thinking:. I'm still looking.
My bad - I was missing the submodule in bpftool/libbpf
OK now that I fixed my setup, bpftool builds just fine and I can't reproduce the error.
I think libbpf has linux/err.h inside its our include/ files, can you please check that bpftool passes correct -I to libbpf during its own build?
It does. The includes seem to be all in order in bpftool's Makefile as far as I can tell, and I don't remember seeing this error before when building from either the kernel repo or the GitHub mirror.
@huogd1999 what commits are you using for libbpf-bootstrap, and the submodules libbpf and bpftool? Did you run git submodule update --init --recursive
to have them all in sync before trying to build? What do you get when building verbose (make V=1
)?
@qmonnet I ran git submodule update --init --recursive to get them all in sync before trying to build, and successfully solved the problem.Thank you very much!
Glad to hear that, thanks for reporting back!
$ make BPFTOOL bpftool/bootstrap/bpftool ... libbfd: [ OFF ] ... clang-bpf-co-re: [ on ] ... llvm: [ OFF ] ... libcap: [ OFF ] CC /home/hgd/libbpf-bootstrap/examples/c/.output/bpftool/bootstrap/libbpf/staticobjs/bpf.o In file included from bpf.c:37: libbpf_internal.h:15:10: fatal error: linux/err.h: No such file or directory 15 | #include <linux/err.h> | ^
~~~~ compilation terminated. make[2]: [Makefile:134: /home/hgd/libbpf-bootstrap/examples/c/.output/bpftool/bootstrap/libbpf/staticobjs/bpf.o] Error 1 make[1]: [Makefile:52: /home/hgd/libbpf-bootstrap/examples/c/.output/bpftool/bootstrap/libbpf/libbpf.a] Error 2 make: *** [Makefile:94: /home/hgd/libbpf-bootstrap/examples/c/.output/bpftool/bootstrap/bpftool] Error 2