Skip to content

If I wish to avoid committing generated BPF object files, am I out of luck? #988

Answered by mejedi
mejedi asked this question in Q&A
Discussion options

You must be logged in to vote

I wonder if the alternative model with bpf object files being generated on the fly is supported. Can I find an example somewhere?

I have figured the bits and pieces. Please let me know if the setup below can be improved.

.gitignore
Makefile
cmd/test/bpf/xdp.c
cmd/test/main.go
go.mod
go.sum

This is a simple eBPF-enabled tool to play with the setup (./cmd/test). I don't want to ever commit generated files, therefore there are a bunch of lines in .gitignore:

*_bpfe[lb].o
*_bpfe[lb].go
*_bpfe[lb].go.d

As go build won't invoke bpf2go on its own, I have a wrapper Makefile.

build: cmd/test/dp_bpfel.go
	go build -tags bpf ./cmd/test

cmd/test/dp_bpfel.go:
	BPF2GO_MAKEBASE=${CURDIR} go generat…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@ti-mo
Comment options

Comment options

You must be logged in to vote
2 replies
@ti-mo
Comment options

@mejedi
Comment options

Answer selected by mejedi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants