bpf2go issues with s390x arch
msherif1234 opened this issue · comments
Describe the bug
I have an application that build amd64,arm64,ppc64le and s390x arch the bpf2go generate is successful and the auto generated files are created for all arch
here is the command I used
//go:generate bpf2go -cc $BPF_CLANG -cflags $BPF_CFLAGS -target amd64,arm64,ppc64le,s390x
here is list of binaries created
ls pkg/ebpf/
bpf_bpfeb_s390.go bpf_bpfel_arm64.go bpf_bpfel_powerpc.go bpf_bpfel_x86.go
bpf_bpfeb_s390.o bpf_bpfel_arm64.o bpf_bpfel_powerpc.o bpf_bpfel_x86.o
Now when I build the userspace golang for the different arch it builds for all arch except s390x
it fails when it tries to reference the auto generate go package for s390x
### How to reproduce
The quickest way to reproduce this
- git clone https://github.com/netobserv/netobserv-ebpf-agent
- GOARCH=s390x make compile
### Debugging
when turn on go build -x -v options and compare working and none working
-arm64
EOF
cat >/tmp/go-build3473788767/b145/embedcfg << 'EOF' # internal
{
"Patterns": {
"bpf_bpfel_arm64.o": [
"bpf_bpfel_arm64.o"
]
},
"Files": {
"bpf_bpfel_arm64.o": "/home/mmahmoud/go/src/netobserv-ebpf-agent/pkg/ebpf/bpf_bpfel_arm64.o"
}
}EOF
/usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/b145/_pkg_.a -trimpath "$WORK/b145=>" -p github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf -lang=go1.20 -complete -buildid HNBc_4x3RVDmb4k0dkDf/HNBc_4x3RVDmb4k0dkDf -goversion go1.20.10 -c=4 -nolocalimports -importcfg $WORK/b145/importcfg -embedcfg $WORK/b145/embedcfg -pack ./pkg/ebpf/bpf_bpfel_arm64.go ./pkg/ebpf/tracer.go
-s390x
/usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/b147/_pkg_.a -trimpath "$WORK/b147=>" -p github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf -lang=go1.20 -complete -buildid I8IGR_iTcXeniUkIzrN6/I8IGR_iTcXeniUkIzrN6 -goversion go1.20.10 -c=4 -nolocalimports -importcfg $WORK/b147/importcfg -pack ./pkg/ebpf/tracer.go
its clear for s390x the right dependency pkg isn't there that is why it failed
### Version information
go version go1.20.10 linux/amd64
github.com/cilium/ebpf v0.12.3
Just had a brief look and want to share my findings:
linux
&s390
is not a validGOOS/GOARCH
combination. See also https://go.dev/doc/install/source#environment andGOARCH=s390 make compile
- for
s390x
bpf2go
creates files with the suffix_s390.go
but should use_s390x.go
instead
Just had a brief look and want to share my findings:
linux
&s390
is not a validGOOS/GOARCH
combination. See also https://go.dev/doc/install/source#environment andGOARCH=s390 make compile
- for
s390x
bpf2go
creates files with the suffix_s390.go
but should use_s390x.go
instead
Thanks @florianl for 2nd bullet how I can force bpf2go to generate _s390x.* I passing -target s390x ?
but ur are right I hacked the auto gen to be called s390x instead and the build work!!
is it because of https://github.com/cilium/ebpf/blob/main/cmd/bpf2go/main.go#L69 ?
/assign @lmb