unum-cloud / usearch

Fast Open-Source Search & Clustering engine × for Vectors & 🔜 Strings × in C++, C, Python, JavaScript, Rust, Java, Objective-C, Swift, C#, GoLang, and Wolfram 🔍
https://unum-cloud.github.io/usearch/
Apache License 2.0
2.15k stars 130 forks source link

WIP: WASM builds #331

Open sroussey opened 9 months ago

sroussey commented 9 months ago

WASM is arch independant, so no need to make for each arch. Will just build on linux.

Get mmap emulation working.

We need stdlib

To use like a library requires some __attribute__ stuff in cpp and -mexec-model=reactor in the build command.

Still fails:

wasm-ld: error: /var/folders/74/djsf8lv965l2tkgr29ybpz4h0000gn/T/lib-a51bfe.o: undefined symbol: __cxa_allocate_exception
wasm-ld: error: /var/folders/74/djsf8lv965l2tkgr29ybpz4h0000gn/T/lib-a51bfe.o: undefined symbol: __cxa_throw
wasm-ld: error: /var/folders/74/djsf8lv965l2tkgr29ybpz4h0000gn/T/lib-a51bfe.o: undefined symbol: __cxa_free_exception
sroussey commented 9 months ago

Related: https://github.com/unum-cloud/usearch/issues/328

ashvardanian commented 7 months ago

I start thinking that for WASM support, we must change at least JS and Rust bindings to use the intermediate C layer, introducing ABI stability, and then simply shipping precompiled shared libraries for WASM. What do you think, @sroussey?

sroussey commented 7 months ago

Can't ship anything that uses exceptions at the moment, at least with wasi. Quickly changing area, but still not there yet.

ashvardanian commented 6 months ago

I am not sure about JavaScript WASM support yet, but CloudFlare recently posted an article about their Pyodide workers:


LLVM provides three target triples for WebAssembly:

Pyodide uses Emscripten, and provides three things:


I am thinking to update the setup.py to support Emscripten and other compilers, and later upload the wheel to release notes.