snipsco / snips-nlu-rs

Snips NLU rust implementation
https://snips.ai
Other
340 stars 56 forks source link

Support for wasm target? #21

Open rodrigopivi opened 6 years ago

rodrigopivi commented 6 years ago

Is there any intention to support wasm32-unknown-unknown target? I've tried to target web assembly but there are current old or deprecated dependencies that don't support wasm32 looking at the cargo tree. How hard would it be updating or replacing some of the dependencies that use libraries like time rustc-serialize memchr and support wasm?

klefevre commented 6 years ago

Hello @rodrigopivi. Supporting wasm is something I'd like to bring and I think replacing these dependencies wouldn't be too hard but the main problem I had was with crfsuite-rs (https://github.com/snipsco/crfsuite-rs).

Because crfsuite-rs is just a binding of the C version of crfsuite. The steps to compile it are the following:

Which is basically what the crfsuite-sys crate does.

I successfuly compiled the static library for wasm32 target (at least I have an artefact), but I had a problem with bindgen to generate an API (no symbols were actually generated) which looks a lot like this issue rust-lang-nursery/rust-bindgen#751. And even after hacking a bit this part (like trying to reuse a generated API from an other 32bit target). The linking part failed which could be whether the result of a bad compilation of the static library or something else I don't know.

In order word, I tried and I failed. But I have a strong feeling that is doable if we put enough time into it. And the first step to do so is to compile crfsuite-rs for wasm32 and any help are welcome on this! So feel free to open a PR if you have any idea on how to do it.

seanghay commented 1 year ago

What about this https://github.com/seanghay/web-crfsuite 😉