NGINX Unit - universal web app server - a lightweight and versatile open source server that simplifies the application stack by natively executing application code across eight different programming language runtimes.
Currently, the Homebrew experience for Unit with Go applications is set up for x86 and fails on arm64 machines. Typically the problems experiences are:
$ go build …
…
# unit.nginx.org/go
In file included from ../../../go/pkg/mod/unit.nginx.org/go@v0.0.0-20231004115303-cfd5bf6e4324/port.go:9:
./nxt_cgo_lib.h:14:10: fatal error: 'nxt_unit.h' file not found
#include <nxt_unit.h>
^~~~~~~~~~~~
1 error generated.
Or
# command-line-arguments
/opt/homebrew/Cellar/go/1.21.1/libexec/pkg/tool/darwin_arm64/link: running cc failed: exit status 1
ld: library 'unit' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The solution is to provide CGO_ environment variables
$ CGO_LDFLAGS="-L/opt/homebrew/include -L/opt/homebrew/lib" CGO_CFLAGS="-I/opt/homebrew/include" go build …
Currently, the Homebrew experience for Unit with Go applications is set up for x86 and fails on arm64 machines. Typically the problems experiences are:
Or
The solution is to provide CGO_ environment variables
Let's fix this for a better user experience! :)