Menu

cpp-llvm

llvm (1) c++ (2)
Alexander Kornilov

Purpose

The plugin 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.

Required plugins

The cpp-llvm require to work another Gradle core plugins: cpp-application/cpp-library/cpp-unit-test.

Usage

plugins {
    id 'cpp-application'
    id 'loggersoft.cpp-llvm' version '2.2'
}

Supported versions

  • 13.0.0
  • 12.0.0
  • 11.0.0 - please see the note below regarding the shared library version for the Windows platform since this release.
  • 10.0.0
  • 9.0.1
  • 9.0.0 - shared and static linkage is supported for this version and above.
  • 8.0.0
    Unofficial builds for x86_64 on Windows and Linux. Also, RTTI and exceptions are enabled on those builds. There are two build variants for each platforms: Debug and Release.
    See llvm-binaries.

  • 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.

Note

Since version 11.0.0 total number of exported symbols reached the limit for Windows PE DLL file format which has an obsolete 16-bit capacity of slot where stored total exports number (restricted within 65535).
https://developercommunity.visualstudio.com/content/problem/220174/fix-msvc-65535-symbol-limit-in-lib-files-lnk1189.html

In this context from Windows DLL files (MSVC/MinGW) were excluded several rarely used targets:

  • 13.0.0 + AMDGPU.
  • 12.0.0 + Hexagon, MSP430, Mips and RISCV.
  • 11.0.0 Sparc, PowerPC and SystemZ.

Linux version and static version of LLVM for Windows the same as before contains all targets without any excludes.

In versions 11.0.0 and 12.0.0 in Windows Debug builds (msvc) statistic collection is disabled in ADT/Statistic.h (LLVM_ENABLE_STATS 0) to prevent export issues for the shared version.

Tasks

llvmVersions - list of supported versions for the current environment/platform

gradle llvmVersions

> Task :llvm-app:llvmVersions
9.0.0
8.0.0

BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed

llvmComponents - list of supported LLVM components for static linkage.

llvmCleanCache - clean of local user cache with LLVM downloads.

llvmBuildInfo, llvmBuildInfoDebug, llvmBuildInfoRelease - show information about used LLVM build.

gradle llvmBuildInfoRelease

> Task :llvm-app:llvmBuildInfoRelease
  version: 9.0.0
  sources link: http://releases.llvm.org/9.0.0/llvm-9.0.0.src.tar.xz
  platform: SMP Debian 4.19.67-2 (2019-08-28) x86_64
  toolchain: clang version 10.0.0-svn372778-1~exp1+0~20190924203139.1491~1.gbpb209ff (trunk)
  profile: Release
  cmake config: CC=/usr/bin/clang CXX=/usr/bin/clang++ -DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON -DCMAKE_BUILD_TYPE=Release
  cmake build: --build .

BUILD SUCCESSFUL in 830ms

Configuration

llvm {
    version = '9.0.0'
    linkage = Linkage.SHARED
    serverUrl = 'http://releases.llvm.org/7.0.1/clang%2bllvm-7.0.1-x86_64-linux-gnu-ubuntu-18.04.tar.xz'
    localPath = '<path to unpacked LLVM build>'
    components = ['Engine', 'OrcJIT']
    forceReleaseLinux = true
    preferCLang = true
    suppressWarningsMsvc = true
}

version (string) - version of LLVM. Version should present in a list which returns llvmVersions. This parameter is mandatory.

linkage (enum) - type of linkage shared (Linkage.SHARED) or static (Linkage.STATIC). The static linkage is used by default.

serverUrl (string) - specify a particular URL to download. 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.

localPath (string) - you can work offline with already downloaded or manual built binaries. In this case, nothing connected with LLVM 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.

components (list of strings) - particular components to static linking. Potentially, decrease of libraries for linking might improve linking time. If none of the components are chosen default component ‘all’ will be used. To see the whole list of supported components you can use llvmComponents task.

forceReleaseLinux (boolean) - force to use release variant of LLVM for debug build on Linux. 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. Recommended to switch it on if you don’t really need binary with debug information of LLVM itself. By default is switched off.

preferCLang (boolean) - prefers CLang LLVM build on Windows if available. By default is switched off.

suppressWarningsMsvc (boolean) - disables compilation warnings for MSVC (C4141, C4244, C4291, C4624, C4996);

Example:

Full sources of simple LLVM application.


Related

Commit: [1c3704]