Skip to content

Commit

Permalink
fix(build): fix build on FreeBSD (#1639)
Browse files Browse the repository at this point in the history
## Checklist

- [x] I have read the [contribution
guidelines](https://github.com/ooni/probe-cli/blob/master/CONTRIBUTING.md)
- [x] reference issue for this pull request:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270020
- [ ] if you changed anything related to how experiments work and you
need to reflect these changes in the ooni/spec repository, please link
to the related ooni/spec pull request: <!-- add URL here -->
- [ ] if you changed code inside an experiment, make sure you bump its
version number

<!-- Reminder: Location of the issue tracker:
https://github.com/ooni/probe -->

## Description

The build of ooni-probe currently fails on FreeBSD because the compiler
cannot find some required symbols (C.SOCK_STREAM, C.AF_INET, C.AF_INET6
and C.AF_UNSPEC). This causes the package
[net/ooni-probe-cli](https://www.freshports.org/net/ooni-probe-cli/) to
be unavailable.

Fix this by including sys/socket.h when building on FreeBSD.

See also these FreeBSD bug reports (the second report also applies to Go
1.21 and Go 1.22):

- [270020: net/ooni-probe-cli: update 3.21.1 → 3.22.0, fix
build](https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270020)
- [272643: lang/go120: Build of one port fails with could not determine
kind of name for C.AF_INET,
etc](https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272643)

I took a bit of a shortcut for the fix in the first URL by omitting the
#ifdef as that patch would only exist in the FreeBSD port anyway. Both
URLs also discuss if this is a problem in OONI or Go itself.

---------

Co-authored-by: René Ladan <rene0+ooni@freedom.nl>
  • Loading branch information
rene0 and René Ladan authored Jan 15, 2025
1 parent 3bc4d0b commit ef139c5
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions internal/netxlite/getaddrinfo_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package netxlite
#ifndef _WIN32
#include <netdb.h> // for getaddrinfo
#include <sys/socket.h> // for C.SOCK_STREAM and C.AF_*
#else
#include <ws2tcpip.h> // for getaddrinfo
#endif
Expand Down

0 comments on commit ef139c5

Please sign in to comment.