# Building and Installing Polly

## Automatic

There is a script available to automatically checkout, update, build, and test Polly. This script contains all the commands that are subsequently described on this webpage. The automatic installation consists of four simple steps:

    mkdir polly && cd polly
    wget https://polly.llvm.org/polly.sh
    chmod +x polly.sh
    ./polly.sh

## Manual

### Get the code

    git clone https://github.com/llvm/llvm-project.git llvm_git

### Build Polly

    mkdir llvm_build && cd llvm_build
    cmake -DLLVM_ENABLE_PROJECTS='polly;clang' ../llvm_git/llvm && make

### Test Polly

    make check-polly

### Building Polly Without LLVM

It is also possible to build Polly without also building LLVM. All you need is an installed version of LLVM or a previous build. To configure Polly to use a pre-built LLVM, set the `-DCMAKE_PREFIX_PATH` option:

    cmake -DCMAKE_PREFIX_PATH=${LLVM_PREFIX}/lib/cmake/llvm ../llvm_git/polly

To run unittests, however, you need to have the LLVM source directory around. Polly will use the `llvm-config` of the LLVM you're building against to guess the location of the source directory. You may override autodetected location by setting the `-DLLVM_SOURCE_ROOT` option.

### Troubleshooting

If you get an error in one of the python files, your system probably uses python3 as default python interpreter. This is the case, for instance, under Arch Linux. To solve this issue, run `cmake` again, but with the added argument: `-DPYTHON_EXECUTABLE=/usr/bin/python2` (replace `/usr/bin/python2` with the location of the python2 interpreter under your system).

    cmake -DCMAKE_PREFIX_PATH=${ISL_INSTALL} -DPYTHON_EXECUTABLE=/usr/bin/python2 ${LLVM_SRC}