bpftune
bpftune copied to clipboard
Fails to build on various architectures
Hi,
looking at the failed builds from https://buildd.debian.org/status/package.php?p=bpftune&suite=sid
lead me to bpftune.bpf.h and
#if defined(__TARGET_ARCH_x86)
#include <bpftune/vmlinux_x86_64.h>
#elif defined(__TARGET_ARCH_arm64)
#include <bpftune/vmlinux_aarch64.h>
#endif
vmlinux_x86_64.h kind of looks like a fork of /usr/include/x86_64-linux-gnu/linux/bpf/vmlinux.h - any reason why not use the packaged version? if so, any plans to fix the build for other architectures?
Thanks,
Bernd
that's great that there is a packaged version - some distros don't have it hence we carry our own - so I'll look at using it where available.
We need to fix that build failures though, or decide it will never be fixed, then we need to limit the architectures it will build on. Debian freeze is not too far ☺️
I'm hopeful #158 will help for x86_64, aarch64 at least. it looks for the local vmlinux.h first and uses it if available. it's merged into main and i've tested with a local vmlinux.h in the right place and seems to work. would be great to see if it helps debian builds for the currently-supported architectures and if so we can look at expanding support for other arches too. thanks!
It builds on amd64, arm64, i386 and x32 now. https://buildd.debian.org/status/logs.php?pkg=bpftune
Look like an
#include <linux/types.h>
is missing? I'm not sure why/where the difference to the more common architectures is. I can go and see if I can figure something out if you don't have a spontaneous idea
clang -g -fno-stack-protector -Wall -Wno-incompatible-pointer-types-discards-qualifiers -D__TARGET_ARCH_arm -O2 -target bpf \
-I../include -I/usr/include -I/usr/local/include -I/usr/include/libnl3 -I../include/uapi -c tcp_buffer_tuner.bpf.c -o tcp_buffer_tuner.bpf.o
In file included from tcp_buffer_tuner.bpf.c:20:
In file included from ../include/bpftune/bpftune.bpf.h:46:
In file included from /usr/include/bpf/bpf_helpers.h:11:
/usr/include/bpf/bpf_helper_defs.h:86:90: error: unknown type name '__u64'
86 | static long (* const bpf_map_update_elem)(void *map, const void *key, const void *value, __u64 flags) = (void *) 2;
| ^
/usr/include/bpf/bpf_helper_defs.h:110:49: error: unknown type name '__u32'
110 | static long (* const bpf_probe_read)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 4;
| ^
/usr/include/bpf/bpf_helper_defs.h:122:14: error: function cannot return function type 'int (void)'
122 | static __u64 (* const bpf_ktime_get_ns)(void) = (void *) 5;
| ^
/usr/include/bpf/bpf_helper_defs.h:122:8: error: illegal initializer (only variables can be initialized)
122 | static __u64 (* const bpf_ktime_get_ns)(void) = (void *) 5;
| ^
/usr/include/bpf/bpf_helper_defs.h:185:57: error: unknown type name '__u32'
185 | static long (* const bpf_trace_printk)(const char *fmt, __u32 fmt_size, ...) = (void *) 6;
| ^
/usr/include/bpf/bpf_helper_defs.h:201:14: error: function cannot return function type 'int (void)'
201 | static __u32 (* const bpf_get_prandom_u32)(void) = (void *) 7;
| ^
/usr/include/bpf/bpf_helper_defs.h:201:8: error: illegal initializer (only variables can be initialized)
201 | static __u32 (* const bpf_get_prandom_u32)(void) = (void *) 7;
| ^
/usr/include/bpf/bpf_helper_defs.h:214:29: error: function cannot return function type 'int (void)'
214 | static __bpf_fastcall __u32 (* const bpf_get_smp_processor_id)(void) = (void *) 8;
| ^
/usr/include/bpf/bpf_helper_defs.h:214:23: error: illegal initializer (only variables can be initialized)
214 | static __bpf_fastcall __u32 (* const bpf_get_smp_processor_id)(void) = (void *) 8;
| ^
/usr/include/bpf/bpf_helper_defs.h:235:66: error: unknown type name '__u32'
235 | static long (* const bpf_skb_store_bytes)(struct __sk_buff *skb, __u32 offset, const void *from, __u32 len, __u64 flags) = (void *) 9;
I suspect the problem is vmlinux.h include is failing. it'd be interesting to see if the less common architectures do in fact have a vmlinux.h at /usr/include/$(ARCH)-linux-gnu/linux/bpf/ ; if so, there's something wrong with the Makefile as it should pick that up. If not we may need to pre-package some vmlinux.h s or fallback to using bpftool to generate one. the problem with the latter solution is that in the rpmbuild context it cannot see /sys/kernel/btf/vmlinux which is used to do that generation.