Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Support rust-std in WebAssembly runtime #4043

Closed
sorpaas opened this issue Nov 7, 2019 · 3 comments
Closed

Support rust-std in WebAssembly runtime #4043

sorpaas opened this issue Nov 7, 2019 · 3 comments
Labels
J0-enhancement An additional feature request.
Milestone

Comments

@sorpaas
Copy link
Member

sorpaas commented Nov 7, 2019

The target we compile wasm runtime to, wasm32-unknown-unknown, actually has builtin std support. Adding support for std would help to solve many of our current user complaints.

Some details of the std support on the wasm target:

  • Filesystem is implemented as shim that cannot be constructed.
  • Single thread is assumed, which is used to implement constructs like Mutex and RwLock.
  • You can find more about the std implementation at this folder.
  • I think the only issue we need to deal with is the allocator. Currently the std library assumes dlmalloc, but it should be possible to switch it to our external allocator.
@sorpaas sorpaas added the J0-enhancement An additional feature request. label Nov 7, 2019
@sorpaas sorpaas added this to the As-and-when milestone Nov 7, 2019
@sorpaas sorpaas added this to To Do in Runtime via automation Nov 7, 2019
@sorpaas
Copy link
Member Author

sorpaas commented Nov 9, 2019

After some discussions with @gavofyork I think we'll not be adding std support in runtime. Closing the issue.

@sorpaas sorpaas closed this as completed Nov 9, 2019
Runtime automation moved this from To Do to Done Nov 9, 2019
@h4x3rotab
Copy link
Contributor

Why? I think any background here about the cancellation would be helpful for the developers.

@sorpaas
Copy link
Member Author

sorpaas commented Nov 10, 2019

@h4x3rotab I think the general consensus yesterday was that:

  • If developers try to do stuff which are not allowed in runtime, std opens up some caveats of panics, potential DoS attacks, among others. This is something we don't want to see.
  • While it was not the intention, we wrote many code with the assumption that std is native, no_std is wasm.
  • It makes things clear that runtime must be deterministic. It may not be a "perfect model", and I do think there're other models that may work better (for example, post-build check of unexpected imports), but still, this is a model that works.
  • It's considered by many that wasm32-unknown-unknown's std implementation is just unstable and not for production, while wasm itself is.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request.
Projects
None yet
Development

No branches or pull requests

2 participants