View source in Mesa


A High Performance, Highly Scalable Software Rasterizer for OpenGL

Linux Build Instructions


These instructions are for Mesa 18.3.4 and earlier, and uses GNU Autotools for configuring the build. As of Mesa 19.0.0, the use of Autotools is deprecated, and is slated to be removed in the future. Mesa now uses the Meson build system with Ninja. For instructions on building Mesa with OpenSWR using Meson+Ninja, please click here.

If you still want to use Autotools before it is completely removed, you must use the --enable-autotools flag during the configure step.

On Linux, OpenSWR can be built within Mesa using GNU autotools as described in Mesa's installation page, with the addition of swr to the list of gallium drivers. Note that the use of autotools is deprecated as of Mesa 19.0.0.

The instructions below describe how to compile Mesa using the Mesa released tarballs. Compiling directly from the git repository is more complex and is beyond the scope of these instructions. If you want to compile from the git repository and you run into issues, please contact us directly.

  1. Setup
    1. Building and Installing LLVM
  2. Building Mesa with OpenSWR
  3. Using Mesa with OpenSWR


Mesa requires some dependencies to build:

as well as the following two Python modules installed via pip:

Please make sure you install them prior to building. Refer to Mesa's installation page for more information on its requirements.

Building and Installing LLVM

One of the major Mesa requirements is LLVM, but with some additional flags required at compile time. If you do not already have LLVM, you will need to install it first. LLVM source is available as tarball on their release download page. Currently, LLVM versions 6.x through 7.0.1 are supported. Once downloaded, use the following steps to build and install LLVM. In this example we are installing them locally.

$ pwd
$ ls
$ tar xJf llvm-x.y.z.src.tar.xz
$ mkdir build
$ cd build
$ cmake -G "Unix Makefiles" \
        -D CMAKE_BUILD_TYPE=Release \
        -D BUILD_SHARED_LIBS=1 \
        -D LLVM_ENABLE_RTTI=1 \
        -D CMAKE_INSTALL_PREFIX=/home/openswr/.local/ \
$ make -j `nproc`
$ make install
If you do not install LLVM locally, make sure you set your LD_LIBRARY_PATH and PATH environment variables to the LLVM lib and bin directories, respectively.

Building Mesa with OpenSWR

Download a Mesa source distribution from Mesa's download page. We recommend the latest non-release-candidate version for the best compatibility.

Once downloaded, use the following steps to build Mesa with OpenSWR.

$ pwd
$ ls
$ tar xf mesa-x.y.z.tar.gz
$ cd mesa-x.y.z
$ mkdir build
$ cd build

Now we can configure Mesa with OpenSWR. In this example, we are installing Mesa locally.

$ ../configure --disable-dri \
               --disable-egl \
               --disable-gbm \
               --with-gallium-drivers=swrast,swr \
               --with-platforms=x11 \

If you run into problems due to VL on your system, add the following flags to the above configure call:

--disable-xvmc --disable-vdpau --disable-va

If you also want to compile OSMesa (off-screen rendering support), please add the following flag:


By default, the build will compile with support for AVX and AVX2 targets. If you want to also compile for Skylake and/or Knight's Landing architectures (AVX512), please add the following flag. Make sure your compiler supports the necessary compiler flags to compile for the specified architectures.


After you have the appropriate configure command for your system, you can build and install with make

$ make -j `nproc`
$ make install

Once installed, you will see,, and libSWR<arch>.so (for each architecture selected) in lib/gallium/ in your build directory as well as in lib/ in your installation directory.

Using Mesa with OpenSWR

If you installed Mesa with OpenSWR to a local directory as in the examples above, it should already be usable by applications. If you installed elsewhere, you will need to include the path in your LD_LIBRARY_PATH environment variable. Make sure you specifically add the lib or lib/gallium directory to LD_LIBRARY_PATH.

$ export LD_LIBRARY_PATH=/your/path/to/mesa/lib:$LD_LIBRARY_PATH

Now any application seeking GL will use the Mesa installation. To enable the OpenSWR driver, you need to specify it with the GALLIUM_DRIVER environment variable:

$ export GALLIUM_DRIVER=swr

You should see a message printed to the terminal when running a GL application when OpenSWR is set as the gallium driver. For example:

$ glxgears
SWR detected AVX2 instruction support (using: