Stream: wit-bindgen

Topic: Swift host support


view this post on Zulip Jack Qi (Feb 08 2023 at 19:27):

Hi, I'm interested in using wit-bindgen to create libraries written in Rust that will be used by mobile hosts (iOS/Swift, Android/Kotlin), the readme suggested checking in here before diving in.

I see Java is already supported but:
1) Has there been any work on generating Swift code and using this on iOS hosts?
2) Are there any know major barriers to getting this working?
3) How far away is some kind of async function support from landing?

If not I would like to contribute Swift support if there is interest.

Thanks

view this post on Zulip Mossaka (Joe) (Feb 08 2023 at 22:09):

Hey! Thanks for asking and welcome to contribute Swift guest bindgen!

  1. I am not aware of any work on generating Swift guest code
  2. I don't think a swift host version of wasmtime exists yet.
  3. async will not land this year

view this post on Zulip Joel Dice (Feb 08 2023 at 22:17):

Also, wasmtime won't work on iOS anyway due to JIT restrictions on that platform.

view this post on Zulip Jack Qi (Feb 08 2023 at 22:30):

@Mossaka (Joe) Thanks for the quick reply. I'm looking for Swift host support, my use case is to have the guest written in rust which from what I understand is very well supported. My plan was to wrap the wasmtime C API (https://docs.wasmtime.dev/c-api/) with Swift as a first step, then work on adding Swift code generation.

view this post on Zulip Jack Qi (Feb 08 2023 at 22:31):

@Joel Dice Doesn't wasmtime support an AOT compilation mode? Would that not work on iOS?

view this post on Zulip Mossaka (Joe) (Feb 08 2023 at 22:59):

Ah that makes sense! Currently all the host generations are moved out of wit-bindgen. You might want to ask this question in the wasmtime stream!

view this post on Zulip Joel Dice (Feb 08 2023 at 23:29):

@Jack Qi Yes, you can have wasmtime AOT a .wasm file to a native .cwasm file, but the iOS restrictions mean that you can't execute native code that was previously writable, so you can't just download a .cwasm and run it. If you don't need to do that, and all your .cwasm files are bundled, read-only, as part of your app, then it might work. Worth a try, anyway!

view this post on Zulip Alex Crichton (Feb 08 2023 at 23:33):

@Jack Qi you might be interested in the wasmtime-py embedding support which is a Python wrapper for Wasmtime's C API which then additionally has a bindgen module which is a code generator to execute components in Python, essentially host support for components in Python

view this post on Zulip Jack Qi (Feb 09 2023 at 04:36):

@Mossaka (Joe) thanks for the pointer, I'll take a look at the wasmtime repo to see how host support is implemented for other host languages. :+1:

view this post on Zulip Jack Qi (Feb 09 2023 at 04:37):

@Joel Dice yes I was hoping to be able bundle the AOT compiled wasm in the app and ship that. I still have hope that Apple might eventually remove the restriction in the future.

view this post on Zulip Jack Qi (Feb 09 2023 at 04:38):

@Alex Crichton thanks I will take a look at wasmtime-py :thumbs_up:


Last updated: Nov 22 2024 at 16:03 UTC