Couldn’t a tcc or similarly simple C compiler be used instead of a 100MB Clang? Where’s the C to wasm compiler hiding?
Show HN: Compiling C in the browser using WebAssembly
41–50 of 74 posts
Re: Show HN: Compiling C in the browser using WebAssembly
#42What's the use case?
Re: Show HN: Compiling C in the browser using WebAssembly
#43Couldn’t a tcc or similarly simple C compiler be used instead of a 100MB Clang? Where’s the C to wasm compiler hiding?
I recently wanted to use tcc for a homebaked programming sideproject and was surprised to find it's no longer supported anymore, at least not by Fabrice Bellard. Upstream git still has some light activity but no releases. I wasn't sure how good of an idea it is to rely on it as a code generator.
We wait for grischka to decide when to announce a new release https://lists.nongnu.org/archive/html/tinycc-devel/2024-10/m...
Re: Show HN: Compiling C in the browser using WebAssembly
#44Now all this needs is a simple OS running in a browser, that can edit and compile itself, post the resulting binary onto a WebDAV somewhere, and reload itself from there. Then it becomes a fully self-sustaining OS that can live forever in a browser.
Re: Show HN: Compiling C in the browser using WebAssembly
#45Re: Show HN: Compiling C in the browser using WebAssembly
#46Earlier quoted context omitted.
One issue with Wasm is you essentially can't target it with a single-pass compiler, unlike just about any real machine. Wasm can only represent reducible control flow, so you have to pass your control-flow graph through some variation of the Relooper[1,2]. I don't know if upstream tcc can do that (there are apparently some forks?..). [1] http://troubles.md/why-do-we-need-the-relooper-algorithm-aga... [2] https://medi…
> you essentially can't target it with a single-pass compiler, That might be true if your source language has goto, but for other languages that start with structured control flow, it's possible to just carry the structure through and emit Wasm directly from the AST.
Re: Show HN: Compiling C in the browser using WebAssembly
#47Earlier quoted context omitted.
MB, right? Mb is megabit I only have to bring this up because network providers still insist on measuring bits
They insist on it because it is the proper way to measure data rates on serial bit streams where out-of-band encoding doesn't divide up on octet boundaries.
Re: Show HN: Compiling C in the browser using WebAssembly
#48https://www.destroyallsoftware.com/talks/the-birth-and-death...
Re: Show HN: Compiling C in the browser using WebAssembly
#49Earlier quoted context omitted.
> you essentially can't target it with a single-pass compiler, That might be true if your source language has goto, but for other languages that start with structured control flow, it's possible to just carry the structure through and emit Wasm directly from the AST.
Presumably C's `switch` is also a problem.
https://old.reddit.com/r/C_Programming/comments/16kg48y/mind...
https://old.reddit.com/r/programminghorror/comments/ylc7f3/w...
Re: Show HN: Compiling C in the browser using WebAssembly
#50Is it possible/already existing to have interactive C++ lessons where the user's C++ code is compiled an run client-side in a web page?
See: emception https://github.com/jprendes/emception
What syntax can be used to run emception? Thank you.