-
-
Save ser-mk/ac746c607b7952248c67a2d7f8f43d4e 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 2019 or 2022 | |
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=15.0.1 | |
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're not interested in clang-tidy.exe, clangd.exe and other clang tools | |
rem ** Build in configuration below takes ~15min on 16-core Ryzen | |
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 BUILD_SHARED_LIBS=OFF ^ | |
-D LLVM_USE_CRT_RELEASE=MT ^ | |
-D LLVM_OPTIMIZED_TABLEGEN=ON ^ | |
-D LLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;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_CRT=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 ^ | |
-D COMPILER_RT_CRT_USE_EH_FRAME_REGISTRY=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