FreeBSD 32-bit build support
This PR adds support for building and running wgctrl on 32-bit FreeBSD systems.
On 32-bit FreeBSD, size_t and ulong are 32 bits under the ILP32 model, whereas on 64-bit FreeBSD they are 64 bits under LP64. The Go code was previously using uint64 (8 bytes) for WGDataIO.Size (which the C struct expects to be 4 bytes on ILP32), C.ulong to pass buffer lengths to nvlist_unpack, and C.ulong to pass numeric values to nvlist_add_number (which expects a uint64_t). These mismatches cause build failures on ILP32.
Changes
- In
client_freebsd.go, updateWGDataIO.Sizefromuint64(sz) touint32(sz). On ILP32 this writes a 32-bit size, matching the C struct. On LP64, uint32(sz) zero-extends appropriately. - In decode.go, change
sz := C.ulong(len(d))tosz := C.size_t(len(d))sonvlist_unpackalways receives exactly asize_t. - In encode.go, change
C.nvlist_add_number(nvl, ckey, C.ulong(value))toC.nvlist_add_number(nvl, ckey, C.uint64_t(value)), ensuring 64-bit numbers are passed correctly on ILP32 and LP64.
@hakansa you have a commit, go.mod: bump dependencies, adjust CI builds, that seems to have been added later on. Should this be included in this PR? What's the purpose?
@jrife
@hakansa you have a commit, go.mod: bump dependencies, adjust CI builds, that seems to have been added later on. Should this be included in this PR? What's the purpose?
it's part of master: a9ab2273dd1
likely when @hakansa committed the requested changes (e.g. https://github.com/WireGuard/wgctrl-go/pull/155#discussion_r2147418762 wgh.SizeT), rather than amending them to their existing commit or making a new commit, they were amended to an unrelated commit at the HEAD of master. cleaning this up with rebase and push --force is left as an exercise to the reader...
is there anythng that i can do the make this pr merged? We have some customers waiting for 32-bit support 👐