Search code examples
rustmac-catalystrustup

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?


Solution

  • 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