Stream: git-wasmtime

Topic: wasmtime / issue #7124 Externally maintained cranelift ba...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 02 2023 at 07:37):

nagisa opened issue #7124:

Feature

Today cranelift has a number of backends for traditional computer architectures: x86, aarch64, riscv64 and some others as well. It would be great if we could have many more, however adding new backends to cranelift-codegen crate faces some difficulties:

As thus, we should make sure that implementation and use of backends implemented outside of the wasmtime/cranelift repositroy is relatively painless. This could be at least the following:

Benefit

Having this infrastructure in place benefits the cranelift project through an eventually increased architecture support, while at the same time not making these additional, and potentially obscure, targets a maintenance burden to the developers upstream.

These backends could move at their own pace for a fair bit of changes too. Although I don’t see how they could avoid needing to keep up with the interface that clift would expect from these backends (especially if these backends wanted to be loaded with a project that integrates a specific version of clift, such as rustc,) but a change like the migration from regalloc to regalloc2 could potentially be made at the backend’s own pace.

Implementation

We at Pagoda have a desire to implement a backend, and although we’re currently hacking on the backend in a fork, it seems that there is a consensus a backend like ours would make most sense as an externally maintained crate.

So far the plan is to figure out the things as we go and contribute changes and/or specific feature requests as they come up. In that sense this issue might act as a tracking issue of sorts.

Alternatives

The alternative of continuing inclusion of all backends in-tree has been considered. There is a concern that these backends may become an excessive maintenance burden, especially as or if the maintainers of the backend become unreachable.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 02 2023 at 10:26):

bjorn3 commented on issue #7124:

TargetIsa should be implementable out-of-tree. You still need a patch to the cranelift user to use your TargetIsa impl though. You can also have your own impl of Module if you are using a non-conventional architecture. This is a lot more flexible, but Wasmtime doesn't use this as it needs low-level control in ways that targets like Wasm and zkASM can't offer anyway. And Wasmtime has hard coded relocation resolving code. Having a new Module impl for Wasm or zkASM as alternative to cranelift-jit and cranelift-object should be possible. I even made an impl which serializes all functions without compiling to then later deserialize into another Module with only a couple of small Cranelift changes required to Cranelift to allow remapping id's in the deserialized Function. Was pretty easy to hook up to cg_clif for "LTO" support. (LTO without actually doing any cross-module optimizations. Just the delaying all codegen until the final executable is being compiled.)


Last updated: Dec 23 2024 at 12:05 UTC