Contrary to what you might expect, llvmlite does not use any LLVM shared libraries that may be present on the system, or in the conda environment. The parts of LLVM required by llvmlite are statically linked at build time. As a result, installing llvmlite from a binary package does not also require the end user to install LLVM. (For more details on the reasoning behind this, see: Why Static Linking to LLVM?)
Building LLVM for llvmlite is challenging, so we strongly recommend installing a binary package where we have built and tested everything for you. Official conda packages are available in the Anaconda distribution:
conda install llvmlite
conda install --channel numba llvmlite
Binary wheels are also available for installation from PyPI:
pip install llvmlite
Building llvmlite requires first building LLVM. Do not use prebuilt LLVM binaries from your OS distribution or the LLVM website! There will likely be a mismatch in version or build options, and LLVM will be missing certain patches that are critical for llvmlite operation.
Before building, you must have the following:
- On Windows:
- Visual Studio 2015 (Update 3) or later, to compile LLVM and llvmlite. The free Express edition is acceptable.
- CMake installed.
- On Linux:
- g++ (>= 4.8) and CMake
- If building LLVM on Ubuntu, the linker may report an error
if the development version of
libeditis not installed. If you run into this problem, install
- On Mac:
- Xcode for the compiler tools, and CMake
If you can build llvmlite inside a conda environment, you can install a prebuilt LLVM binary package and skip this step:
conda install -c numba llvmdev
The manual instructions below describe the main steps, but refer to the recipe for details:
#. Download the LLVM 6.0.0 source code. (Note that PPC64LE requires LLVM 6.0.1 for specific bug fixes.)
Download or git checkout the llvmlite source code.
Decompress the LLVM tar file and apply the following patches from the
llvm-lto-static.patch: Fix issue with LTO shared library on Windows
D47188-svml.patch: Add support for vectorized math functions via Intel SVML
0001-Transforms-Add-missing-header-for-InstructionCombini.patch: Fix release bug with LLVM 6.0.0, skip on LLVM 6.0.1.
twine_cfg_undefined_behavior.patch: Fix obscure memory corruption bug in LLVM that hasn’t been fixed in master yet
- For Linux/macOS:
export PREFIX=desired_install_location CPU_COUNT=N(
Nis number of parallel compile tasks)
- Run the build.sh script in the llvmdev conda recipe from the LLVM source directory
- For Windows:
- Run the bld.bat script in the llvmdev conda recipe from the LLVM source directory.
To build the llvmlite C wrapper, which embeds a statically linked copy of the required subset of LLVM, run the following from the llvmlite source directory:
python setup.py build
If your LLVM is installed in a nonstandard location, set the
LLVM_CONFIGenvironment variable to the location of the corresponding
llvm-config.exeexecutable. This variable must persist into the installation of llvmlite—for example, into a Python environment.
EXAMPLE: If LLVM is installed in
llvm-configbinary located at
To validate your build, run the test suite by running:
python -m llvmlite.tests
If the validation is successful, install by running:
python setup.py install