Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support lld on pure wasm backend #2

Closed
aturon opened this issue Jan 10, 2018 · 9 comments
Closed

Support lld on pure wasm backend #2

aturon opened this issue Jan 10, 2018 · 9 comments

Comments

@aturon
Copy link
Contributor

aturon commented Jan 10, 2018

Currently we avoid the need for any linked on wasm32-unknown-unknown, by combining all Rust code into a single compilation unit. This allows us to work around the immaturity of the lld story for wasm, but at the cost of compile times. This issue tracks the status of the lld readiness and rustc's ability to use it.

@alexcrichton
Copy link
Contributor

Awhile back I filed https://bugs.llvm.org/show_bug.cgi?id=35369 with at least one cause of "we can't use lld vanilla upstream". There's a whole lot more issues to solve here, but that's at least one concrete actionable one :)

@pepyakin
Copy link
Member

JFYI Experimental LLD support has been landed in Emscripten

WebAssembly/binaryen#1346
emscripten-core/emscripten#6056

@alexcrichton
Copy link
Contributor

I've tested on top of the LLVM 6 upgrade (plus a bit farther on LLVM for a few more patches) with LLD master and everything looks to be working beautifully! Once https://reviews.llvm.org/D42511 lands we won't even need wasm-gc any more, yay!

@alexcrichton
Copy link
Contributor

Ok I've now completed a test run of our entire test suite using LLD to link wasm binaries together. Specifically I was using llvm-mirror/lld@95a9b67 with https://reviews.llvm.org/D42511 applied manually (but that probably wasn't necessary), llvm-mirror/llvm@d14b8f6, and alexcrichton/rust@106657e.

I believe the sequence of steps here are now:

  • Wait for LLVM 6 - rustc: Upgrade to LLVM 6 rust-lang/rust#47828
  • Add lld as a submodule (turned off by default) in the rust-lang/rust repository.
  • Add build system support to build LLD and make its binary available to rustc to run
  • Probably upgrade LLVM again (but a much smaller one) necessary to get LLD building
  • Land something along the lines of alexcrichton/rust@106657e in rustc to switch wasm's default linker.

I'd hope we can just switch the defaults overnight and not worry about maintaining the old "LTO everything" link mode. There'll proably be bugs but likely nothing that's too hard to backport!

@alexcrichton
Copy link
Contributor

Ok I got a little excited and I've now implemented all of this -- alexcrichton/rust@cbf406f

Once LLVM 6 lands I'll send that as a PR and we should be able to switch to LLD pronto.

@alexcrichton
Copy link
Contributor

PR for this

@alexcrichton
Copy link
Contributor

Landed!

@alexcrichton
Copy link
Contributor

alexcrichton commented Mar 6, 2018

FWIW as a testament to the improvements brought about by LLD related to build times, the wasm32-unknown-unknown builder we have in rust-lang/rust reduced from 1h53m per build to 1h10m per build when this landed, a huge reduction in our build times!

@mgattozzi
Copy link
Contributor

Wow that's a huge reduction. Shaving 40+ minutes off is not a trivial gain at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants