Use the cross tool to compile Rust code for different target platforms without needing to install toolchains for each one locally. Install cross via cargo install cross, then run cross build --target <target-triple> to compile your project for the specified architecture.
cargo install cross
cross build --target x86_64-unknown-linux-musl --release
This command builds a statically linked binary for Linux using the musl libc, which can run on most Linux distributions without requiring specific system libraries.