I am trying to packagize pwru for Debian and it uses a generate stage to
build some eBPF filters by compiling them into an object and embedding
them into Go. The upstream owner provides a Makefile to handle the whole
build, but I am trying to break it up and use dh-golang with it's
built-in support for go generate. However, I am getting some kind of
strange build failure I can't understand. When adding this to d/rules:
export DH_GOLANG_GO_GENERATE := 1
During the build, it fails with this output:
dh_auto_build -O--builddirectory=_build -O--buildsystem=golang
cd _build && go generate -v github.com/cilium/pwru
github.com/cilium/pwru/internal/byteorder
github.com/cilium/pwru/internal/libpcap
github.com/cilium/pwru/internal/pwru
src/github.com/cilium/pwru/build.go
Generating for amd64
Compiled /srv/build/pwru/clean/pwru/_build/src/github.com/cilium/pwru/kprobepwru_bpfel_x86.o
Error: can't write /srv/build/pwru/clean/pwru/_build/src/github.com/cilium/pwru/kprobepwru_bpfel_x86.go:
can't load BPF from ELF: load data sections: data section .bss: can't get contents: unexpected read from SHT_NOBITS section
exit status 1
src/github.com/cilium/pwru/build.go:5: running "go": exit
status 1
However, if I run that generate command exactly as show above, it builds
correctly:
go generate -v github.com/cilium/pwru \
github.com/cilium/pwru/internal/byteorder \
github.com/cilium/pwru/internal/libpcap \
github.com/cilium/pwru/internal/pwru \
src/github.com/cilium/pwru/build.go
build.go
Generating for amd64
Compiled /srv/build/pwru/clean/pwru/kprobepwru_bpfel_x86.o
Wrote /srv/build/pwru/clean/pwru/kprobepwru_bpfel_x86.go
Compiled /srv/build/pwru/clean/pwru/kprobemultipwru_bpfel_x86.o
Wrote /srv/build/pwru/clean/pwru/kprobemultipwru_bpfel_x86.go
Compiled
/srv/build/pwru/clean/pwru/kprobepwruwithoutoutputskb_bpfel_x86.o
Wrote /srv/build/pwru/clean/pwru/kprobepwruwithoutoutputskb_bpfel_x86.go
Compiled
/srv/build/pwru/clean/pwru/kprobemultipwruwithoutoutputskb_bpfel_x86.o
Wrote
/srv/build/pwru/clean/pwru/kprobemultipwruwithoutoutputskb_bpfel_x86.go
kprobemultipwru_bpfel_x86.go
kprobemultipwruwithoutoutputskb_bpfel_x86.go
kprobepwru_bpfel_x86.go
kprobepwruwithoutoutputskb_bpfel_x86.go
...
What would be different about the two different invocations? In the
first scenario, it doesn't even save an output object file for me to
look at. This is from the module github.com/cilium/pwru and it's using
the module github.com/cilium/ebpf/cmd/bpf2go to compile the eBPF into
embedding in a Golang source file.
The generate lines look like this:
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -target
$TARGET_GOARCH -cc clang -no-strip KProbePWRU ./bpf/kprobe_pwru.c --
-DOUTPUT_SKB -I./bpf/headers -Wno-address-of-packed-member
Any ideas what to debug next?
--
Loren M. Lang
lorenl@north-winds.org
http://www.north-winds.org/
Public Key: http://www.north-winds.org/lorenl_pubkey.asc
Fingerprint: 7896 E099 9FC7 9F6C E0ED E103 222D F356 A57A 98FA
Attachment:
signature.asc
Description: PGP signature