Build LLVM on Windows

Published:
less than 1 minute read

To build LLVM on Windows, Cmake and Vistual Studio is required.

Take a look at this page for the complete manual.

Grab LLVM source and checkout to a desired tag/branch:

git clone --config core.autocrlf=false https://github.com/llvm/llvm-project.git

cd llvm-project

# Checkout to a tag, for instance:
git checkout llvmorg-17.0.1

In the root directory of the repo (not build), run cmake with desired options:

cmake -B build -G "Visual Studio 16 2019" -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;lld;lldb' \
 -DCMAKE_BUILD_TYPE=Release -DLLVM_PARALLEL_COMPILE_JOBS=4 -DLLVM_PARALLEL_LINK_JOBS=4 \
 -DLLVM_ENABLE_RUNTIME='compiler-rt;libc;libcxx;openmp' -S llvm

This command will create LLVM.sln file. Open it in Visual Studio, change the build type to Release and build the whole project.

After completion, the binary files should be under build/Release/bin.