bytecodealliance / wasmtime

A fast and secure runtime for WebAssembly
https://wasmtime.dev/
Apache License 2.0
15.08k stars 1.26k forks source link

Can cranelift support eBPF? #7060

Closed chengshuyi closed 9 months ago

chengshuyi commented 11 months ago

Thanks for filing a feature request! Please fill out the TODOs below.

Feature

cranelift-codegen adds a new eBPF backend

Benefit

eBPF bytecode can be generated from cranelift intermediate code. Cranelift is more lightweight and has fewer dependencies than llvm. To be precise, the binary program I used to implement eBPF bytecode generation using cranelift is only about 10MB and has almost no dependencies.

Implementation

I used clif to simply implement some functions[1]. If possible, I can improve this part of the function.

[1] https://github.com/aliyun/coolbpf/blob/master/lwcb/bpfir/src/module.rs

bjorn3 commented 11 months ago

I opened an issue for this a couple of years ago: https://github.com/bytecodealliance/wasmtime/issues/1129 I didn't have any concrete use cases for it back then though, so it has been labeled as moonshot.

chengshuyi commented 11 months ago

I opened an issue for this a couple of years ago: #1129 I didn't have any concrete use cases for it back then though, so it has been labeled as moonshot.

Thanks for you quick reply. We are developing the ebpf scripting language to be able to write eBPF programs in a simple C-like language. We prefer to be able to deploy lightweight cranelift on the environment instead of llvm. I don’t know if this can be considered a case.

alexcrichton commented 9 months ago

Closing as a duplicate of https://github.com/bytecodealliance/wasmtime/issues/1129