Skip to content

Instantly share code, notes, and snippets.

@miloszwasacz
Last active January 2, 2024 16:31
Show Gist options
  • Save miloszwasacz/94ccdf0c16941b2586e3663a4c647363 to your computer and use it in GitHub Desktop.
Save miloszwasacz/94ccdf0c16941b2586e3663a4c647363 to your computer and use it in GitHub Desktop.
Building LLVM from source on Windows (MSVC)

Building LLVM from source on Windows (MSVC)

Prerequisites

  • Git
  • Visual Studio with C++ development toolchain installed

Steps

All these steps (maybe apart from 1.) must be run in Developer Command Prompt for VS

  1. Clone LLVM repo
# Specify the release using --branch
git clone --config core.autocrlf=false --depth 1 --branch llvmorg-16.0.6 https://github.com/llvm/llvm-project.git
cd llvm-project
  1. Configure the build with CMake
# You can add `-DLLVM_ENABLE_PROJECTS="..."` to also compile other tools, e.g. clang, lld.
# Remember to change `-DCMAKE_INSTALL_PREFIX` to a real path
cmake -S llvm -B build -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_HOST_TRIPLE="x86_64-pc-windows-msvc" -DCMAKE_INSTALL_PREFIX="C:\some\path\for\llvm\binaries" -DLLVM_ENABLE_ASSERTIONS=ON
  1. Build and test LLVM
# Use check-'tool' for other tools like clang
ninja -C build check-llvm
  1. Install
ninja -C build install
  1. Add the path from CMAKE_INSTALL_PREFIX to the PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment