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: enable ebpf code reuse across go packages #1625

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mejedi
Copy link
Contributor

@mejedi mejedi commented Dec 12, 2024

New -import command line option specifies golang packages to pull headers from. 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.

frob.c:
#include "example.org/foo/foo.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.

"Build" dependencies are recorded in generated files so that "go mod tidy" can see them. Further, we don't check if -import refers to internal packages, but "go build" will.

New -import command line option specifies golang packages to pull
headers from. 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.

frob.c:
  #include "example.org/foo/foo.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.

"Build" dependencies are recorded in generated files so that "go mod
tidy" can see them. Further, we don't check if -import refers to
internal packages, but "go build" will.

Signed-off-by: Nick Zavaritsky <[email protected]>
@mejedi
Copy link
Contributor Author

mejedi commented Dec 12, 2024

Change to listing packages explicitly on command line with -import option.

Prior iteration (#1509) pulled them from the "magic" bpf2go.hfiles.go in the output directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant