asomers/blosc-rs

WASM support

clbarnes opened this issue · 4 comments

By linking a C library, it's obviously harder to get blosc-rs to run in a browser. However, c-blosc itself can be compiled to WASM (see Blosc/c-blosc#238 (comment) and https://github.com/manzt/numcodecs.js/tree/main/codecs/blosc ). I don't know much about linking C libraries or WASM itself (other than running cargo build and praying...); is it possible to bake that kind of configuration into a build.rs and gain WASM support for blosc-sys? I gather the hard bit is the FFI between rust and C.

I suppose there could alternatively be a separate crate which generates a WASM blob as above and then writes a dependent rust wrapper around it with js_sys for API niceness.

Wow, interesting idea. I don't know much about WASM, either. But my preferred approach would be your second suggestion: a separate crate to generate the WASM blob.

Most rust-wasm packages use the wasm32-unknown-unknown target instead of the wasm32-unknown-emscripten target, which is what you'd need to use if you have a C library. The tooling around the rust+emscripten bindings isn't very good rustwasm/team#291

I'm going to close this issue because nobody seems to be working on it. And to be clear, I'm not going to do it myself; I know nothing about wasm or browsers. But I can help you with the blosc side if you try it.

In case anyone comes here to try this, there's currently some work to make the C - Rust wasm story a lot simpler: rustwasm/wasm-bindgen#3454