News for hackers. Stuff that matters.
Re:Zig Makes Rust Cross-Compilation Just Work by pornel on Monday May 24, 2021 @05:48AM (#27262553)
Rust depends on the operating system already having a cross-linker and sysroot for the target platform. You probably have them already installed.

On a "clean" OS, you get:

• Panics from sys crates using the pkg_config crate, because the target sysroot is missing. It can auto-detect available sysroot on some Linux platforms, but on others you need to fiddle with env vars.

• Screen full of linker errors, because the linker for the host OS doesn't know what to do with the target OS's object files. It's less terrible if you enable a semi-secret option for bundled lld, but it's too buggy to use on some platforms.

Cross-compilation from one Linux flavor to another Linux flavor is reasonably easy with some distros. But anything more adventurous like Mac -> Linux just falls apart and you need to spend a whole day copy-pasting configs and installing bitrotting 3rd party Homebrew formulas from random people on the Internet.

Rust's tooling is usually excellent, but cross-compilation feels half-finished. The Rust's own side of it is fine (cross-compiles object files like a champ, has cross-libstd), but anything not written by the Rust project is left as "not our problem".

There are no comments on this comment yet.