3 ms·
Using Zig is the easiest way to cross-compile with cgo: https://lucor.dev/post/cross-compile-golang-fyne-project-using-zig/ https://lucor.dev/post/cross-compile
by jedisct1 4y ago
Using Zig is the easiest way to cross-compile with cgo: https://lucor.dev/post/cross-compile-golang-fyne-project-using-zig/ https://lucor.dev/post/cross-compile-golang-fyne-project-usi...
- emidoots 4y agoI am in love with Zig (as you know), but feel the need to say: please be careful with blanket claims like this. purego is a pretty admirable approach to fixing cgo cross-compilation without Zig (though has its own drawbacks, like no static binary for example.) Using Zig for Go cross-compilation, although quite great, isn't bulletproof. Finding the right CC/CXX incantation can be fairly tricky, the articles on this are not super up-to-date, and you need a copy of the macOS SDK[0] if you intend to cross-compile for macOS. You may also run into a few scary linker warnings and need to figure out the right Go build flags. I definitely think Zig and Go can be best-friends, after all they share so many similar qualities and seem quite complementary to each-other. It's definitely possible to get Go<->Zig CGO cross compilation working (I did so for Sourcegraph); But Zig needs a little more love before it'll 'just work' as claimed for the Go use case, so best not to claim otherwise until then. [0] https://github.com/ziglang/zig/issues/1349 https://github.com/ziglang/zig/issues/1349