4 ms·
Bringing NetBSD to Zig's Continuous Integration
- motiejus 5y agoZig cross-compiler toolchain is fantastic: weighs ~40MB, includes clang-12, musl, glibc (v2.2-2.33, selectable). I wrote a bazel toolchain on top of it, will blog about it sometime soon: https://sr.ht/~motiejus/bazel-zig-cc/ https://sr.ht/~motiejus/bazel-zig-cc/ This gives me a hermetic C/C++ compiler for my cgo programs.
- pojntfx 5y agoThat'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.
- txdv 5y agoDoes this also support compiling zig? I wanted to have zig in bazel
- motiejus 5y agoNo, and I don't have plans to add it, though a contribution would be welcome. It's a matter of writing a rule. Best follow Jay Conrod's "awesome bazel", IMO that gives enough in terms of documentation to make it happen.