Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpf2go issues with s390x arch #1307

Closed
msherif1234 opened this issue Jan 15, 2024 · 4 comments · Fixed by #1312
Closed

bpf2go issues with s390x arch #1307

msherif1234 opened this issue Jan 15, 2024 · 4 comments · Fixed by #1312
Labels
bug Something isn't working

Comments

@msherif1234
Copy link

msherif1234 commented Jan 15, 2024

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
@msherif1234 msherif1234 added the bug Something isn't working label Jan 15, 2024
@florianl
Copy link
Contributor

Just had a brief look and want to share my findings:

  • linux & s390 is not a valid GOOS/GOARCH combination. See also https://go.dev/doc/install/source#environment and GOARCH=s390 make compile
  • for s390x bpf2go creates files with the suffix _s390.go but should use _s390x.go instead

@msherif1234
Copy link
Author

msherif1234 commented Jan 15, 2024

Just had a brief look and want to share my findings:

  • linux & s390 is not a valid GOOS/GOARCH combination. See also https://go.dev/doc/install/source#environment and GOARCH=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!!

@msherif1234
Copy link
Author

@msherif1234
Copy link
Author

/assign @lmb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants