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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add webassembly language #6429

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

afonso360
Copy link

馃憢 Hey,

This PR adds support for the Webassembly Text Language (#1871). Currently it only supports the wasmtime compiler, but it should be possible to add others (i.e. v8 / wasmer / etc...).

It looks like the monaco does not support the WAT language, so I've added a simple mode for it, that is mostly copied from the clojure mode with some changes. From what I've tested it seems to work reasonably well.

image

lib/languages.ts Show resolved Hide resolved
Comment on lines +2 to +3
objdumper=llvm-objdump
objdumperType=llvm
Copy link
Author

Choose a reason for hiding this comment

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

I used llvm-objdump here because wasmtime supports a --target=<triple> parameter that cross-compiles WASM modules for other architectures. The problem is that when using objdump it then can't disassemble the resulting file. I'm not sure if there is a better solution to handle these cases

Copy link
Member

@RubenRBS RubenRBS left a comment

Choose a reason for hiding this comment

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

Hi! Thanks a lot for taking the time to add support for this, we really appreciate it :)

I have a few minor comments on the config files, but other than that, this looks great!

etc/config/wasm.defaults.properties Outdated Show resolved Hide resolved
etc/config/wasm.defaults.properties Outdated Show resolved Hide resolved
group.wasmtime.isSemVer=true

compiler.wasmtime2001.name=Wasmtime 20.0.1
compiler.wasmtime2001.exe=/opt/compiler-explorer/wasmtime-20.0.1/wasmtime
Copy link
Member

Choose a reason for hiding this comment

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

The path in the defaults environment should be the one where a typical wasm installation would find the binary - this is usually /usr/bin/{binaryname} for most other language compilers, but whatever works best in wasm's case would be ok

Copy link
Author

Choose a reason for hiding this comment

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

I'm not too sure what to do here, wasmtime defaults to installing via a shell script, and the default location is $HOME/.wasmtime/bin/wasmtime, installing via cargo (the rust package manager) also installs it in the users home directory. I also don't think there are any system packages for it. At least that I could find.

Copy link
Member

@RubenRBS RubenRBS May 4, 2024

Choose a reason for hiding this comment

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

Hmm, I see. We could probably merge as-is then, but let's see what others think first, I'll bring it up tomorrow if noone checks this before :)

Thanks for the extra insight!

etc/config/wasm.defaults.properties Outdated Show resolved Hide resolved
lib/languages.ts Show resolved Hide resolved
static/modes/wat-mode.ts Outdated Show resolved Hide resolved
static/modes/wat-mode.ts Outdated Show resolved Hide resolved
The previous regex had a exponential backtracking issue under some inputs.
@syrusakbary
Copy link

I'd love to have Wasmer supported as well! Let me know if we can help with that :)

@afonso360
Copy link
Author

afonso360 commented May 14, 2024

Awesome! I already have a WIP patch locally adding wasmer! I was waiting to get this merged in before proposing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants