如何为Mac Catalyst/x86_64-apple-ios-macabi构建



rustup target list --toolchain nightly的输出不包含x86_64-apple-ios-macabi,即使它在Rust主分支的src/librustc_target中。

如何为Mac Catalyst/x86_64-apple-ios-macabi构建?

x86_64-apple-ios-macabi目标在夜间(5c5b8afd8 2019-11-16(编译器上可用。仅仅因为目标可用并不意味着标准库和朋友已经编译或可以进行rustup:

% rustc +nightly --print target-list | grep macabi
x86_64-apple-ios-macabi

Rust有一个分层系统(这是提议的RFC的主题(。这个目标是如此之新,甚至没有被列入第三层名单,但毫无疑问,它将成为第三层。Tier 2.5表示(重点矿(:

Tier 2.5平台可以被认为是";保证建造";,但是没有通过rustup可用的构建

同时,您需要从源代码构建自己的libcore/libstd。我没有时间也没有能力真正测试编译是否有效,但像这样的选择是一般的开始路径:

构建std

不稳定的-Z build-std标志可用于构建标准库:

% cargo +nightly build -Z build-std --target x86_64-apple-ios-macabi

Xargo

可以使用xargo工具来构建标准库。

% rustup override set nightly
info: using existing install for 'nightly-x86_64-apple-darwin'
info: override toolchain for '/private/tmp/example' set to 'nightly-x86_64-apple-darwin'
nightly-x86_64-apple-darwin unchanged - rustc 1.41.0-nightly (5c5b8afd8 2019-11-16)
% cat > Xargo.toml
[target.x86_64-apple-ios-macabi.dependencies.std]
# features = ["jemalloc"] # Whatever is appropriate
% xargo build --target x86_64-apple-ios-macabi
# Iterate until libcore and libstd compile and work for your platform

@shepmaster的答案是正确的。详细地说,你必须:

  • 安装Xargo:
cargo install xargo
  • cd在您的项目中

  • 使用nighly版本:

rustup override set nightly
  • 创建包含以下内容的Xargo.toml文件:
[target.x86_64-apple-ios-macabi.dependencies.std]
  • 在您的项目Cargo.toml中,确保[profile.release]部分包含panic = "abort"。如果没有,请添加。

  • 构建项目时,请使用xargo而不是cargo

Shepmaster的答案有点过时了。Cargo现在支持-Zbuild-std命令。使用它,您可以瞄准rustc本身支持的任何目标,即使它们没有列在rustup +nightly target list上。简单地说:
rustc +nightly --print target-list

cargo +nightly build -Z build-std --target x86_64-apple-ios-macabi

现在应该足够了。您不再需要xargo来构建标准库。

如果你有一个旧的rust安装,你可能需要每晚删除旧的(或者至少对我来说,它无法每晚更新(:

rustup toolchain remove nightly
rustup update
rustup toolchain install nightly

最新更新