How to build LLVM Debian/Ubuntu packages from source?
Building the latest nightly snapshot

The latest nightly snapshot can be built with the following steps. First, ensure you add to your apt.sources the nightly repositories for your distribution.

Use apt-get to retrieve the sources of the llvm-toolchain-snapshot package,

$ mkdir build/ && cd build/
$ apt-get source llvm-toolchain-snapshot

This should download all the original snapshot tarballs, and create a directory named llvm-toolchain-snapshot-X.Y~++202.... Depending on the last update of the jenkins nightly builder, the snapshot version number and git hash will vary.

Then install the build dependencies,

$ sudo apt-get build-dep llvm-toolchain-snapshot

On older versions of Ubuntu, some build dependencies cannot be satisfied because the required gcc versions are missing. To fix this issue you should add the Ubuntu Toolchain PPA to your system before executing the above command.

Once everything is ready, enter the directory and build the package,

$ cd llvm-toolchain-snapshot-X.Y~++202*/
$ debuild -us -uc -b

Building a snapshot package by hand

In some cases you may want to build a snapshot package manually. For example to debug the Debian package scripts, or to build a package for a specific development branch. In that scenario, follow the following steps:

  1. Clone the llvm-toolchain source package.

    The source package is maintained in git, you can retrieve it using the debcheckout command,

    $ git clone -b snapshot snapshot

  2. Retrieve the latest snapshot and create original tarballs.

    Run the script,

    $ sh snapshot/debian/

    which will retrieve the latest version for each LLVM subproject (llvm, clang, lldb, etc.) from the git repository and repack it as a set of tarballs.

  3. Unpack the original tarballs and apply quilt Debian patches.

    run the script,

    $ sh snapshot/debian/

    which will unpack the source tree inside a new directory such as branches/llvm-toolchain-snapshot_X.Y~++200*. Depending on the current snapshot version number and git hash, the directory name will be different. Quilt patches will then be applied.

  4. Build the binary packages using,

    $ debian/rules binary

    When debugging, successive builds can be recompiled faster by using tools such as ccache (PATH=/usr/lib/ccache:$PATH debian/rules binary).

Retrieving a specific branch or release candidate with

When using, if you need to retrieve a specific branch, you can pass the branch name as the first argument. For example, to get the 13 release branch at you should use,

$ sh 13/debian/ release/13.x

To retrieve a specific release candidate, you can pass the branch name as the first argument, and the tag rc number as the second argument. For example, to get the 13.0.1 release candidate rc3 at you should use,

$ sh 13/debian/ 13.0.1 rc3

Organization of the repository

The Debian package for each LLVM point release is maintained as a separate git branch. For example, the 3.8 release lives at 3.8.

The current snapshot release is maintained at branches/snapshot.

Organization of the repository

Clone all branches

for f in 4.0 5.0 6.0 7.0 snapshot; do
git clone -b $f $f;

Additional maintainer scripts

The script that is found at the root should be used to quickly test a newly built clang package. It runs a short set of sanity-check tests.

The script releases/snapshot/debian/ is used when preparing a new point release. It automatically replaces version numbers in various files of the package.

Contact: Sylvestre Ledru
Build infra by IRILL / Hosting by LLVM Foundation