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

cmd/bpf2go: allow to specify native target #526

Merged
merged 1 commit into from
Dec 15, 2021

Conversation

tklauser
Copy link
Member

This allows to invoke bpf2go to build for the native architecture and
have __TARGET_ARCH_xxx defined based on GOARCH without having to
derive the architecture e.g. as part of the build system.

For example this would be useful in github.com/cilium/pwru:

//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang -target native KProbePWRU ./bpf/kprobe_pwru.c -- -DOUTPUT_SKB -I./bpf/headers

This allows to invoke `bpf2go` to build for the native architecture and
have `__TARGET_ARCH_xxx` defined based on `GOARCH` without having to
derive the  architecture e.g. as part of the build system.

For example this would be useful in github.com/cilium/pwru:

    //go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang -target native KProbePWRU ./bpf/kprobe_pwru.c -- -DOUTPUT_SKB -I./bpf/headers

Signed-off-by: Tobias Klauser <tobias@cilium.io>
@tklauser tklauser force-pushed the bpf2go-native-target branch 2 times, most recently from 4abcf4a to ab5dbf0 Compare December 15, 2021 10:13
Copy link
Collaborator

@lmb lmb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@lmb lmb merged commit 59af061 into cilium:master Dec 15, 2021
@tklauser tklauser deleted the bpf2go-native-target branch December 15, 2021 16:45
brb pushed a commit to cilium/pwru that referenced this pull request Dec 17, 2021
This allows to get the PT_REGS_* macros for the correct target
architecture, e.g. ARM64. Note, that currently the //go:generate lines
have to be specified per GOARCH in order to set __TARGET_ARCH_xxx
correctly. This can be replaced by adding `-target native` to the bpf2go
call once the private fork of cilium/ebpf has been rebased to include
cilium/ebpf#526.

Signed-off-by: Tobias Klauser <tobias@cilium.io>
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.

None yet

2 participants