Stream: cranelift

Topic: First contribution


view this post on Zulip Vinayak Dev (Dec 04 2024 at 11:34):

Hi all!

I am looking to start contributing to cranelift, and eventually wasmtime.

I went through most of the good first issues on the wasmtime repo, but it appears to me that almost all of the issues have PRs attached to them, or have been solved but not closed.

Is there something that the maintainers think would be worthwhile working on? I would love to be of help! I have a good experience with compilers, but will be writing Rust at this level for the first time.

Any suggestions/thoughts are most welcome!

view this post on Zulip fitzgen (he/him) (Dec 04 2024 at 17:44):

Hi Vinayak! Welcome :)

I think contributing to Winch and/or Pulley could be a great on-ramp for you. Winch is our baseline/single-pass Wasm compiler that trades better compile time for worse codegen. Pulley is our portable, optimizing interpreter that ultimately aims to let you take Wasmtime anywhere that the Rust compiler can target, even if we don't have a Cranelift or Winch backend for that architecture (e.g. we don't have backends for riscv32 or esp32 currently, but rustc can target those architectures, so with Pulley we would still be able to run Wasm on them)

More context/overview/motivation in the RFCs that introduced Winch and Pulley:

At this time, Winch is fairly complete for x86 but aarch64 is still a WIP. No one has started on riscv64 or s390x yet (which are the two other backends that Cranelift currently supports but Winch does not yet). Check out the winch subdirectory of the repository. I'd suggest perhaps finding a Wasm instruction that isn't implemented on aarch64 yet and putting up a PR to implement it. Example of doing this kind of thing: https://github.com/bytecodealliance/wasmtime/pull/9033

Another possibility (probably better for a second/third/fourth PR once you've got into the swing of things) could be implementing a Wasm proposal for Winch that isn't supported yet, such as Wasm reference types, SIMD, GC, etc...

+cc @Saúl Cabrera, who is the lead for Winch

As for Pulley, it is very much more of a WIP at the moment. @Alex Crichton has a few PRs in flight right now that I need to review and merge, but locally has all the infra for running all the Wasm spec test suite, so once all that lands, we just need to bang out all the instruction implementations. This involves basically defining any new pulley bytecode instructions (Pulley has its own bytecode and does not interpret Wasm directly; see RFC for more details) that might be needed, adding support to Cranelift's Pulley backend for emitting those instructions (hooking up encoding support and defining CLIF-to-Pulley-bytecode lowering patterns), and adding tests as necessary. See the pulley and cranelift/codegen/src/isa/pulley-shared/ directories for more details here. If you're interested in Pulley, I can also follow up once the in-flight work lands and this effort really opens up as far as parallel work items goes.

Does all that make sense? What follow up questions do you have?

Hey 👋 This PR implements clz and ctz instructions for winch targeting aarch64. #8321
RFC process for Bytecode Alliance projects. Contribute to bytecodealliance/rfcs development by creating an account on GitHub.
RFC process for Bytecode Alliance projects. Contribute to bytecodealliance/rfcs development by creating an account on GitHub.

view this post on Zulip Vinayak Dev (Dec 04 2024 at 18:03):

@fitzgen thanks for replying! Winch does appear to be a great starting point, so I'll begin with that. Thanks for the links to the RFCs and the PR, I will use them as references in my own work.

Does all that make sense?

Yes! Now that I have a clear way forward, I think I can pick up an issue to work on and build from there.

Contributing to Pulley would be great, I would be very happy to be of help when parallel work is required.

What follow up questions do you have?

None at the moment, your post was quite clear. If I need help, I will reach out again here! In the meantime, I will take a little time to look at the winch codebase and pick up an instruction to port to aarch64.

Thanks a lot! I will be opening a PR very soon :)

view this post on Zulip fitzgen (he/him) (Dec 04 2024 at 18:06):

great! looking forward to it :)

view this post on Zulip Alex Crichton (Dec 04 2024 at 18:13):

I'm getting close-ish with Pulley to landing the testing integration with everything but there's still more prerequisites to fill out, so Pulley's not great yet. My hope is that in the next week or two though it'll be a prime contribution target as it'll be a problem of "just" supporting more instructions and that's it

view this post on Zulip Vinayak Dev (Dec 04 2024 at 18:15):

Understood. It should take me that much time to open a PR to Winch, so I guess that is perfectly alright. Thanks!

view this post on Zulip Saúl Cabrera (Dec 04 2024 at 18:16):

Hi Vinayak,

We currently track all the Winch related work in this board: https://github.com/orgs/bytecodealliance/projects/12. If you're interested or have questions around any of those issues, reach out through Zulip. If your intention is to work on some of the missing instructions for Aarch64 feel free to comment on the issue/reach out through Zuilip so that I can assign your name next to them to avoid duplicated effort.

Tracking board for Winch

view this post on Zulip Alex Crichton (Dec 10 2024 at 17:29):

If you're curious we've now got some documentation on contributing to Pulley

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant - bytecodealliance/wasmtime

view this post on Zulip Vinayak Dev (Dec 10 2024 at 17:38):

Thanks @Alex Crichton! I'll go through the docs.


Last updated: Dec 23 2024 at 12:05 UTC