Cargo-zigbuild: Compile Cargo project with Zig as linker
github.com
github.com
Normally this process is awful because it requires a bunch of very specific files to be present at build time that normally come distributed on the "target" architecture. But you're not building on the target architecture, so you don't have any of these files.
Typical solutions are a nightmare and require careful management of environment variables and finding the right versions of all these files and carefully putting them in the right place. Anything that compiles or links against C has to deal with this.
Zig makes it far, far easier to cross compile. It ships with all these files by default and will handle everything for you. It's great, and Andy Kelly put in a ton of work to get the details right. It's a simple idea ("ship with the files, of course") but it leads to lots of problems that need solving. Zig solved them, and has the ability to link C code.
Rust code often needs to link against C. Some Rust libraries explicitly call C/C++ code. Also the OS interface usually requires linking against C. So Rust programmers still have to touch the nightmare of cross-compilation, and so this benefits them in the same way it benefits C programmers.
For reference, https://kristoff.it/blog/maintain-it-with-zig/
Shows how Zig can be a powerful tool for building C and C++ codebases. Now with Cargo integration, it can help achieve clean cross builds in Rust.
> Now that there is significant work put into Mach-O linking thanks to @kubkon, Zig is more than just a linker driver for LLD. It is now a linker that competes in the linker space, and some projects may want to use Zig as a drop-in replacement for other linkers.