aws/aws-ebpf-sdk-go

Compilation error due to call undeclared functions

shun159 opened this issue · 0 comments

In BPF programs, when using functions like memset() and memcpy(), you should use LLVM built-in functions like __builtin_memset().

$ doas make unit-test              
bpftool btf dump file /sys/kernel/btf/vmlinux format c > /home/shun159/play/openflow/aws-ebpf-sdk-go/test-data/vmlinux.h
clang -I../../.. -g -O2 -Wall -fpie -target bpf -DCORE -D__BPF_TRACING__ -march=bpf -D__TARGET_ARCH_x86 -c test-data/tc.ingress.bpf.c -o test-data/tc.ingress.bpf.elf
clang-16: warning: argument unused during compilation: '-march=bpf' [-Wunused-command-line-argument]
test-data/tc.ingress.bpf.c:100:4: error: call to undeclared library function 'memset' with type 'void *(void *, int, unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        memset(&flow_key, 0, sizeof(flow_key));
        ^
test-data/tc.ingress.bpf.c:100:4: note: include the header <string.h> or explicitly provide a declaration for 'memset'
test-data/tc.ingress.bpf.c:122:31: warning: declaration of 'struct sched_process_fork_t' will not be visible outside of this function [-Wvisibility]
int sched_process_fork(struct sched_process_fork_t *ctx) {