Support of LLVM

Let me introduce my new plugin ‘cpp-llvm’.

It allow to start working with LLVM framework in a very simple way.

  • No need to download sources.
  • No need to build it.
  • No need to use CMake.
  • No need to play with build scripts to obtain expected behavior.

Just add these lines to Gradle build script and you will have build with LLVM:

plugins {
    id 'org.bitbucket.akornilov.cpp-llvm' version '0.1'

llvm {
    version = '9.0.0' // Required version.


  • Java
  • Gradle (I used the latest version for now 5.6.2 and don’t check older versions).
  • gcc/clang on Linux
  • msvc 2019 on Windows
  • ‘cpp-application’ or ‘cpp-library’ Gradle plugin.

Supported versions of LLVM:

  • 9.0.0

  • 8.0.0
    Unofficial builds for x86_64 on Windows with MSVC 2019 and Linux (built on Debian 10.0 with CLang v10.0). Also, RTTI and exceptions are enabled on those builds. There are two build variants for each platforms: Debug and Release.

  • 7.1.0

  • 7.0.1

  • 7.0.0

  • 6.0.1

  • 6.0.0

  • 5.0.2

  • 5.0.1

  • 5.0.0

  • 4.0.1

  • 4.0.0

  • 3.9.1

  • 3.9.0

  • 3.8.1

  • 3.8.0

  • 3.7.1

  • 3.7.0

  • 3.6.2

  • 3.6.1

  • 3.6.0

  • 3.5.2

  • 3.5.1

  • 3.5.0

  • 3.4.2

  • 3.4.1

  • 3.4

  • 3.3

  • 3.2

  • 3.1

  • 3.0
    Only x86_64 Linux. Official builds from LLVM server without RTTI and exceptions.

To see a list of supported versions for the current environment please use the following command:

gradle llvmVersions

> Task :llvm-app:llvmVersions

1 actionable task: 1 executed

All LLVM builds binaries will be downloaded and extracted into Gradle local cache (user folder) and will be shared between different applications builds.

Note: Only static linking is supported because creating a shared library (DLL) of LLVM is not supported on Windows for MSVC (strange LLVM build scripts restriction).

Another configuration options of the plugin:

You can specify a particular URL to download:

llvm {
    version = '7.0.1'
    serverUrl = ''

Make sure that the specified version of LLVM is the same with the version which will be downloaded from the URL. Otherwise, the configuration of the build might be incorrect.

You can work offline with already downloaded or manual built binaries:

llvm {
    version = '7.0.1'
    localPath = '<path to unpacked LLVM build>'

In this case, nothing will be downloaded from a net.

Make sure that the specified version of LLVM is the same as the version of the local binaries. The plugin assumes to have ‘lib’ and ‘include’ directories inside the specified path.

Specify particular components to linking:

llvm {
    version = '9.0.0'
    components = ['Engine', 'OrcJIT']

Potentially, decrease of libraries for linking might improve linking time especially for static linking in as in our case.

If none of the components are chosen default component ‘all’ will be used.

To see the whole list of supported components you can use this command:

gradle llvmComponents


The libraries of LLVM in Debug variant are huge and as a result linking time is big. If you don’t really need binary with debug information of LLVM itself you can use this option (forceReleaseLinux):

llvm {
    version = '9.0.0'
    forceReleaseLinux = true

This affects only Linux builds and can improve linking time (and size of download archive will be less). Unfortunately, MSVC 2019 doesn’t allow to mix debug and release object files within the build and we have to use debug variant.

Also, I recommend to use my other plugins together :slight_smile: :

plugins {
    id 'cpp-application'
    id 'org.bitbucket.akornilov.cpp-build-tuner' version '0.7'
    id 'org.bitbucket.akornilov.cpp-llvm' version '0.1'
    id 'org.bitbucket.akornilov.cpp-ide-generator' version '0.5'

Using them can optimize the build procedure and decrease the size of the final binary (cpp-build-tuner). And on the other hand, you have integration with different IDEs from a box by a single command: gradle generateIde. IDE will have a path to all LLVM include files and can indexing it.

Possible troubles:

FAILURE: Build failed with an exception.

* What went wrong:

A problem occurred configuring project ':llvm-app'.

> Cannot change dependencies of configuration ':llvm-app:cppCompileDebug' after it has been resolved.

This means that you should place ‘cpp-ide-generator’ after ‘cpp-llvm’ as in the example above.

A full example of LLVM demo application you can found here:

Version 0.3 was released:

  1. Task llvmCleanCache was added. The task performs clean of local user cache with LLVM downloads.

  2. A shared linkage was implemented. Only version LLVM 9.0.0 for GCC, MinGW-W64, and MSVC is supported at the moment.

    llvm {
         version = '9.0.0'
         linkage = Linkage.SHARED

In connection with changing project’s hosting the plugins were moved in another group:

plugins {
    id 'loggersoft.cpp-llvm' version '0.5'

Project URL: