Closed bfengj closed 10 months ago
bpf2go
will pass the necessary target flags and defines to clang, do not add them to the cflags manually.
Try this:
go run github.com/cilium/ebpf/cmd/bpf2go -cc clang-12 -target arm64 -cflags "-g -O2 -Wall" ...
thanks!Looking at my code again after so many days i find that actually it's not the bug of clang,it's because of my code.But still thanks for the reply!!!
Describe the bug
According to the error message "The eBPF is using target specific macros, please provide -target that is not bpf, bpfel or bpfeb", clang shouldn't set -target to bpf, bpfel and bpfeb during compilation, so I need to specify the -target myself, but with clang version >= 12, it still specifies a -target bpfel by itself, resulting in an error According to the message above:"Program arguments: clang-12 -O2 -mcpu=v1 -g -O2 -Wall -target arm64 -D TARGET_ARCH_arm64 -DTARGET_ARCH_arm64 -target bpfel "
When i use clang-11, i will not happen:
I don't know if this is a clang bug or a bpf2go bug,so i report it.
ebpf code is :
this is my linux:
Version information
github.com/cilium/ebpf v0.12.3