【发布时间】:2021-09-09 07:55:34
【问题描述】:
我一直在比较 C 和 Rust 为 x86 和 ARM 生成的汇编代码。
我有一台 M1 Mac,我找到了如何用 Clang 交叉编译 C,但到目前为止我找不到如何交叉编译 Rust。
如何在 M1 Mac 上从 Rust 生成 x86_64 二进制文件?
【问题讨论】:
标签: macos rust x86-64 cross-compiling
我一直在比较 C 和 Rust 为 x86 和 ARM 生成的汇编代码。
我有一台 M1 Mac,我找到了如何用 Clang 交叉编译 C,但到目前为止我找不到如何交叉编译 Rust。
如何在 M1 Mac 上从 Rust 生成 x86_64 二进制文件?
【问题讨论】:
标签: macos rust x86-64 cross-compiling
内置交叉编译,使用rustup安装目标支持即可:
$ rustup target install x86_64-apple-darwin
然后像这样构建你的箱子:
$ cargo build --target x86_64-apple-darwin
感谢 Rosetta,您甚至可以像这样运行它:
$ cargo run --target x86_64-apple-darwin
【讨论】:
brew install filosottile/musl-cross/musl-cross