Use rustup to install the target toolchain, then run cargo build with the --target flag to compile for a different architecture.
- Install the desired target toolchain using
rustup target add <target-triple>. - Compile your project for that target using
cargo build --target <target-triple>.
rustup target add wasm32-unknown-unknown
cargo build --target wasm32-unknown-unknown --release
Replace wasm32-unknown-unknown with your specific target triple (e.g., x86_64-unknown-linux-musl for Linux or aarch64-apple-darwin for Apple Silicon).