6 ms·
TCC RISC-V Compiler Runs in the Web Browser (Thanks to Zig Compiler)
- pitherpather 3y agoScrolled all the way through; very impressive. > We have implemented (fully or partially) 48 POSIX Functions from above. ...[however] These 24 POSIX Functions will Halt when TCC WebAssembly calls them… I was just wondering this evening: I have seen WASM described as an environment for selectively subsetting interfaces, in part for security. Is the following sometimes done?: Compile and link to a "glibc" which implements only a subset of calls, again for runtime security?
- GrumpySloth 3y agoStatically linking with musl and enabling LTO sounds like what you’re looking for.
- flohofwoe 3y agoThat's basically what WASI is about (or now the specific derivation called WASIX). Essentially a POSIX runtime for WASM, but typically using musl instead of glibc.
- syrusakbary 3y agoA few months ago Wasmer tried add WASIX support to Zig so anything on Zig ecosystem could target the browser easily, which is quite relatable of what the TCC compiler is trying to achieve. I'm sure at some moment the community will pick it up. I'll drop a link to WASIX in case is useful for the reader! https://wasix.org https://wasix.org
- fwsgonzo 3y agoAs usual, comment out all the error handling code. Also my experience with WASM.
- flohofwoe 3y agoTBF, setjmp/longjmp is a fairly exotic way for doing error handling in C. The only other place I've seen it so far is libjpeg.
- cygx 3y agoNote the SJLJ is one of the ways to implement C++ exceptions, which is one of the reasons why LLVM keeps it around[1]. [1] https://llvm.org/docs/ExceptionHandling.html#sjlj-intrinsics https://llvm.org/docs/ExceptionHandling.html#sjlj-intrinsics
- mati365 3y agoRecently I created C compiler directly in TypeScript [1]. Maybe it is not super fast but at least adding new backends is much easier. [1] https://github.com/Mati365/ts-c-compiler https://github.com/Mati365/ts-c-compiler
- cod1r 3y agoThis is super cool. I'm also trying to write a C compiler but in Rust and it's difficult.
- pjmlp 3y agoI fail to see why zig had to be introduced, with Emscripten being there, other than "I want to use zig".
- szundi 3y agoZig is going to be the new Rust for some people
- pjmlp 3y agoExcept it is being used here as a wrapper for C and C++ clang packaging. Also as remark, Zig is going to be the new Modula-2, with revamped syntax for C minded folks, and compile time support. Assuming it takes off post 1.0, still a long to go in the adoption chasm graph.
- ZoomZoomZoom 3y agoI'm sorry to inform, but the new Modula-2 is already Nim, isn't it?
- pjmlp 3y agoNot really, that is more like a compiled Python.
- ZoomZoomZoom 3y agoIt's like saying a lizard is closer to a table than to a snake, because it has legs.
- xeonmc 3y agoBut he is saying it’s closer to a snake though...?
- laerus 3y agoZig is not memory safe.
- hongbo_zhang 3y agoNot only we have a compiler but we have a full blown IDE in the browser: try.moonbitlang.com