Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Squash of fastcomp commit 4105790f1549808c1f1daa5250b4ada5f41a5c02 #50

Merged
merged 2 commits into from
Sep 7, 2016

Conversation

brson
Copy link

@brson brson commented Sep 6, 2016

This is the entire content of the emscripten fastcomp LLVM fork, which it uses to generate asm.js and which can also be used to generate wasm. By importing this into our tree we can do the same, by emitting LLVM IR that emscripten's emcc compiler understands.

The vast majority of the code here belongs to the pnacl IR legalizer and to the asmjs backend, though there are a few bits that touch common code. As such, I expect this to be relatively easy to maintain, the maintenance model being:

  • When either Rust or emscripten need to upgrade LLVM, we do it at the same time. This can involve some experimentation to find a commit that works for both of us.
  • We squash their entire commit history after their merge base into one, giving it a name containing the sha of their head commit, then cherry pick it onto our patch set.
  • If ever the upgrade becomes too difficult we can just exclude the fastcomp patch and temporarily drop asmjs/wasm support.

The only reason I expect emscripten to need to upgrade LLVM in the future is to move to the upstream wasm backend, which we will also want. So there is in fact the possibility we will be looking forward to quite a bit of llvm churn in the near future.

Once the LLVM wasm backend is complete we can consider dropping this patch, though at that time will either need to also drop asm.js support or invest considerable effort into a wasm2asmjs code path.

Once this is merged and the libc patches for wasm merged, I will submit a patch to Rust adding more-or-less working asmjs/wasm32 targets.

r? @alexcrichton

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive
Copy link

warning Warning warning

  • Pull requests are usually filed against the master branch for this repo, but this one is against rust-llvm-2016-07-09. Please double check that you specified the right target!

// is quite desirable.
if (isSplat || newMask == LHSMask || newMask == RHSMask || newMask == Mask ||
true)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems pretty suspicious in the sense that it's a change made with the assumption that LLVM is only generating asmjs. I wonder if we should back this out?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked with @sunfish and we can revert this with little performance impact on asmjs. I will do so.

@brson
Copy link
Author

brson commented Sep 7, 2016

@alexcrichton I've added a patch to revert two of the changes and determined that the others should not affect us.

@alexcrichton
Copy link
Member

Tally ho!

@alexcrichton alexcrichton merged commit c3bfb2c into rust-lang:rust-llvm-2016-07-09 Sep 7, 2016
bors added a commit to rust-lang/rust that referenced this pull request Oct 1, 2016
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 emscripten-core/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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants