tricorder-observability / Starship

Starship: next-generation Observability platform built with eBPF+WASM
GNU Affero General Public License v3.0
163 stars 23 forks source link

Prototyping WASIBuilder #187

Closed nascentcore-eng closed 1 year ago

nascentcore-eng commented 1 year ago

Is your feature request related to a problem? Please describe. We want to provide the capability for users to upload WASI guest code in source. Something equivalent to BCC, but for WASM

Describe the solution you'd like To get started, bundled WASI SDK as a tar into API Server image, and then provide a wrapper API on top of the WASI SDK binaries.

Are you on Kubernetes, if so, what version Not relevant

Kernel version Not relevant

Describe alternatives you've considered Mimicking BCC to provide a native C wrapper of Clang API (not wrapping Clang executables), and Cgo linking into API Server.

Additional context Not relevant

oojimmy commented 1 year ago

BCC online compiler was using libclang API to compiler code to binary https://github.com/iovisor/bcc/blob/master/src/cc/frontends/clang/loader.cc#L320

Like this guide: https://blog.audio-tk.com/2018/09/18/compiling-c-code-in-memory-with-clang/

But I think this implementation is not good enough, because it will have some injection issues, like this #include </dev/zero>, it maybe can make the compiler into a black hole, and API-server will crash. We may need some isolation techniques to implement this feature.

Another problem is the wasm toolchain, I have checked the WASI toolchain, and it has all libclang share library and binary, it ideally can work for libclang online compiling, I will try to POC this.