Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Catalyst #31

Open
eyeplum opened this issue Jul 8, 2019 · 9 comments
Open

Add support for Catalyst #31

eyeplum opened this issue Jul 8, 2019 · 9 comments

Comments

@eyeplum
Copy link

eyeplum commented Jul 8, 2019

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

@terhechte
Copy link

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:

rust-lang/rust#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!

@eyeplum
Copy link
Author

eyeplum commented Sep 6, 2019

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.

@eyeplum
Copy link
Author

eyeplum commented Sep 9, 2019

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 :)

@terhechte
Copy link

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 :)

@imWildCat
Copy link

imWildCat commented Jun 4, 2020

Any update on this issue?

I saw rust-lang/rust#63467 has been merged a long time ago.

@terhechte
Copy link

@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.

@imWildCat
Copy link

@terhechte Thank you so much for your reply! It helps me a lot!

@Crash22191
Copy link

Are you planning to add catalyst support ? rust-catalyst-example was updated and doesn't seem to be working anymore

@terhechte
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants