Skip to content
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

feat(wasm): support building for webassembly target #43

Merged
merged 14 commits into from
Apr 25, 2024

Conversation

doinkythederp
Copy link
Member

@doinkythederp doinkythederp commented Apr 17, 2024

Describe the changes this PR makes. Why should it be merged?

This PR adds support for building for WebAssembly to be simulated.

  • Cargo config has updated linker flags
    • Memory is no longer shared because there is no need to simulate FreeRTOS task switching. Before, the simulator would essentially do multithreading (but only run 1 thread at once). Multithreading in WASM requires memory to be marked as shared.
    • Indirect function table is now imported instead of exported. This makes it easier to develop the simulator because the jump table can be set up before booting. I didn't do this with the memory because it seems like Dlmalloc can't see imported memory and always returns OOM errors?
  • Wasm32 is now a checked target by rust-analyzer; this was necessary for making sure everything compiled on both platforms.
  • Added NoopCriticalSection for WASM
    • WASM doesn't have interrupts or any way to disable them so I'm pretty sure it's safe. Also because the module's memory is not shared there is guaranteed to not be any multithreading.
  • Cfg's for ARM assembly
    • The operations being performed at the start of the program aren't actually necessary in WASM.

Additional Context

  • I have tested these changes on a VEX V5 brain.
  • I have tested these changes in a simulator.

@doinkythederp
Copy link
Member Author

I've updated the examples I modified to actually do what their name suggests. Also, I removed the unstable WASM feature flags because they were only needed for FreeRTOS emulation.

@doinkythederp doinkythederp marked this pull request as ready for review April 17, 2024 03:34
@Gavin-Niederman
Copy link
Member

Please fix the warning about missing documentation.

@doinkythederp doinkythederp changed the title feat: support building for webassembly feat(wasm): support building for webassembly target Apr 17, 2024
@Tropix126 Tropix126 added the simulator Relates to the WASM or QEMU simulator on vexide's end. label Apr 17, 2024
Copy link
Member

@Tropix126 Tropix126 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM otherwise

packages/vexide/examples/basic.rs Outdated Show resolved Hide resolved
Copy link
Member

@Gavin-Niederman Gavin-Niederman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (Lets Get That wasM)

Copy link
Member

@Tropix126 Tropix126 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Tropix126 Tropix126 merged commit 6e8b460 into vexide:main Apr 25, 2024
3 checks passed
@doinkythederp doinkythederp deleted the feat/wasm branch April 26, 2024 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
simulator Relates to the WASM or QEMU simulator on vexide's end.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants