macos - 如何在 ARM M1 Apple Silicon Mac 上将 Rust 代码交叉编译为 Intel 程序集?

标签 macos rust x86-64 cross-compiling

我一直在比较 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/

相关文章:

node.js - 为 node.js 构建 libxmljs 时出错

OS X 上的 Python : Getting local date time patterns

rust - Rust 中的 PhantomData 类型用法

regex - 从字符串中删除所有空格

rust - impl block 不需要泛型参数的生命周期限制

xcode - 如何公证在 XCode 之外创建的 MacOS 命令行工具?

macos - 在 golang 中使用 exec.Command,如何打开一个新终端并执行命令?

linux - 确定在 GNU/Linux 中启动程序所需的时间?

assembly - 在汇编代码中查找循环或数字

linux - 程序集 - 内联 asm - 从一个数组复制到另一个数组?