A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/ziglang/zig/wiki/How-to-build-LLVM,-libclang,-and-liblld-from-source below:

How to build LLVM, libclang, and liblld from source · ziglang/zig Wiki · GitHub

Alternate Options to Building from Source

Install CMake, version 3.20.0 or newer.

Download llvm, clang, and lld The downloads from llvm lead to the github release pages, where the source's will be listed as : llvm-20.X.X.src.tar.xz, clang-20.X.X.src.tar.xz, lld-20.X.X.src.tar.xz. Unzip each to their own directory. Ensure no directories have spaces in them. For example:

Install Build Tools for Visual Studio 2019. Be sure to select "C++ build tools" when prompted.

Install Python 3.9.4. Tick the box to add python to your PATH environment variable.

Using the start menu, run x64 Native Tools Command Prompt for VS 2019 and execute these commands, replacing C:\Users\Andy with the correct value. Here is listed a brief explanation of each of the CMake parameters we pass when configuring the build

mkdir C:\Users\Andy\llvm-20.1.0.src\build-release
cd C:\Users\Andy\llvm-20.1.0.src\build-release
"c:\Program Files\CMake\bin\cmake.exe" .. -Thost=x64 -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=C:\Users\Andy\llvm+clang+lld-20.1.0-x86_64-windows-msvc-release-mt -DCMAKE_PREFIX_PATH=C:\Users\Andy\llvm+clang+lld-20.1.0-x86_64-windows-msvc-release-mt -
DLLVM_ENABLE_ZLIB=OFF -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_USE_CRT_RELEASE=MT
msbuild /m -p:Configuration=Release INSTALL.vcxproj
mkdir C:\Users\Andy\llvm-20.1.0.src\build-debug
cd C:\Users\Andy\llvm-20.1.0.src\build-debug
"c:\Program Files\CMake\bin\cmake.exe" .. -Thost=x64 -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=C:\Users\andy\llvm+clang+lld-20.1.0-x86_64-windows-msvc-debug -
DLLVM_ENABLE_ZLIB=OFF -DCMAKE_PREFIX_PATH=C:\Users\andy\llvm+clang+lld-20.1.0-x86_64-windows-msvc-debug -DCMAKE_BUILD_TYPE=Debug -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="AVR" -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_USE_CRT_DEBUG=MTd
msbuild /m INSTALL.vcxproj

Using the start menu, run x64 Native Tools Command Prompt for VS 2019 and execute these commands, replacing C:\Users\Andy with the correct value.

mkdir C:\Users\Andy\lld-20.1.0.src\build-release
cd C:\Users\Andy\lld-20.1.0.src\build-release
"c:\Program Files\CMake\bin\cmake.exe" .. -Thost=x64 -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=C:\Users\Andy\llvm+clang+lld-14.0.6-x86_64-windows-msvc-release-mt -DCMAKE_PREFIX_PATH=C:\Users\Andy\llvm+clang+lld-20.1.0-x86_64-windows-msvc-release-mt -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_CRT_RELEASE=MT
msbuild /m -p:Configuration=Release INSTALL.vcxproj
mkdir C:\Users\Andy\lld-20.1.0.src\build-debug
cd C:\Users\Andy\lld-20.1.0.src\build-debug
"c:\Program Files\CMake\bin\cmake.exe" .. -Thost=x64 -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=C:\Users\andy\llvm+clang+lld-20.1.0-x86_64-windows-msvc-debug -DCMAKE_PREFIX_PATH=C:\Users\andy\llvm+clang+lld-20.1.0-x86_64-windows-msvc-debug -DCMAKE_BUILD_TYPE=Debug -DLLVM_USE_CRT_DEBUG=MTd
msbuild /m INSTALL.vcxproj

Using the start menu, run x64 Native Tools Command Prompt for VS 2019 and execute these commands, replacing C:\Users\Andy with the correct value.

mkdir C:\Users\Andy\clang-20.1.0.src\build-release
cd C:\Users\Andy\clang-20.1.0.src\build-release
"c:\Program Files\CMake\bin\cmake.exe" .. -Thost=x64 -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=C:\Users\Andy\llvm+clang+lld-20.1.0-x86_64-windows-msvc-release-mt -DCMAKE_PREFIX_PATH=C:\Users\Andy\llvm+clang+lld-20.1.0-x86_64-windows-msvc-release-mt -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_CRT_RELEASE=MT
msbuild /m -p:Configuration=Release INSTALL.vcxproj
mkdir C:\Users\Andy\clang-20.1.0.src\build-debug
cd C:\Users\Andy\clang-20.1.0.src\build-debug
"c:\Program Files\CMake\bin\cmake.exe" .. -Thost=x64 -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=C:\Users\andy\llvm+clang+lld-20.1.0-x86_64-windows-msvc-debug -DCMAKE_PREFIX_PATH=C:\Users\andy\llvm+clang+lld-20.1.0-x86_64-windows-msvc-debug -DCMAKE_BUILD_TYPE=Debug -DLLVM_USE_CRT_DEBUG=MTd
msbuild /m INSTALL.vcxproj

This guide will get you both a Debug build of LLVM, and/or a Release build of LLVM. It intentionally does not require privileged access, using a prefix inside your home directory instead of a global installation.

This is the generally recommended approach.

cd ~/Downloads
git clone --depth 1 --branch release/20.x https://github.com/llvm/llvm-project llvm-project-20
cd llvm-project-20
git checkout release/20.x

mkdir build-release
cd build-release
cmake ../llvm \
  -DCMAKE_INSTALL_PREFIX=$HOME/local/llvm20-assert \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_ENABLE_PROJECTS="lld;clang" \
  -DLLVM_ENABLE_LIBXML2=OFF \
  -DLLVM_ENABLE_TERMINFO=OFF \
  -DLLVM_ENABLE_LIBEDIT=OFF \
  -DLLVM_ENABLE_ASSERTIONS=ON \
  -DLLVM_PARALLEL_LINK_JOBS=1 \
  -G Ninja
ninja install

This is occasionally needed when debugging Zig's LLVM backend. Here we build the three projects separately so that LLVM can be in Debug mode while the others are in Release mode.

cd ~/Downloads
git clone --depth 1 --branch release/20.x https://github.com/llvm/llvm-project llvm-project-20
cd llvm-project-20
git checkout release/20.x

# LLVM
mkdir llvm/build-debug
cd llvm/build-debug
cmake .. \
  -DCMAKE_INSTALL_PREFIX=$HOME/local/llvm20-debug \
  -DCMAKE_PREFIX_PATH=$HOME/local/llvm20-debug \
  -DCMAKE_BUILD_TYPE=Debug \
  -DLLVM_ENABLE_LIBXML2=OFF \
  -DLLVM_ENABLE_TERMINFO=OFF \
  -DLLVM_ENABLE_LIBEDIT=OFF \
  -DLLVM_PARALLEL_LINK_JOBS=1 \
  -G Ninja
ninja install
cd ../..

# LLD
mkdir lld/build-debug
cd lld/build-debug
cmake .. \
  -DCMAKE_INSTALL_PREFIX=$HOME/local/llvm20-debug \
  -DCMAKE_PREFIX_PATH=$HOME/local/llvm20-debug \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_PARALLEL_LINK_JOBS=1 \
  -DCMAKE_CXX_STANDARD=17 \
  -G Ninja
ninja install
cd ../..

# Clang
mkdir clang/build-debug
cd clang/build-debug
cmake .. \
  -DCMAKE_INSTALL_PREFIX=$HOME/local/llvm20-debug \
  -DCMAKE_PREFIX_PATH=$HOME/local/llvm20-debug \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_PARALLEL_LINK_JOBS=1 \
  -DLLVM_INCLUDE_TESTS=OFF \
  -G Ninja
ninja install
cd ../..

Then add to your Zig CMake line that you got from the README.md: -DCMAKE_PREFIX_PATH=$HOME/local/llvm20-debug or -DCMAKE_PREFIX_PATH=$HOME/local/llvm20-assert depending on whether you want Debug or Release LLVM.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4