ebpf icon indicating copy to clipboard operation
ebpf copied to clipboard

bpf2go: enable ebpf code reuse across go packages (WIP)

Open mejedi opened this issue 7 months ago • 0 comments

Extract imports from "bpf2go.hfiles.go" in the output dir, scan packages for header files, and expose headers to clang. C code consumes headers by providing a go package path in include directive, e.g.

bpf2go.hfiles.go:
  package younameit
  import (
    _ "github.com/cilium/ebpf/foo"
  )

frob.c:
  #include "github.com/cilium/ebpf/foo/bar.h"

It is handy for sharing code between multiple ebpf blobs within a project. Even better, it enables sharing ebpf code between multiple projects using go modules as delivery vehicle.

By listing build dependencies in a .go file, we ensure that they are properly reflected in go.mod.

mejedi avatar Jul 10 '24 09:07 mejedi