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

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

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

4个回答

3

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 来构建标准库。

3
"

x86_64-apple-ios-macabi目标在夜间版(5c5b8afd8 2019-11-16)编译器上可用。仅因为目标可用,并不意味着标准库和相关组件已经编译或可以通过rustup使用:

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

Rust有一个分层系统(这是一项提议的RFC的主题)。这个目标是如此新,甚至没有列在分层列表上,但它无疑将成为第3层。第2.5层说(重点是我的):

第2.5层平台可以被视为“保证构建”,但没有通过rustup提供的构建

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

build-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

1
请注意,您不再需要使用 xargo。新的 -Z build-std 已经足够让普通的 cargo 访问任何未预构建的目标:cargo +nightly build -Z build-std --target x86_64-apple-ios-macabi - dcow

1

@shepmaster 's answer 是正确的。具体来说,您需要:

  • 安装Xargo:
cargo install xargo
  • 进入您的项目

  • 使用夜间版本构建:

(保留HTML格式)
rustup override set nightly

创建包含以下内容的 Xargo.toml 文件:
[target.x86_64-apple-ios-macabi.dependencies.std]

在您的项目Cargo.toml中,请确保[profile.release]部分包含panic = "abort"。如果没有,请添加它。 构建项目时,请使用xargo而不是cargo

0
如果您安装了旧版本的 Rust,可能需要删除旧版的 Nightly(对我来说,至少无法更新 Nightly):
rustup toolchain remove nightly
rustup update
rustup toolchain install nightly

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接