Closed paravoid closed 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.
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:
sed -i -r 's/HAVE_(MKFIFOAT|MKNODAT|FTS|B64_NTOP|READPASSPHRASE|SETRESGID|SETRESUID) 0/HAVE_\1 1/' config.h
make lowdown
needs to be used.wasi-libc does not provide(edit: this is now fixed)getpagesize()
that the bundledrecallocarray()
requires. Easily worked around by replacing it withsysconf(_SC_PAGE_SIZE)
, but I've also asked wasi-libc upstream to add the (trivial) implementation as well (WebAssembly/wasi-libc#299)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"