Skip to content

Comments

bpf2go, btf: emit structs.HostLayout in GoFormatter#1769

Merged
lmb merged 1 commit intocilium:mainfrom
lmb:bpf2go-structs-hostlayout
May 7, 2025
Merged

bpf2go, btf: emit structs.HostLayout in GoFormatter#1769
lmb merged 1 commit intocilium:mainfrom
lmb:bpf2go-structs-hostlayout

Conversation

@lmb
Copy link
Contributor

@lmb lmb commented Apr 30, 2025

Types described by BTF essentially follow C rules for laying out a struct. Use the newly introduced structs.HostLayout to hint at the compiler that reordering is not permissible.

Fixes #1686

@lmb lmb force-pushed the bpf2go-structs-hostlayout branch from e0ec582 to b8e8084 Compare April 30, 2025 13:03
Copy link
Contributor

@ti-mo ti-mo left a comment

Choose a reason for hiding this comment

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

Nice! One nit, and you forgot to update the test battery in TestGoTypeDeclaration.

Types described by BTF essentially follow C rules for laying out a
struct. Use the newly introduced structs.HostLayout to hint at the
compiler that reordering is not permissible.

Fixes cilium#1686

Signed-off-by: Lorenz Bauer <[email protected]>
@lmb lmb force-pushed the bpf2go-structs-hostlayout branch from b8e8084 to 1967520 Compare May 7, 2025 09:20
@lmb lmb marked this pull request as ready for review May 7, 2025 09:38
@lmb lmb requested review from a team and dylandreimerink as code owners May 7, 2025 09:38
@lmb lmb merged commit 5c1db4f into cilium:main May 7, 2025
17 checks passed
@lmb lmb deleted the bpf2go-structs-hostlayout branch May 7, 2025 09:38
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.

bpf2go: emit structs.HostLayout into generated structs

2 participants