Content-Length: 287514 | pFad | http://github.com/RustPython/RustPython/issues/5704

DF Can not build RustPython to wasm32-wasip2 · Issue #5704 · RustPython/RustPython · GitHub
Skip to content

Can not build RustPython to wasm32-wasip2 #5704

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

Open
miraclejzd opened this issue Apr 16, 2025 · 7 comments
Open

Can not build RustPython to wasm32-wasip2 #5704

miraclejzd opened this issue Apr 16, 2025 · 7 comments

Comments

@miraclejzd
Copy link

Summary

I am trying to build RustPython into .wasm file which can run Python program with ssl as dependency. I found that wasm32-wasip2 supports std fully, which means it supports socket proposal that wasm32-wasip1 does not.

But I failed.

Details

rustc version:

$ rustc --version
rustc 1.88.0-nightly (38c560ae6 2025-04-15)

I also add #![feature(wasip2)] to the crate attributes and here is the diff:

diff --git a/common/src/lib.rs b/common/src/lib.rs
index 25501e4f5..2ee3a78b5 100644
--- a/common/src/lib.rs
+++ b/common/src/lib.rs
@@ -1,5 +1,5 @@
 //! A crate to hold types and functions common to all rustpython components.
-
+#![feature(wasip2)]
 #![cfg_attr(target_os = "redox", feature(byte_slice_trim_ascii))]
 
 #[macro_use]
diff --git a/stdlib/src/lib.rs b/stdlib/src/lib.rs
index a910c5854..8da304ac6 100644
--- a/stdlib/src/lib.rs
+++ b/stdlib/src/lib.rs
@@ -1,5 +1,6 @@
 // to allow `mod foo {}` in foo.rs; clippy thinks this is a mistake/misunderstanding of
 // how `mod` works, but we want this sometimes for pymodule declarations
+#![feature(wasip2)]
 #![allow(clippy::module_inception)]
 
 #[macro_use]

Then I run the command below:

export RUSTFLAGS="-C linker=wasm-ld"
cargo build --release --target wasm32-wasip2 --features "freeze-stdlib,ssl"

It fails with the log:

warning: unused import: `utils::ToCString`
   --> vm/src/stdlib/os.rs:145:9
    |
145 |         utils::ToCString,
    |         ^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(unused_imports)]` on by default

warning: unused imports: `IntoPyException`, `Py`, and `TryFromBorrowedObject`
  --> vm/src/stdlib/signal.rs:15:19
   |
15 |         convert::{IntoPyException, TryFromBorrowedObject},
   |                   ^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^^^^
16 |         signal, Py, PyObjectRef, PyResult, VirtualMachine,
   |                 ^^

warning: `rustpython-vm` (lib) generated 2 warnings (run `cargo fix --lib -p rustpython-vm` to apply 2 suggestions)
   Compiling rustpython-stdlib v0.4.0 (/home/jzd/projects/RustPython/stdlib)
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `ssl`
   --> stdlib/src/lib.rs:154:23
    |
154 |             "_ssl" => ssl::make_module,
    |                       ^^^ use of unresolved module or unlinked crate `ssl`
    |
    = help: if you wanted to use a crate named `ssl`, use `cargo add ssl` to add it to your `Cargo.toml`

For more information about this error, try `rustc --explain E0433`.
error: could not compile `rustpython-stdlib` (lib) due to 1 previous error

What can I do to make it work? I need the feature ssl to enable python library couchdb and redis.

@youknowone
Copy link
Member

you will find mod ssl is disabled for the entire wasm32

@miraclejzd
Copy link
Author

you will find mod ssl is disabled for the entire wasm32

It is.
Do you plan to support ssl for wasm32-wasip2? I think it's an important feature for python :)

@youknowone
Copy link
Member

youknowone commented Apr 17, 2025

We usually don't have plans but cover more features step by step.
Yes, it is important. And a lot of things are important features for python. Please help us to support it.

@arihant2math
Copy link
Collaborator

To my knowledge it is not possible to support ssl for wasm, (barring some major shift in architecture) due to this:
sfackler/rust-openssl#1016.

@miraclejzd
Copy link
Author

To my knowledge it is not possible to support ssl for wasm, (barring some major shift in architecture) due to this: sfackler/rust-openssl#1016.

Well, I am not familiar with Rust(and RustPython). But in CPython, it is possible to add ssl support, check out wasmer/python . We can use pre-built openssl and link it to CPython. I am trying to find the same solution to RustPython, but due to my poor Rust knowledge, it's hard :(

@youknowone
Copy link
Member

youknowone commented Apr 17, 2025

Thank you for the reference! We may can do similar way.

One caveat. The linked wasmer/python is saying it is built on top of wasix, wasmer's variant of wasi.
Then that build will be only compatible to wasmer.

@miraclejzd
Copy link
Author

Thank you for the reference! We may can do similar way.

One caveat. The linked wasmer/python is saying it is built on top of wasix, wasmer's variant of wasi. Then that build will be only compatible to wasmer.

Absolutely! wasmer/python is wasix-based so that it can not work with wasmtime and other wasi-based wasm runtime. That's why I want to build a wasi-based python interpreter.

I will continue trying to find the solution. If you have any other idea, I will keep paying attention :)

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

No branches or pull requests

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/RustPython/RustPython/issues/5704

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy