DelSkayn / rquickjs

High level bindings to the quickjs javascript engine
MIT License
434 stars 59 forks source link

add support for wasm32-wasi #245

Closed mmoskal closed 4 months ago

mmoskal commented 5 months ago

This makes build.rs download wasi-sys if building for wasm32-wasi target. The logic is copied from https://github.com/bytecodealliance/javy/blob/main/crates/quickjs-wasm-sys/build.rs

I was unable to get the bindgen to work - it would not output functions (it would output types and constants correctly though). In the end I copied the bindgen file from i686-msvc. It works OK.

DelSkayn commented 5 months ago

Thanks for the PR!

I have also been experimenting with adding support for wasi. I thought I managed at one point to get bindgen working, so I will do some testing with that before merging this.

dejang commented 4 months ago

Really appreciate the work done here, do you know how we could make this work for the web ? I'm really curios about that. I' m currently working on a project where I'm in need of an isolated environment that is not an iframe or worker and QuickJS fits perfectly.

DelSkayn commented 4 months ago

@dejang the problem with compiling quickjs for web wasm is that there are currently some problems with packaging c libraries which require libc. The default wasm target used by rust is wasm-unknown-unknown which doesn't have a libc available. We could instead add support for wasm-emscripten but this requires a lot of code just to pull in the sdk or check for it's availability for a platform which isn't well supported by rust tools like wasm-bindgen.

For more reference see rustwasm/team#291

dejang commented 4 months ago

Thank you @DelSkayn, that actually makes a lot of sense.