bytecodealliance / bytecodealliance/wasmtime

cranelift: Add support for BPF code generation

Open
#14,236 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 18h
Merged PRs (30d)
126

Description

#### Feature

I need BPF back end code generator that is not a 100MB in size, cranelift looks ideal (based on AI prototypes).

BPF is small RISC style ISA that should be relatively straightforward to implement.

#### Benefit

I am working on a [scripting language](https://github.com/oddcoder/traqilet) that compiles down to BPF and is meant to be stapable to production systems. I need a lightweight optimizing JIT capable of producting BPF assembly to be loaded in relatively constrained environments.

Currently the alternatives are one of the following:

A- compile down to bpf byte code and ship it. Sometimes that can be impractical when having diverse machines with diverse kernel versions.

B- Strap a full LLVM toolchain to to the script so that it compiles on target

#### Implementation

I have no idea yet how to do it yet. I hope you would surprise me by saying this a) exists b) is WIP and is fully resourced.

If not, AI was able to prototype an implementation via traversing IR and generating assembly. So least I know it is doable.

I read a bit about ISLE, and I am kind of familiar with term rewriting in general due to previous experience with proof tactics in coq.

I patched cranelift to expose its internals for an out of tree implementation of a backend. I will be doing my own implementation in [traqilet/crates/bpf](https://github.com/oddcoder/traqilet/tree/main/crates/bpf), by copying alot from the structure of existing backends and will PR the back-end bit by bit.

#### Alternatives

I am not aware of any reasonable alternatives.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.