Live data from Hacker News

Show HN: How to compile C/C++ for WASM, pure Clang, no libs, no framework

github.com

11–20 of 44 posts

Re: Show HN: How to compile C/C++ for WASM, pure Clang, no libs, no framework

#11

That is half of what I would need for a project, the other half being Clang itself running in the browser (to use for teaching). In theory there is [1] since many years, but in practice it never worked for me (even now I get "Runtime error: memory access out of bounds"). [1] https://tbfleming.github.io/cib/

Do you know https://webassembly-studio.kamenokosoft.com/ ? I don't know if it compiles in the browser or on a server.

That's fast! But it looks like it still needs a server, and I'd rather avoid giving the internet arbitrary code execution rights to some server I pay for and risk having my bill explode or my account terminated for abuse.

Re: Show HN: How to compile C/C++ for WASM, pure Clang, no libs, no framework

#13
post #7

This looks good! In my experience the hardest part for compiling WebAssembly is third party dependencies. Getting arbitrary libraries to build can be rather challenging.

Getting arbitrary libraries to build is IMO quite often challenging even if you're not compiling for WebAssembly.

Re: Show HN: How to compile C/C++ for WASM, pure Clang, no libs, no framework

#15

This is really awesome, good work! We did a similar thing running Clang on the browser, which is now uploaded to WAPM: https://wapm.io/syrusakbary/clang

Excellent, I wonder if using a two year old LLVM fork is still required, wasm support should be in trunk by now.

Re: Show HN: How to compile C/C++ for WASM, pure Clang, no libs, no framework

#16

Earlier quoted context omitted.

Do you know https://webassembly-studio.kamenokosoft.com/ ? I don't know if it compiles in the browser or on a server.

That's fast! But it looks like it still needs a server, and I'd rather avoid giving the internet arbitrary code execution rights to some server I pay for and risk having my bill explode or my account terminated for abuse.

Choose a supplier with a 100Mbit limit and unlimited bandwidth.

Re: Show HN: How to compile C/C++ for WASM, pure Clang, no libs, no framework

#17

Earlier quoted context omitted.

That's fast! But it looks like it still needs a server, and I'd rather avoid giving the internet arbitrary code execution rights to some server I pay for and risk having my bill explode or my account terminated for abuse.

Choose a supplier with a 100Mbit limit and unlimited bandwidth.

I'm way more worried about ending up hosting miners or other malicious crap, Godbolt himself said users have found all sorts of ways to escape the compiler explorer sandbox over the years. I'd rather serve the compiler as a static blob that runs in the browser.

Re: Show HN: How to compile C/C++ for WASM, pure Clang, no libs, no framework

#18
directly when reading this code I cannot help myself but to get into review-mode. It is an awesome example, which i will probably use myself one day.

However...

inc.cpp:27

Gray is not the average of RGB, it is usally approximated with `Y = 0.299 R + 0.587 G + 0.114 B`.

Re: Show HN: How to compile C/C++ for WASM, pure Clang, no libs, no framework

#19

directly when reading this code I cannot help myself but to get into review-mode. It is an awesome example, which i will probably use myself one day. However... inc.cpp:27 Gray is not the average of RGB, it is usally approximated with `Y = 0.299 R + 0.587 G + 0.114 B`.

Marvelous example of the bikeshed effect
Post reply on HN