Cheerp 2.6 rc1: C++ compiled for the Web

Carlo Piovesan
Nov 30, 2020 · 6 min read

Today we are proud to announce that we are close to finalizing the release of Cheerp 2.6.

Many improvements have been added to Cheerp in the last 8 months (compared to the previous release) by our team, and now it’s all packaged to be used on the C/C++ codebases you have at hand.

In this post, I will go through the new features of Cheerp 2.6, how to use it, and present some benchmarks and live examples.

What’s Cheerp?

The JavaScript support allows for easy and powerful interoperability with other JavaScript interfaces, like browser APIs, JavaScript libraries and HTML/DOM elements.

Applications compiled with Cheerp are compact and performant (see benchmarks later in the article) and can be executed sandboxed by the client browser locally, without requiring any server components but only serving 2 static files.

Cheerp supports all modern browsers (even Internet Explorer 11 thanks to an opt-in asmjs-based solution), with the possibility of enabling WebAssembly extensions by command line.

What’s new? JSExport

Free standing functions can be exported with a wider range of parameter kinds, and now also classes and namespaces can be exported.

JSExport, as in JavaScript Export, is a unique feature of Cheerp, that allows to specify an interface in an expressive and easy to maintain way, since all information is stored in one place: your codebase.

Using JSExport it’s just a matter of adding the tag [[cheerp::jsexport]] to the definition of all relevant classes and functions.

(original article: link)

What’s new? Delayed Int64 lowering

This allowed many improvements of the WebAssembly backend, to name two major ones: a speed-up of 64 bit math-intensive workloads, and an improved code generation of the memset/memcpy/memmove intrinsics (from 4 byte/instruction to 8 byte/instruction).

For code targeting JavaScript, the delayed lowering now allows BigInt to be used whenever supported, allowing also 64 bit integers at the JS-Wasm interface in certain conditions. For the JavaScript-side improvements, they could be opted-in passing the command line flag: -cheerp-use-bigints.

(original article: link)

What’s new? ExternRef

ExternRef it’s an important stepping stone toward a full fledged garbage collection in WebAssembly (see proposal).

(original article: link)

What else is new?

More information can be found on our github repos.

Cheerp is a LLVM-based compiler, leveraging plenty of state of the art optimizations available there. Cheerp is currently based on clang 9.0, and supports the C++17 standard.

How to try it out

How to upgrade your project to Cheerp 2.6

make clean && make && make install

You should now experience a smaller footprint and improved performance without any change required neither on your codebase nor in the way your code is built or integrated.

You can also now enjoy the newer JSExport capabilities, we recommend to start from the main article about it.

This release will be a month long process where we will both gather feedback from our users and do additional rounds of testing, fixing any problem that might emerge in the process, before finalizing version 2.6.


We focus our attention on the four bigger and more complex benchmarks:

  • Box2d: a 2D rigid body simulation library
  • Bullet: a 3D physics engine which simulates collision detection, soft and rigid body dynamics
  • Zlib: a lossless data compression library
  • Lzma: another lossless data compression library

We compared with the latest Emscripten release, 2.0.9.


Interactive charts available here, raw data here.

In all these test cases comparing the sum of the JavaScript and WebAssembly components shows Cheerp’s output is on average 3% smaller than Emscripten’s output.


Charts available here: SpiderMonkey or V8. Raw data here: SpiderMonkey or V8

These numbers have been extrapolated on a single benchmark environment (MacBook Pro, Linux x86_64, TurboBoost disabled), and averaged across three repetitions. Similar results hold on all of our benchmark machines.

Cheerp’s outputs outperform Emscripten’s outputs by roughly 5%.

Why Cheerp?

Cheerp allows developers to code in an expressive and easy to maintain way, enabling tightly couple interactions of WebAssembly’s number crunching capabilities and JavaScript flexibility and rich ecosystem.

Cheerp is a combination of an industry standard compiler (clang) with its own state-of-the-art optimization passes (PreExecuter, Registerize, GEPOptimizer, CFGStackifier, Devirtualization, and various others).

Cheerp is tried and tested on extremely complex code bases, and is backed by a strong technical team that can provide support and advice.

Cheerp in use

They took a complex C++ codebase and compiled it for the Web, allowing to offer a more responsive and easier to manage cross platform solution to 3D cad.

Cheerp is also the cornerstone of two other tools developed at Leaning Technologies:

  • CheerpJ, a solution to run any Java application or legacy Java applet client-side in the browser . CheerpJ leverages Cheerp’s JavaScript generation capabilities in its own internal custom compiler.
  • CheerpX, an extremely efficient solution to run unmodified x86 binaries in the browser thanks to a fast JIT that generates Wasm modules at runtime. CheerpX leverages Cheerp, with its advanced JavaScript/WebAssembly interoperability and state-of-the-art codegen.
CheerpJ (for Java), Cheerp (for C++), CheerpX (for x86 and Flash)


We monitor browsers compliance (eg. on WebKit or V8), we support and participate in WebAssembly standardization (eg. our proposal for branch-hinting), and we develop and evolve three unique WebAssembly+JavaScript based solutions: Cheerp, CheerpJ and CheerpX.

With Cheerp 2.6, we deliver a mature tool that allows to unlock your C++ code bases and bring them to the Web. Update your Cheerp version, or try it for the first time getting started on our documentation.

Get in touch either on the developers Gitter channel, signalling issues on Github, or get in contact with our customer support to discuss how Cheerp can bring your code to any browser.

Follow us on twitter and on our website For additional technical information on Cheerp, please visit our wiki or our tech blog.


Leaning Technologies' Blog - everything Cheerp, CheerpJ…