I've been comparing the assembly code generated by C and Rust for x86 and ARM.
I have an M1 Mac and I found how to cross-compile C with Clang, but so far I can't find how to cross-compile Rust.
How can I generate an x86_64 binary from Rust on an M1 Mac?
Cross-compilation is built in, just use rustup
to install the target support:
$ rustup target install x86_64-apple-darwin
and build your crate like this:
$ cargo build --target x86_64-apple-darwin
Thanks to Rosetta you can even run it like this:
$ cargo run --target x86_64-apple-darwin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With