Stream: general

Topic: C++ to wasm and Cranelift IR


view this post on Zulip Divya Agrawal (Mar 18 2020 at 06:12):

Hello all, I am new to Wasm and Cranelift and wanted to play with it with C++ code. I am trying to compile the C++ code to wasm and also to cranelift IR. I read few documents and saw that C++ exception handling and threads in Wasm are still in development/proposal phase. Given that would it be right to think about replacing the JVM jit environment with wasm at the moment ? Also any concrete starting points in that direction would be really appreciated. TIA.

view this post on Zulip Dan Gohman (Mar 18 2020 at 11:23):

Exception handling and threads for WebAssembly are both stage 2 proposals right now. Follow the links on that page for more info.

view this post on Zulip Dan Gohman (Mar 18 2020 at 11:25):

Whether or not wasm is a suitable replacement for the JVM depends greatly on how you want to use it. If you need exception handling and threads, then it's not all the way there yet.

view this post on Zulip Divya Agrawal (Mar 18 2020 at 11:28):

Hi Dan, thanks a lot for your comments. Any other starting points for C++ to wasm ?

view this post on Zulip Dan Gohman (Mar 18 2020 at 11:33):

Are you interested in wasm in browsers, outside of browsers, or both?

view this post on Zulip Divya Agrawal (Mar 18 2020 at 11:34):

outside of browsers

view this post on Zulip Dan Gohman (Mar 18 2020 at 11:36):

wasi-sdk has packages of clang for C/C++ configured to work with wasi-libc and builds of libc++

view this post on Zulip Dan Gohman (Mar 18 2020 at 11:36):

https://github.com/WebAssembly/wasi-sdk

WASI-enabled WebAssembly C/C++ toolchain. Contribute to WebAssembly/wasi-sdk development by creating an account on GitHub.

view this post on Zulip Julian Seward (Mar 18 2020 at 11:40):

Dan, is that also available for arm64-linux? It would be useful (for current dev work) if it was. Currently we have to compile C++ to wasm on an x86 box and then scp it to an arm64 box for testing, which is, well, something that would be nice to be able to avoid.

view this post on Zulip Dan Gohman (Mar 18 2020 at 11:48):

Unfortunately no, we don't have precompiled packages for arm64 yet.

view this post on Zulip Dan Gohman (Mar 18 2020 at 11:49):

If you build it from source, it ought to work though.

view this post on Zulip Joey Gouly (Mar 18 2020 at 11:51):

and rust/cargo should work

view this post on Zulip Julian Seward (Mar 18 2020 at 12:04):

@Joey Gouly sure, but I really would prefer to start with C test cases.

view this post on Zulip Julian Seward (Mar 18 2020 at 12:06):

@Dan Gohman do you happen to know if building from source is a complex process (mucho hoop jumping?) Or is it something nice like ./configure ; make ; make install?

view this post on Zulip Dan Gohman (Mar 18 2020 at 12:09):

It's a pretty simple process in theory: check out wasi-sdk, init the git submodules, run "make", you now have /opt/wask-sdk/bin/clang etc. and are good to go

view this post on Zulip Dan Gohman (Mar 18 2020 at 12:16):

Set PREFIX=... on the make invocation if you want it to build somewhere else.

view this post on Zulip Julian Seward (Mar 18 2020 at 12:17):

@Dan Gohman thanks! I'll give it a try.


Last updated: Nov 26 2024 at 00:12 UTC