3 ms·
Cross-compilation is when you compile code on one machine meant to run on another machine with a different operating system or CPU architecture. Normally this
by vlmutolo 5y ago
Cross-compilation is when you compile code on one machine meant to run on another machine with a different operating system or CPU architecture.
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.