-
Notifications
You must be signed in to change notification settings - Fork 778
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
wasm32-emscripten support #2412
Comments
We are actively testing Python 3.11 development versions on CI so I think it should be ready. Line 93 in f84c740
|
Hey, thanks for offering to help us build up wasm support! With the Python 3.11 wasm interest, it feels like a great time to start testing this in CI. I agree with @messense that adding a new CI job using the Python 3.11 beta is probably the easier choice? Honestly though I think you're the expert in this domain, so happy to take your lead on whichever seems simpler. Let me know if you need any pointers in order to add the CI job?
I suspect that that's fundamental to either
Oh, I'm curious why?
We only run |
Python3.11.0b1 it is then.
Will do, still working on getting the tests working in an ad-hoc way on my local setup. They mostly work but
You can print out the target info with: RUSTC_BOOTSTRAP=1 rustc -Z unstable-options --print target-spec-json --target=wasm32-unknown-emscripten and you see:
Yeah that would probably be useful.
Well I tried removing it and... it works fine without it. So we don't need nightly =) |
Custom cargo runner should do: https://doc.rust-lang.org/cargo/reference/config.html#targettriplerunner |
Okay, on my local setup, all tests pass except the following:
|
Nice! We can always start by adding
|
Will keep this open until we solve the tests with remaining issues. |
I'm also interested in adding wasm python extension module build support to maturin and setuptools-rust, I'd love to learn more about how to implement it, for example how to build a python.wasm file and run it in nodejs or wasmtime. |
I am looking into adding emscripten-wasm CI support for setuptools-rust next. |
Also, very happy to provide advice about building for the emscripten-wasm target. I don't know as much about wasi, and I've been putting off on learning it because it doesn't support dynamic linking yet. |
Actually, it seems like all of pyo3 requires libffi? The only wasm target that currently has a libffi port is emscripten-wasm32 so I don't think you will be able to build for wasi-wasm or unknown-wasm until that is fixed. Though it's not really clear that it's possible to make a libffi port for wasi-wasm since wasi doesn't have a way to make flexible argument call trampolines. I guess if you don't need closure support you could make a predefined list of trampolines based on what signatures you think you might need at runtime and just fail if someone tries to make a libffi call outside the list. |
That's interesting, can you detail to me why this appears to be the case? We don't knowingly link to |
In that case I'm probably wrong! I think I read |
Okay now I remember why I was using
I'm not sure why I'm not getting them when building the cryptography package anymore. |
This is really exciting, thanks everyone for your work on this. I'd love pydantic-core to be a guinea pig for releasing packages with wasm support. It should be a good candidate as there's no disk or network IO involved. I think we're pretty much ready an initial release of pydantic-core, is there anything I can do to encourage this? Or somewhere else I should submit a PR or issue? |
@samuelcolvin Emscripten support was added to maturin in PyO3/maturin#974 which was released in To build a wheel, with emscripten installed, run the following command with a Rust nightly toolchain maturin build --manifest-path <Path to Cargo.toml> --target wasm32-unknown-emscripten -i python3.10 |
thanks @messense pydantic/pydantic-core#106. |
Is there anything remaining in this issue? We have emscripten CI in all of PyO3 / maturin / setuptools-rust which appear to be working, so I think this can be called resolved? |
Agreed. |
Well there's a couple more things I'm interested in:
It would be reasonable to close this one and open one or more new issues for these more specific things. |
Sounds good to me; will track follow-ups in #2582. |
I am interested in wasm32-emscripten support for pyo3. We are able to build the cryptography package:
pyodide/pyodide#2378
There are still some issues with the toolchain which require patching:
llvm/llvm-project#55786
Another issue that I have is that for some reason pyo3 produces
blah.wasm
files rather thanblah.so
files. In our cargo/rustc wrapper, we look for.wasm
files and move them to.so
files. This would probably be an easy fix but I don't know where the problem comes from. We also use-Zbuild-std
so we need to use nightly.https://github.com/pyodide/pyodide/pull/2378/files#diff-dcdc2b45d6538a6db4fa7c76a3b29c56f5f7e7669ab7460385c4241d6d453ce2
If these are things that could be improved in PyO3 or if I am just missing some setting, it would be helpful to know.
I see on #1522 you said:
I would be interested in contributing a CI job for wasm32-emscripten. Options:
Also, until wasm-ld is fixed to not be mad about
lib.rmeta
files we will need a patch for emscripten. (I'm actually a bit surprised you don't run into this problem withwasm32-wasi
.)Build time for the wasm32-emscripten Python interpreter is generally a bit shy of 15 minutes. I think we could run the tests themselves in node.
The text was updated successfully, but these errors were encountered: