nginx / unit

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.
https://unit.nginx.org
Apache License 2.0
5.37k stars 323 forks source link

[Homebrew/Golang] Default paths for Apple Silicon #967

Closed lcrilly closed 10 months ago

lcrilly commented 1 year ago

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 …

Let's fix this for a better user experience! :)