binaryen  by WebAssembly

Compiler/toolchain library for WebAssembly

created 9 years ago
8,011 stars

Top 6.6% on sourcepulse

GitHubView on GitHub
Project Summary

Binaryen is a C++ compiler and toolchain infrastructure library for WebAssembly, designed to make WebAssembly generation, optimization, and manipulation efficient and accessible. It serves as a backend for various language toolchains (Rust, Kotlin, Dart, etc.) and provides standalone tools for WebAssembly processing, targeting developers and researchers working with WebAssembly.

How It Works

Binaryen utilizes a custom C++ Intermediate Representation (IR) that closely mirrors WebAssembly's structure, facilitating fast conversion to and from the WebAssembly binary format. This IR is tree-based, allowing for efficient parallel optimization passes. It also supports a "Stack IR" for optimizations tailored to WebAssembly's stack-based nature. Binaryen's design prioritizes speed and effectiveness, enabling advanced WebAssembly-specific optimizations akin to minification for other web assets.

Quick Start & Requirements

  • Install: Build from source using CMake and a C++17 compiler. git submodule update --init && cmake . && make
  • Prerequisites: C++17 compiler, CMake. Optional: gtest for tests.
  • Build Time: Estimated 5-15 minutes depending on hardware.
  • Docs: https://github.com/WebAssembly/binaryen

Highlighted Details

  • wasm-opt: A powerful command-line tool for optimizing WebAssembly modules, offering numerous passes for size and speed improvements.
  • Toolchain Integration: Used by Emscripten, wasm-pack, Kotlin/Wasm, and others.
  • wasm2js: Compiles WebAssembly to JavaScript.
  • wasm-merge: Bundles multiple WebAssembly modules into a single file.
  • Source Map Support: Can read and write source maps for debugging.

Maintenance & Community

Binaryen is a core component of the WebAssembly ecosystem, with contributions from major players like Google and Mozilla. It is actively maintained. Community channels are not explicitly listed in the README, but development activity is visible on GitHub.

Licensing & Compatibility

Binaryen is released under the Apache 2.0 license, which is permissive and allows for commercial use and integration into closed-source projects.

Limitations & Caveats

Binaryen's IR has minor differences from the official WebAssembly text format, particularly regarding s-expressions and handling of unreachable code, which can lead to slight differences in round-tripped text output. Some optimizations may not perfectly preserve DWARF debug info.

Health Check
Last commit

1 day ago

Responsiveness

1 day

Pull Requests (30d)
67
Issues (30d)
22
Star History
200 stars in the last 90 days

Explore Similar Projects

Starred by Andrej Karpathy Andrej Karpathy(Founder of Eureka Labs; Formerly at Tesla, OpenAI; Author of CS 231n), Tim J. Baek Tim J. Baek(Founder of Open WebUI), and
5 more.

gemma.cpp by google

0.1%
7k
C++ inference engine for Google's Gemma models
created 1 year ago
updated 1 day ago
Feedback? Help us improve.