Skip to content

Commit

Permalink
main: pass -target to bpf2go
Browse files Browse the repository at this point in the history
Use the -target flag to tell bpf2go which arch we are targeting. This
cuts down on compiling useless targets (big endian x86 anyone?)
bpf2go will automatically pass the appropriate __TARGET_ARCH_xxx.

Also use $GOARCH from as set by go generate to reduce the necessary
boilerplate.
  • Loading branch information
lmb authored and tklauser committed Jun 28, 2023
1 parent 0578811 commit 62d0dff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
11 changes: 11 additions & 0 deletions build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: GPL-2.0-only
// Copyright (C) 2021 Authors of Cilium */

//go:generate sh -c "echo Generating for $GOARCH"
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -target $GOARCH -cc clang KProbePWRU ./bpf/kprobe_pwru.c -- -DOUTPUT_SKB -I./bpf/headers -Wno-address-of-packed-member
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -target $GOARCH -cc clang KProbeMultiPWRU ./bpf/kprobe_pwru.c -- -DOUTPUT_SKB -DHAS_KPROBE_MULTI -I./bpf/headers -Wno-address-of-packed-member
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -target $GOARCH -cc clang KProbePWRUWithoutOutputSKB ./bpf/kprobe_pwru.c -- -I./bpf/headers -Wno-address-of-packed-member
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -target $GOARCH -cc clang KProbeMultiPWRUWithoutOutputSKB ./bpf/kprobe_pwru.c -- -D HAS_KPROBE_MULTI -I./bpf/headers -Wno-address-of-packed-member
//go:generate go run ./tools/getgetter.go -struct ^(KProbePWRU|KProbeMultiPWRU|KProbePWRUWithoutOutputSKB|KProbeMultiPWRUWithoutOutputSKB)(Programs|Maps)$

package main
11 changes: 0 additions & 11 deletions main_amd64.go

This file was deleted.

11 changes: 0 additions & 11 deletions main_arm64.go

This file was deleted.

0 comments on commit 62d0dff

Please sign in to comment.