← 输入框|github.com|刷新
Skip to content

Support deployment to wasm32-unknown-unknown without wasm-bindgen #4320

Closed

Description

@lastmjs

wasm32-unknown-unknown != wasm-bindgen support.

This is one of the main problems we have with RustPython, as the environment we are deploying to is a non-browser strict wasm32-unknown-unknown environment without wasm-bindgen support.

RustPython by default expects wasm32-unknown-unknown to support wasm-bindgen, thus in our fork of RustPython we have to make the following changes that can be seen in this pull request: https://github.com/demergent-labs/RustPython/pull/1/files

1

In vm/Cargo.toml:

We need to change this:

getrandom = { version = "0.2.6", features = ["js"] }

To this:

getrandom = { version = "0.2.6", features = ["custom"] }

The js feature assumes wasm-bindgen support.

2

In vm/Cargo.toml:

We need to change this:

chrono = { version = "0.4.19", features = ["wasmbind"] }

To this, or to a newer version without the wasmbind feature:

chrono = { version = "=0.4.19" }

3

In vm/Cargo.toml we need to comment out the following:

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "0.2.80"

4

In vm/src/stdlib/time.rs we need to comment out everything from line 94-102, basically get rid of all of the wasm_bindgen stuff. We also need a way to provide our own time functionality, which comes from a crate called ic_cdk, which has an API ic_cdk::api::time that will give us system time for our environment.

5

In vm/src/vm/vm_object we need to comment out all wasm_bindgen functionality, from lines 45-55.

Assuming wasm-bindgen support requires us to maintain a fork with these many changes, it would be great to upstream the ability to turn off wasm-bindgen so that our fork can be much smaller or even disappear.

Thanks!

Activity

  1. youknowone commented on Dec 10, 2022

    @youknowone
    Member

    We'd better to add "wasm-bindgen" feature and disable them without the features.
    On the other hand, we need to package the dependency reversed way to allow outer project can inject their own implementation. And then wasm-bindgen impl can be one of them.

  2. lastmjs commented on Apr 14, 2023

    @lastmjs
    Author

    Any update on this? It's difficult for us to update to the latest RustPython because we have to track down all of the wasm-bindgen dependencies and manually turn them off.

  3. lastmjs commented on Apr 14, 2023

    @lastmjs
    Author

    We're going to attempt a PR for this

  4. youknowone commented on Oct 6, 2026

    @youknowone
    Member

    example_projects/wasm32_without_js builds rustpython-vm for wasm32-unknown-unknown with default-features = false and no wasm-bindgen/JS host (rustpython-without-js + wasm-runtime).

    Closing.

    — commented by Grok 4.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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