Skip to content
Fork of LLVM with modifications to support a program repository
C++ LLVM C Assembly HTML Python Other
Branch: master
Clone or download
This branch is 280 commits ahead, 38959 commits behind llvm:master.

LLVM with Program Repository Support

Commit Tests

This git repository contains a copy of LLVM (forked from llvm/llvm-project@7b556541 with work-in-progress modifications to output to a Program Repository.

The changes are to add support for the program repository that was first shown at the 2016 US LLVM Developers’ meeting in the talk catchily titled “Demo of a repository for statically compiled programs”. You can relive the highs and lows by watching it on YouTube. The early implementation demonstrated there has its own Github repository. This repository implements the same thing in LLVM to give you the anticipated build-time improvements in a C++ compiler targeting Linux. This implementation was the subject of a lightning talk at 2019 Euro LLVM Developers' meeting, also available on YouTube. Further documentation can be found on the project wiki.

Building the Compiler

The process to follow is similar to that for a conventional build of Clang+LLVM, but with an extra step to get the pstore back-end.

  1. Clone llvm-project-prepo (this repository):

    git clone
  2. Clone pstore:

    cd llvm-project-prepo
    git clone
    cd -

    Ultimately, we envisage supporting multiple database back-ends to fit different needs, but there’s currently a hard dependency on the pstore (“Program Store”) key/value store as a back-end.

  3. Build LLVM as normal enabling the clang and pstore subprojects (e.g.):

    mkdir build && cd build

Using the Program Repository


The program-repository is implemented as a new object-file format (“repo”) in LLVM. To use it, you need to request it explicitly in the target triple:

clang -target x86_64-pc-linux-gnu-repo -c -o test.o test.c

Note that this is the only triple that we’re currently supporting (i.e. targeting X86-64 Linux).

Furthermore, the path to the program-repository database itself is set using an environment variable REPOFILE; it that variable is not set, it defaults to ./clang.db (eventually, you’d expect to be able to specify this path with a command-line switch).

The command-line above will write the object code for test.c to the program-repository and emit a “ticket file” test.o. This tiny file contains a key to the real data in the database.


A program-repository aware linker is very much on the project’s “TODO” list. Until that happens, there's a repo2obj tool in the project tree. This generates a traditional ELF file from a repository ticket file. Using it is simple:

clang -target x86_64-pc-linux-gnu-repo -c -o test.o test.c
repo2obj test.o -o test.o.elf

The first step compiles the source file test.c to the repository, the second will produce a file test.o.elf which can be fed to a traditional ELF linker.

clang -o test test.o.elf

The LLVM Compiler Infrastructure

This directory and its subdirectories contain source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and runtime environments.

You can’t perform that action at this time.