4

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?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
shallowThought
  • 19,212
  • 9
  • 65
  • 112

4 Answers4

3

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:

build-std

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

Xargo

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
Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
  • 1
    Note you no longer need `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`. – dcow Aug 24 '21 at 03:07
1

@shepmaster 's answer is correct. In detail, you have to:

  • Install Xargo:
cargo install xargo
  • cd in your project

  • use the nighly build:

rustup override set nightly
  • create the 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 xargoinstead of cargo.

shallowThought
  • 19,212
  • 9
  • 65
  • 112
1

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.

dcow
  • 7,765
  • 3
  • 45
  • 65
0

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
hohteri
  • 174
  • 1
  • 5