kristapsdz / lowdown

simple markdown translator
https://kristaps.bsd.lv/lowdown
ISC License
294 stars 36 forks source link

Add initial support for the wasm32-wasi target #99

Closed paravoid closed 1 year ago

paravoid commented 2 years ago

I have successfully built lowdown to WebAssembly, using the wasm32-wasi target. The resulting wasm binary can be executed locally with wasmtime (wasmtime lowdown), wasmer (wasmer lowdown) and wasmedge, or deployed in a serverless cloud.I had success with all three, using Cloudflare Workers for the latter, with their brand new WASI support.

The changes required are #98, kristapsdz/oconfigure#23, kristapsdz/oconfigure#24, and this change. Beyond those, the following issues remain:

Necessary pieces are: a clang supporting the wasm32-wasi target, compiler-rt built for wasm32-wasi and wasi-sysroot (w/ wasi-libc). All of those provided by the wasi-sdk.

The command-line to build would be: AR=llvm-ar CC=clang CFLAGS="--target=wasm32-wasi --sysroot=/opt/wasi-sysroot" ./configure LDFLAGS="--rtlib=compiler-rt"

kristapsdz commented 1 year ago

Thank you for this! I've addressed the termios issue in the upstream. As for the sandbox comment... I've kept your ifndef, but added more explanation in the code. I don't really like this special case, but until there's a more general way of handling platform sandboxing, am ok with keeping it.