Initial webassembly support via LLVM #36317

Closed
brson opened this Issue Sep 7, 2016 · 2 comments

Projects

None yet

2 participants

@brson
Contributor
brson commented Sep 7, 2016 edited

After a lot of work from a number of people, including @badboy and @tomaka it looks like we're home free. Here's a recent summary. And we still need help, and fast. If you want to volunteer, either say which of these you want to tackle here or on the irlo thread and I'll mark you down.

Immediate tasks to get preliminary asmjs support:

  • ignore-emscripten failing tests
  • Merge the fastcomp squash into the rust llvm fork. It may be worth pushing this to a temporary branch on the assumption that it's not going to land easily in Rust, but I actually think this will go pretty smoothly. rust-lang/llvm#50
  • Land PR in Rust that adds asmjs support with new llvm branch and remaining Rust patches
  • Fix jemalloc being disabled when asmjs is enabled. This causes test failures. liballoc_jemalloc needs to only be disabled for targets that don't support it.
  • Add an auto- builder that builds the asmjs target. We probably won't start testing it right away because testing this target is quite slow.
  • Add a dist- builder to create the asmjs target packages.

The first three here somebody else can pick up. I'll probably need to do the last two.

Remaining tasks:

  • Fix failing tests.
  • Fix compiletest targetting wasm kripken/emscripten#4542
  • Fix the unwinder - the "Patch panic_unwind to compile, but this is surely broken" commit. It's likely this code will look like 32-bit ARM on musl. Unwinding is just completely broken for Rust+emscripten - lots of unimplemented symbols on emscripten side. #36514
  • Error on unimplemented symbols #36515
  • Enable broken std::num tests kripken/emscripten#4543
  • Enable test_estimate_scaling_factor kripken/emscripten#4563
  • Enable checked_next_power of two tests kripken/emscripten#4545
  • Add the wasm32-unknown-emscripten target to rustc. It will be almost the same as the asmjs target (you can literally just grep for "asmjs" and "emcripten" and duplicate the various cfgs). Start with the target specs in mk/cfg and in rustc. For the initial implementation we will not use the wasm llvm backend, but instead use the asmjs backend and ask emcc to convert the asmjs IR to wasm (I don't know how to do this offhand but it's possible - ask in #emscripten). Thusly we will have wasm support.
  • Get asmjs backend working without fastcomp patches #36356
  • Test various cargo projects and report/fix bugs.
  • Create compelling Rust-on-wasm demos. Need to brainstorm here.

Many of the failing tests are for multithreading. Let's not try to tackle that, but there are probably plenty that can be fixed. Adding the wasm target is probably the most fun. Ask in emscripten about how to test it. Having a mind-blowing demo is going to be important for us to bring the thunder alongside the wasm launch.

@brson
Contributor
brson commented Sep 7, 2016

Work on this is happening in this irlo thread.

@bors bors added a commit that referenced this issue Sep 28, 2016
@bors bors Auto merge of #36339 - brson:emscripten-new, r=alexcrichton
Working asmjs and wasm targets

This patch set results in a working standard library for the asmjs-unknown-emscripten and wasm32-unknown-emscripten targets. It is based on the work of @badboy and @rschulman.

It does a few things:

- Updates LLVM with the emscripten [fastcomp](rust-lang/llvm#50) patches, which include the pnacl IR legalizer and the asm.js backend. This patch is thought not to have any significant effect on existing targets.
- Teaches rustbuild to correctly link C code with emscripten
- Updates gcc-rs to work correctly with emscripten
- Teaches rustbuild to run crate tests for emscripten with node
- Modifies Thread::new to return an error on emscripten, to facilitate debugging a common failure mode
- Modifies libtest to run in single-threaded mode for emscripten
- Ignores a host of tests that don't work yet, mostly dealing with threads and I/O
- Updates libc with wasm32 definitions (presently the same as asmjs)
- Adds a wasm32-unknown-emscripten target that feeds the output of LLVM's asmjs backend through emcc to generate wasm

Notes and caveats:

- This is only known to work with `--enable-rustbuild`.
- The wasm32 target can't be tested correctly yet because of issues in compiletest and limitations in node kripken/emscripten#4542, but hello.rs does seem to work when run on node via the binaryen interpreter
- This requires an up to date installation of the emscripten sdk from its incoming branch
- Unwinding is very broken
- When enabling the emscripten targets jemalloc is disabled for all targets, which results in test failures for the host

Next steps are to fix the jemalloc issue, start building the two emscripten targets on the auto builders, then start producing nightlies.

#36317 tracks work on this.

Fixes #36515
Fixes #36515
ebd61d6
@bors bors added a commit that referenced this issue Oct 1, 2016
@bors bors Auto merge of #36339 - brson:emscripten-new, r=alexcrichton
Working asmjs and wasm targets

This patch set results in a working standard library for the asmjs-unknown-emscripten and wasm32-unknown-emscripten targets. It is based on the work of @badboy and @rschulman.

It does a few things:

- Updates LLVM with the emscripten [fastcomp](rust-lang/llvm#50) patches, which include the pnacl IR legalizer and the asm.js backend. This patch is thought not to have any significant effect on existing targets.
- Teaches rustbuild to correctly link C code with emscripten
- Updates gcc-rs to work correctly with emscripten
- Teaches rustbuild to run crate tests for emscripten with node
- Modifies Thread::new to return an error on emscripten, to facilitate debugging a common failure mode
- Modifies libtest to run in single-threaded mode for emscripten
- Ignores a host of tests that don't work yet, mostly dealing with threads and I/O
- Updates libc with wasm32 definitions (presently the same as asmjs)
- Adds a wasm32-unknown-emscripten target that feeds the output of LLVM's asmjs backend through emcc to generate wasm

Notes and caveats:

- This is only known to work with `--enable-rustbuild`.
- The wasm32 target can't be tested correctly yet because of issues in compiletest and limitations in node kripken/emscripten#4542, but hello.rs does seem to work when run on node via the binaryen interpreter
- This requires an up to date installation of the emscripten sdk from its incoming branch
- Unwinding is very broken
- When enabling the emscripten targets jemalloc is disabled for all targets, which results in test failures for the host

Next steps are to fix the jemalloc issue, start building the two emscripten targets on the auto builders, then start producing nightlies.

#36317 tracks work on this.

Fixes #36515
Fixes #36515
Fixes #36356
8b00355
@sanxiyn sanxiyn added the A-wasm label Dec 30, 2016
@brson
Contributor
brson commented Jan 3, 2017

Closing this out-dated tracking issue.

@brson brson closed this Jan 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment