Skip to content

Building LLVM

Vihan edited this page Jun 27, 2020 · 11 revisions

VSL relies pretty heavily on LLVM for most targets. This is a quick guide with the recommended way to install LLVM so it works with VSL. Any errors you encounter during this process would be an issue with LLVM so we recommend you leave an issue with them.

These instructions are for macOS/Linux but shouldn't be too much different for you Windows users.

Dependencies

Installation Process

Hopefully this isn't out of date by the time you are reading this:

  1. Download the LLVM source code. VSL should support the latest LLVM version at all times (last tested on v9.0.0). You can also clone the latest from SVN. Navigate inside the directory
    git clone --depth 1 https://github.com/llvm/llvm-project.git
    cd llvm-project
  2. Create a build directory and inside of it run cmake with the LLVM build flags to generate the build files.
    mkdir build
    cd build
    cmake ../llvm -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly
    • Recommended (for WASM): compile with the lld linker using: -DLLVM_ENABLE_PROJECTS=lld
    • macOS users: add -GXcode flag for parallel builds with Xcode installed
    • consider: adding -DCMAKE_BUILD_TYPE=Release to do a 'release' build of LLVM which may provide better errors in case of internal compiler errors.
  3. To build run:
    cmake --build .
    • note: this will take long time and lots of CPU
  4. To install, then run the following:
    cmake --build . --target install
    • You may need to add sudo depending on OS and user permissions