The output of rustup target list --toolchain nightly
does not contain x86_64-apple-ios-macabi
, even though it is in src/librustc_target
on the Rust master branch.
How do I build for Mac Catalyst / x86_64-apple-ios-macabi
?
The output of rustup target list --toolchain nightly
does not contain x86_64-apple-ios-macabi
, even though it is in src/librustc_target
on the Rust master branch.
How do I build for Mac Catalyst / x86_64-apple-ios-macabi
?
The x86_64-apple-ios-macabi
target is available on the nightly (5c5b8afd8 2019-11-16) compiler. Just because a target is available does not mean that the standard library and friends are compiled or available to rustup:
% rustc +nightly --print target-list | grep macabi
x86_64-apple-ios-macabi
Rust has a tier system (which is the subject of a proposed RFC). This target is so new it's not even listed on the tier list, but it's undoubtedly going to be tier 3. Tier 2.5 says (emphasis mine):
Tier 2.5 platforms can be thought of as "guaranteed to build", but without builds available through rustup
In the meantime, you will need to build your own libcore / libstd from source. I don't have the time nor ability to actually test that the compilation works, but something like these choices are the general starting path:
The unstable -Z build-std
flag can be used to build the standard library:
% cargo +nightly build -Z build-std --target x86_64-apple-ios-macabi
Building the standard library can be done using the xargo tool.
% 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
xargo
. The new new-ish -Z build-std
is enough for normal cargo
to access any of the targets that aren't pre-built: cargo +nightly build -Z build-std --target x86_64-apple-ios-macabi
.
@shepmaster 's answer is correct. In detail, you have to:
cargo install xargo
cd in your project
use the nighly build:
rustup override set nightly
Xargo.toml
file with content:[target.x86_64-apple-ios-macabi.dependencies.std]
In your projects Cargo.toml, make sure the [profile.release]
section contains panic = "abort"
. If it does not, add it.
When building the project, use xargo
instead of cargo
.
Shepmaster's answer is a little outdated. Cargo now supports the -Zbuild-std
command. Using it, you can target any of the targets that rustc
itself supports even if they aren't listed on rustup +nightly target list
. Simply:
rustc +nightly --print target-list
and
cargo +nightly build -Z build-std --target x86_64-apple-ios-macabi
should be enough now. You don't need xargo
to build the standard lib anymore.
If you have an old installation of rust, you might need to remove old nightly (or at least for me it fails to update nightly):
rustup toolchain remove nightly
rustup update
rustup toolchain install nightly