3 ms·
That's awesome! How have you gotten it to work with CGo though? A simple CC="zig cc" doesn't seem to work because CGo (as of 1.16) tries to use -E which zig cc
by pojntfx 5y ago
That's awesome! How have you gotten it to work with CGo though? A simple CC="zig cc" doesn't seem to work because CGo (as of 1.16) tries to use -E which zig cc doesn't seem to support ...
- kristoff_it 5y agoI wrote a blog post about using Zig with CGo, the main problem is that CGo doesn't expect the CC command to have a space in it and the workaround is to wrap the Zig invocation inside a bash script. https://dev.to/kristoff/zig-makes-go-cross-compilation-just-work-29ho https://dev.to/kristoff/zig-makes-go-cross-compilation-just-... As a related note, it seems that Go 1.17 won't have the fix as the relative patch has not been merged (see https://go-review.googlesource.com/c/go/+/276412/ https://go-review.googlesource.com/c/go/+/276412/ ). Would be awesome if somebody from the Go team saw this post and made it happen :)
- pojntfx 5y agoThanks a lot, I was trying to use it all day yesterday and just couldn't get it work. Zig and Go are a great match it seems.
- hawski 5y agoZig should work like multi call binaries (i.e. busybox) so a link to it called cc or would call the compiler.
- slimsag 5y agoYeah, my brother opened an issue similar to this earlier - there is actually a quite cool proposal for something like this here now: https://github.com/ziglang/zig/issues/8973 https://github.com/ziglang/zig/issues/8973
- motiejus 5y agoYes, it works for all cgo programs I have tried it with, including a shared library. There were a few workarounds I needed to apply, they are in "known issues" section.