Last active
January 30, 2025 18:28
-
-
Save mmozeiko/48be1c90135241b7b4188bbd0f481fd6 to your computer and use it in GitHub Desktop.
download & build llvm+clang on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
rem !!! build requirements !!! | |
rem Visual Studio 2022 - https://visualstudio.microsoft.com/vs/ | |
rem 7-Zip - https://www.7-zip.org/download.html | |
rem Python - https://www.python.org/downloads/ | |
rem CMake - http://www.cmake.org/download/ | |
rem ninja.exe - https://github.com/ninja-build/ninja/releases/latest | |
set VERSION=18.1.2 | |
echo downloading and unpacking... | |
if exist "%ProgramFiles%\7-Zip\7z.exe" ( | |
set SZIP="%ProgramFiles%\7-Zip\7z.exe" | |
) else ( | |
where /q 7za.exe || ( | |
echo ERROR: 7-Zip installation or "7za.exe" not found | |
exit /b 1 | |
) | |
set SZIP=7za.exe | |
) | |
curl -sfL https://github.com/llvm/llvm-project/releases/download/llvmorg-%VERSION%/llvm-project-%VERSION%.src.tar.xz ^ | |
| %SZIP% x -bb0 -txz -si -so ^ | |
| %SZIP% x -bb0 -ttar -si -aoa 1>nul 2>nul | |
del /y pax_global_header 1>nul 2>nul | |
where /Q cl.exe || ( | |
set __VSCMD_ARG_NO_LOGO=1 | |
for /f "tokens=*" %%i in ('"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath') do set VS=%%i | |
if "!VS!" equ "" ( | |
echo ERROR: Visual Studio installation not found | |
exit /b 1 | |
) | |
call "!VS!\VC\Auxiliary\Build\vcvarsall.bat" amd64 || exit /b 1 | |
) | |
rem ** You can add more targets to LLVM_TARGETS_TO_BUILD line, or just remove it to build all possible targets | |
rem ** Remove clang-tools-extra from LLVM_ENABLE_PROJECTS if you don't need clang-tidy / clangd / other clang tools | |
rem ** Remove compiler-rt from LLVM_ENABLE_PROJECTS if you don't need clang's sanitizers | |
rem ** Remove lldb from LLVM_ENABLE_PROJECTS if you don't need lldb debugger | |
rem ** Build in configuration below takes ~20min on 16-core Ryzen 9 5950X | |
rem ** Without clang-tools-extra & lldb it takes ~15min | |
cmake ^ | |
-G Ninja ^ | |
-S "llvm-project-%VERSION%.src\llvm" ^ | |
-B "llvm-project-%VERSION%.build" ^ | |
-D CMAKE_INSTALL_PREFIX="%CD%\llvm-project-%VERSION%" ^ | |
-D CMAKE_BUILD_TYPE=Release ^ | |
-D CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ^ | |
-D BUILD_SHARED_LIBS=OFF ^ | |
-D LLVM_OPTIMIZED_TABLEGEN=ON ^ | |
-D LLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb;compiler-rt;polly" ^ | |
-D LLVM_TARGETS_TO_BUILD="AArch64;ARM;WebAssembly;X86" ^ | |
-D LLVM_BUILD_LLVM_C_DYLIB=OFF ^ | |
-D LLVM_ENABLE_BACKTRACES=OFF ^ | |
-D LLVM_ENABLE_UNWIND_TABLES=OFF ^ | |
-D LLVM_ENABLE_CRASH_OVERRIDES=OFF ^ | |
-D LLVM_ENABLE_CRASH_DUMPS=OFF ^ | |
-D LLVM_ENABLE_TERMINFO=OFF ^ | |
-D LLVM_ENABLE_LIBXML2=OFF ^ | |
-D LLVM_ENABLE_LIBEDIT=OFF ^ | |
-D LLVM_ENABLE_LIBPFM=OFF ^ | |
-D LLVM_ENABLE_ZLIB=OFF ^ | |
-D LLVM_ENABLE_ZSTD=OFF ^ | |
-D LLVM_ENABLE_CURL=OFF ^ | |
-D LLVM_ENABLE_HTTPLIB=OFF ^ | |
-D LLVM_ENABLE_Z3_SOLVER=OFF ^ | |
-D LLVM_ENABLE_WARNINGS=OFF ^ | |
-D LLVM_ENABLE_PEDANTIC=OFF ^ | |
-D LLVM_ENABLE_WERROR=OFF ^ | |
-D LLVM_ENABLE_ASSERTIONS=OFF ^ | |
-D LLVM_BUILD_EXAMPLES=OFF ^ | |
-D LLVM_BUILD_TESTS=OFF ^ | |
-D LLVM_BUILD_BENCHMARKS=OFF ^ | |
-D LLVM_BUILD_DOCS=OFF ^ | |
-D LLVM_INCLUDE_EXAMPLES=OFF ^ | |
-D LLVM_INCLUDE_TESTS=OFF ^ | |
-D LLVM_INCLUDE_BENCHMARKS=OFF ^ | |
-D LLVM_INCLUDE_DOCS=OFF ^ | |
-D LLVM_ENABLE_OCAMLDOC=OFF ^ | |
-D LLVM_ENABLE_BINDINGS=OFF ^ | |
-D LLVM_ENABLE_PLUGINS=OFF ^ | |
-D LLVM_ENABLE_IDE=OFF ^ | |
-D CLANG_BUILD_EXAMPLES=OFF ^ | |
-D CLANG_INCLUDE_TESTS=OFF ^ | |
-D CLANG_INCLUDE_DOCS=OFF ^ | |
-D CLANG_ENABLE_ARCMT=OFF ^ | |
-D CLANG_ENABLE_STATIC_ANALYZER=OFF ^ | |
-D COMPILER_RT_BUILD_SANITIZERS=ON ^ | |
-D COMPILER_RT_BUILD_LIBFUZZER=ON ^ | |
-D COMPILER_RT_BUILD_PROFILE=ON ^ | |
-D COMPILER_RT_BUILD_BUILTINS=OFF ^ | |
-D COMPILER_RT_BUILD_XRAY=OFF ^ | |
-D COMPILER_RT_BUILD_MEMPROF=OFF ^ | |
-D COMPILER_RT_BUILD_XRAY_NO_PREINIT=OFF ^ | |
-D COMPILER_RT_BUILD_ORC=OFF ^ | |
-D COMPILER_RT_BUILD_GWP_ASAN=OFF ^ | |
-D COMPILER_RT_ENABLE_CET=OFF | |
ninja -C llvm-project-%VERSION%.build install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment