Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: WASM builds #331

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

WIP: WASM builds #331

wants to merge 1 commit into from

Conversation

sroussey
Copy link
Contributor

@sroussey sroussey commented Jan 6, 2024

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

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.
@sroussey
Copy link
Contributor Author

sroussey commented Jan 6, 2024

Related: #328

@ashvardanian
Copy link
Contributor

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
Copy link
Contributor Author

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

@ashvardanian
Copy link
Contributor

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:

  • wasm32-unknown-unknown – this backend provides no C standard library or system call interface; to support this backend, we would need to manually rewrite every system or library call to make use of imports we would define ourselves in the runtime.
  • wasm32-wasi – WASI is a standardized system interface, and defines a standard set of imports that are implemented in WASI runtimes such as wasmtime.
  • wasm32-unknown-emscripten – Like WASI, Emscripten defines the imports that a WebAssembly program needs to execute, but also outputs an accompanying JavaScript library that implements these imported functions.

Pyodide uses Emscripten, and provides three things:

  • A distribution of the CPython interpreter, compiled using Emscripten
  • A foreign function interface (FFI) between Python and JavaScript
  • A set of third-party Python packages, compiled using Emscripten’s compiler to WebAssembly.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants