Compiler-explorer: Rustc: Would it be possible to support WASM?

Created on 25 Jan 2018  路  4Comments  路  Source: compiler-explorer/compiler-explorer

Compiling with rustc and --target wasm32-unknown-unknown fails because this target is not installed.
Support for WASM and WebAssembly Text Format in the output pane would be great.

enhancement help wanted lang-rust

All 4 comments

It may actually make sense to add other targets like arm, powerpc and co. as well, considering some other languages have those.

It should mostly be fairly trivial to add this as rustc can already cross compile, it just needs a precompiled std which you can get from rustup and co.

It already works if you try hard enough (copying parts of rust's core library, so we don't need a precompiled one). Here's a little rust fibonacci implementation compiled to WebAssembly, AArch64 and PowerPC64 on Godbolt: Godbolt Craziness

Also fun: compiling to JavaScript

@CryZe interesting!
why does it fail with opt-level=0 though?

If you mean the missing panic item error. That's because opt-level=0 has panic paths that would get optimized away otherwise and I didn't copy the panic handling code from libcore / libstd. But I think wasm-unknown-unknown generally has problems with opt-level=0 atm

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattgodbolt picture mattgodbolt  路  4Comments

mathbunnyru picture mathbunnyru  路  4Comments

Sahnvour picture Sahnvour  路  4Comments

CryZe picture CryZe  路  3Comments

valiko-ua picture valiko-ua  路  4Comments