Zig extends that excellent support to its embedded LLVM C compiler - it’s probably the easiest way to cross compile C across operating system boundaries these days.
Nim doesn't seem to have excellent cross compiling support out of the box. It simply relies on cross platform toolchains that you have to set up.
Good luck setting up cross platform GCC.
Zig uses musl AFAIK? That can often be problematic.
https://ziglang.org/download/0.7.0/release-notes.html
But yeah, I think musl is the main target, and it ships with the source for it
I don't think it uses glibc to compile Linux binaries on macOS or macOS libc to compile macOS binaries on Linux.
macOS handles libc a little differently from Linux; whereas the Linux kernel publishes its syscall API, and allows programs to make syscalls however they want (e.g. with glibc or musl, or with go, which does syscalls itself), macOS's syscall API is subject to change at any time, and the only (supported) way to make syscalls is to dynamically link to the system libc.
https://andrewkelley.me/post/zig-cc-powerful-drop-in-replace...
Getting an .o out from a cross compiler is easy, in my experience - the big problem is getting libraries, includes and linkage right. And in my (admittedly small) experience, Nim makes that part much simpler as soon as you have a compiler set up (which in my case was an apt-get away)
Not so nice on Windows or macOS.
While Go supports it all out of the box.
Not so with Nim.
To compile to linux it needs to have a linker installed. For windows it has an internal linker, so probably does not even need that
(Not to mention the golang folks' need to reinvent the wheel has caused a few high-profile bugs that have needlessly wasted people's time.)
Regardless, this quickly falls apart whenever you have an app that does any kind of FFI to system libraries, or even third-party libraries that the author didn't want to reimplement in golang.
Windows makes cross compiling work by shipping the libs for each of the architectures in the SDK. I think that's quite reasonable for macOS since Apple controls the SDK, but it's always seemed to be a mess on Linux.
Disclaimer: I work at Microsoft on Windows but I have tried cross compiling code on both Windows and Linux in the past and I've always found it painful on Linux.