commit | 3905550b49c2e0a7ddff53e9a798713f0f50c637 | [log] [tgz] |
---|---|---|
author | Alon Zakai <azakai@google.com> | Thu Jul 11 18:30:50 2024 |
committer | GitHub <noreply@github.com> | Thu Jul 11 18:30:50 2024 |
tree | d998a83955ae4ec2a3732eb18cc5c54fcfa78693 | |
parent | daf5b264706d7835e6c8d16c805d35ede59e4ece [diff] |
Use Binaryen StackIR at the end of the pipeline (#22218) Before this PR, if we did -O3 then we ended up doing this: * wasm-opt -O3 * wasm-metadce * wasm-opt --minify-imports-and-exports The first invocation uses StackIR (which is enabled by default in -O3), but then the later invocations "lose" those optimizations, since they read the wasm binary and generate structured BinaryenIR once more. We would need to do StackIR opts again, but even more, we'd need to do work to undo the effects of stackiness, which can lead to more locals and such, see #22196 After this PR, we do this: * wasm-opt -O3 --no-stack-ir * wasm-metadce * wasm-opt --minify-imports-and-exports --optimize-stack-ir The first command is now told to not use StackIR. The second remains unchanged. The last then does StackIR optimizations. This is the same amount of work (we just shuffle around the StackIR opts), so compile times are unaffected, but we gain some code improvements. To see them, see the commit before last which applies the size changes on top of a recent rebase. Many tests improve by small but noticeable amounts, though two wasm2js tests somehow lose by a few bytes, which I think is noise. There is a slight code complexity downside here, but given this avoids corner cases that may be quite annoying (#22196) it seems worthwhile. Also improve our handling of --emit-symbol-map to use llvm-objcopy, which avoids wasm-opt roundtrip issues (this is necessary in this commit as otherwise the improvements of this PR are undone by that roundtrip, which was caught by a test).
Main project page: https://emscripten.org
Chromium builder status: emscripten-releases
Emscripten compiles C and C++ to WebAssembly using LLVM and Binaryen. Emscripten output can run on the Web, in Node.js, and in wasm runtimes.
Emscripten provides Web support for popular portable APIs such as OpenGL and SDL2, allowing complex graphical native applications to be ported, such as the Unity game engine and Google Earth. It can probably port your codebase, too!
While Emscripten mostly focuses on compiling C and C++ using Clang, it can be integrated with other LLVM-using compilers (for example, Rust has Emscripten integration, with the wasm32-unknown-emscripten
and asmjs-unknown-emscripten
targets).
Emscripten is available under 2 licenses, the MIT license and the University of Illinois/NCSA Open Source License.
Both are permissive open source licenses, with little if any practical difference between them.
The reason for offering both is that (1) the MIT license is well-known and suitable for a compiler toolchain, while (2) LLVM‘s original license, the University of Illinois/NCSA Open Source License, was also offered to allow Emscripten’s code to be integrated upstream into LLVM. The second reason became less important after Emscripten switched to the LLVM wasm backend, at which point there isn't any code we expect to move back and forth between the projects; also, LLVM relicensed to Apache 2.0 + exceptions meanwhile. In practice you can just consider Emscripten as MIT licensed (which allows you to do pretty much anything you want with a compiler, including commercial and non-commercial use).
See LICENSE
for the full content of the licenses.