我一直在比较 C 和 Rust 为 x86 和 ARM 生成的汇编代码。
我有一台 M1 Mac,我找到了如何用 Clang 交叉编译 C,但到目前为止我找不到如何交叉编译 Rust。
如何在 M1 Mac 上从 Rust 生成 x86_64 二进制文件?
最佳答案
内置交叉编译,直接使用rustup
安装目标支持:
$ rustup target install x86_64-apple-darwin
并像这样构建您的 crate :$ cargo build --target x86_64-apple-darwin
感谢 Rosetta,你甚至可以像这样运行它:$ cargo run --target x86_64-apple-darwin
关于macos - 如何在 ARM M1 Apple Silicon Mac 上将 Rust 代码交叉编译为 Intel 程序集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68139162/