Skip to content

wasm32-emscripten support #2412

@hoodmane

Description

@hoodmane

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 than blah.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:

If anyone with knowledge of how to build a Python interpreter for wasm wants to contribute a full CI job, that would be cool!

I would be interested in contributing a CI job for wasm32-emscripten. Options:

  • build against 3.11b1 -- we wouldn't need to patch the Python interpreter, but this may require the rest of the PyO3 dependencies to work against 3.11b1 which it might not be ready for
  • build against 3.10 -- Pyodide already does this. We would need a few patches, but probably some of our patches can be dropped.

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 with wasm32-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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions