https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109068
Bug ID: 109068 Summary: bpf: "error: too many function arguments for eBPF" for always_inline function Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: david.faust at oracle dot com CC: cupertino.miranda at oracle dot com, jemarch at gcc dot gnu.org Target Milestone: --- Target: bpf BPF calling convention does not support function calls with more than 5 arguments. But if the function is inlined this restriction should be relaxed. Many convenience macros for BPF in the kernel make use of always_inline functions, and the expansion of the macro uses can result in an always_inline function with >5 args. There are several examples of this in the BPF selftests, so GCC fails to compile those tests. e.g. on bpf-next: linux/tools/testing/selftests/bpf/progs/bpf_syscall_macro.c and corresponding BPF_KSYSCALL macro def in linux/tools/testing/selftests/bpf/tools/include/bpf/bpf_tracing.h duplicated from linux/tools/lib/bpf/bpf_tracing.h clang compiles these tests without issue. We should fix the BPF backend check for function arguments to allow calls to inline functions with >5 args. $ cat args.c inline __attribute__((always_inline)) int foo (int a, int b, int c, int d, int e, int f) { return a + b + c + d + e + f; } int bar (int x) { return foo (x, x*2, x*3, x*4, x*5, x*6); } $ bpf-unknown-none-gcc -c args.c -o args.o args.c: In function ‘foo’: args.c:2:5: error: too many function arguments for eBPF 2 | int foo (int a, int b, int c, int d, int e, int f) | ^~~