Open eyeplum opened 5 years ago
This is a bit more involved. Catalyst adds a new target to LLVM (a so called target tripple). So adding support to lipo
also requires support from the rust compiler for this new target. I recently opened a PR for this into the Rust compiler and it was already merged:
https://github.com/rust-lang/rust/pull/63467
This is not part of the default toolchains, however. So if you're interested in this, you have to build rustc from master yourself in order to have a working toolchain with this triple. Then, you can try it out via normal cargo:
cargo build --target x86_64-apple-ios-macabi
I'm not entirely sure if this really works correctly though. I'd love help. So if you're interested, feel free to give it a try and see if it works for you!
Thanks @terhechte! That looks promising, I will try to compile a toolchain for the triple and see if I can build a binary for x86_64-apple-ios-macabi
.
I've tried to build a toolchain for x86_64-apple-ios-macabi
, and linked it to rustup.
./x.py build --target=x86_64-apple-ios-macabi
rustup toolchain link mytoolchain build/x86_64-apple-darwin/stage2/
Then I tried to build and test a bare-bone crate:
cargo +mytoolchain build --target x86_64-apple-ios-macabi
succeeded without error.cargo +mytoolchain test --target x86_64-apple-ios-macabi
failed with a few error[E0463]: can't find crate for 'std'
.I feel like somehow mytoolchain
didn't include libstd
(at least not for x86_64-apple-ios-macabi
)? However there seems to be a few files with names like libstd-04c8f9b7a9a8c33a.dylib
or libstd-89019129fe48e132.rlib
in the toolchain's directory.
Appreciate any help :)
Appreciate any help :)
@eyeplum Hey! Sorry for the late reply, but I finally had some time to look into it again. Forgot to reply here. I figured out how to do it and created a small sample project here:
https://github.com/terhechte/rust-catalyst-example
Ping me if you have any questions :)
Any update on this issue?
I saw https://github.com/rust-lang/rust/pull/63467 has been merged a long time ago.
@imWildCat I'm currently using the approach outlined in rust-catalyst-example
in almost-production (~1000 beta testers). I did not figure out a way to make this work with the default rust compiler because I found it tricky to build the standard library for a different platform. However, I also didn't invest a lot of time there. I think if you can get the standard library to build, building a custom Catalyst Rust toolchain should be easy. You can also tell Cargo to load a custom toolchain in addition to stable and nightly. I'd also be happy if somebody figures out how to do that and documents it. The current documentation for how to do this didn't work for me. I'm still stuck at the point outlined in the PR:
Supposedly I need to compile everything into a toolchain somehow that I can then test via rustup to make sure that a binary compiled against the toolchain also works with Catalyst. I read this article, but I'm still lost and would love pointers what to do next here.
@terhechte Thank you so much for your reply! It helps me a lot!
Are you planning to add catalyst support ?rust-catalyst-example
was updated and doesn't seem to be working anymore
@Crash22191 rust-catalyst-example
should still work. In fact, it should be easier. If you're not targeting Apple Silicon, then it should work out of the box with Rust nightly. If you want to support Apple Silicon, you need (for the time being) a custom Rust toolchain, until this is merged.
Any plans for adding support for Catalyst (i.e. UIKitForMac)?
It seems that UIKitForMac is not the same as x86_64, for example, it may require some extra flags to be passed when built.
This thread might provide some useful info: https://forums.developer.apple.com/thread/117229