2 ms·
golang compiles to eBPF? including the whole golang runtime with garbage collector? that... surprises me edit: I don't see anything on the web that would show
by shp0ngle 3y ago
golang compiles to eBPF? including the whole golang runtime with garbage collector? that... surprises me
edit: I don't see anything on the web that would show golang compiles to eBPF. I see bpf2go which is the other way around.
- thatloststudent 3y agoThis [1] makes me think gobpf uses C bindings to bcc, so golang does not compile to eBPF, bcc does. [1] - https://github.com/iovisor/gobpf/tree/master/bcc https://github.com/iovisor/gobpf/tree/master/bcc
- ants_everywhere 3y agoOh, no I don't mean that arbitrary Go compiles to eBPF. Apologies if I gave that impression. I meant that there are libraries that let you compose eBPF programs in other languages. But you're still putting together an eBPF program, just like you can assemble JSON with Go but you can't compile an arbitrary Go program to JSON. Cilium's eBPF library is the Go one I had in mind: https://github.com/cilium/ebpf https://github.com/cilium/ebpf Here's an example from that repo: https://github.com/cilium/ebpf/tree/main/examples/ringbuffer https://github.com/cilium/ebpf/tree/main/examples/ringbuffer
- spaceywilly 3y agoBPF works more like Java, where you have your high-level source code, then a JIT compiler translates it to bytecode that runs on a VM. Even BPF “programs” written in C aren’t using a standard C compiler. The BPF JIT compiler translates them to bytecode. The subset of C you can use is fairly limited, only what their compiler supports. So what people have done is written compilers that can take Go or Python and compile it to BPF bytecode.