PlanktoScope / forklift

Composable, reprovisionable, decentralized management of apps & configs on Raspberry Pis and other embedded Linux systems
Apache License 2.0
6 stars 0 forks source link

Try using the zig toolchain for CGo builds for macOS #219

Closed ethanjli closed 1 month ago

ethanjli commented 1 month ago

This PR attempts to simplify builds by using the Zig toolchain for CGo builds for macOS (see https://github.com/goreleaser/goreleaser-example-zig-cgo and https://zig.news/kristoff/building-sqlite-with-cgo-for-every-os-4cic).

ethanjli commented 1 month ago

The build fails with a /opt/hostedtoolcache/go/1.22.3/x64/src/net/cgo_unix_cgo_darwin.go:10:10: fatal error: 'resolv.h' file not found error (probably because I don't want to provide CoreFoudnation). I think for now it'll be simpler to just stay with the goreleaser-cross container image for builds. Also, macos builds were already pretty fast - the bottleneck seems to be with the windows builds. I think I want to disable the windows builds anyways - maybe people who need to run Forklift on Windows (if anyone like that exists) can just use WSL?

ethanjli commented 1 month ago

I was able to get cross-compilation working with Zig, but the difficulty of trying to make go/zig link the compiled object files correctly into a binary is not worth the complexity - and it's not clear that we'll have very substantial performance improvements.