Skip to content


Switch branches/tags
This branch is 55 commits ahead, 159 commits behind JuliaComputingOSS:master.

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


The resurrected LLVM "C Backend", with improvements.


My primary goal is to have a backend I can use for this project:

Github: Blogpost: Demo:

In one word, it's a compiler from the D programming language to Javascript (asmjs).

The LLVM frontend for the D programming language, aka LDC, generates valid bitcode that JuliaComputing/llvm-cbe can't process (it generates uncompilable C code). (It seems that the JuliaComputing/llvm-cbe was only tested with bitcode inputs that were generated by clang)

Moreover, the project in its current state needs a lot of cleaning, its merely consists of one huge source file and uses heavy C++ syntax that isn't required anymore, and the test suite is hard to use.

So my goal here is to have a codebase:

  • that has no bugs blocking the dscripten project.
  • that works with a recent version of LLVM (at the moment 3.9, vs JuliaComputing/llvm-cbe which requires LLVM 3.7)
  • that can be compiled out of the LLVM tree (as long as there's one llvm-config in the PATH).
  • that has a trustable suite of tests which directly feed llvm-cbe with deterministic LLVM bitcode (instead of relying on clang code generation, as JuliaComputing/llvm-cbe does).
  • that don't require compromises on code cleanliness.
  • whose output is standard ISO C99 code, instead of relying on the specifics of some compilers.


This version of the LLVM-CBE library works with LLVM 3.9. You will have to compile this version of LLVM before you try to use LLVM-CBE. This guide will walk you through the compilation and installation of both tools and show usage statements to verify that the LLVM-CBE library is compiled correctly.

The library is known to compile on various Linux versions (Redhat, Mageia, Ubuntu, Debian), Mac OS X, and Windows (Mingw-w64).

Step 1a: Installing LLVM manually

LLVM-CBE currently requires LLVM 3.9 to be installed somewhere on your system, and that the corresponding "llvm-config" be in your PATH. (only LLVM is needed, not clang).

The first step is to compile LLVM on your machine:

$ cd $HOME
$ git clone
$ cd llvm
$ git checkout release_39
$ ./configure
$ make
$ make install

At this point, you should have llvm-config in your path:

$ llvm-config --version

Step 1b: Install LLVM from repositories

Alternatively, a LLVM installed some other way can be used, e.g. installing the Debian packages. Be aware that some distributions will suffix the 'llvm-config' program with LLVM version, e.g 'llvm-config-3.9'. In this case, you will need to set the environment variable LLVM_CONFIG so the makefile knows which program to call. Example:

$ export LLVM_CONFIG=llvm-config-3.9

Step 2: Compiling LLVM-CBE

Next, download and compile llvm-cbe:

$ cd $HOME
$ git clone llvm-cbe
$ cd llvm-cbe
$ make

Step 3: Usage Examples

Once llvm-cbe is compiled, you can run it with the following command.

$ bin/llvm-cbe main.ll -o=main.cbe.c
$ gcc -w main.cbe.c -o main.exe
$ ./main.exe

Run the test suite

$ ./check

This will trigger the build and run the tests.


resurrected LLVM "C Backend", with improvements







No releases published


No packages published


  • C++ 66.3%
  • C 28.6%
  • Makefile 1.9%
  • LLVM 1.4%
  • Shell 0.9%
  • Python 0.8%
  • CMake 0.1%