@echo off setlocal enabledelayedexpansion REM ================================================================= REM Stage 1: Bootstrap Compiler (using MSVC as host compiler) REM ================================================================= REM Builds basic Clang + LLD without runtime libraries REM ================================================================= echo ================================================================ echo Stage 1: Building Bootstrap Compiler echo ================================================================ REM =============== CONFIGURATION =============== set LLVM_SOURCE_DIR=E:\llvm-project-llvmorg-22.1.5 set BUILD_DIR=E:\llvm-build-stage1 set INSTALL_DIR=E:\llvm-stage1 set PARALLEL_JOBS=3 set CMAKE_GENERATOR=Ninja REM ============================================== echo. echo Configuration: echo Source: %LLVM_SOURCE_DIR% echo Build: %BUILD_DIR% echo Install: %INSTALL_DIR% echo Generator: %CMAKE_GENERATOR% echo Jobs: %PARALLEL_JOBS% echo. REM Check if source directory exists if not exist "%LLVM_SOURCE_DIR%\llvm\CMakeLists.txt" ( echo ERROR: Source directory not found or invalid! echo Please set LLVM_SOURCE_DIR to your llvm-project directory exit /b 1 ) REM Clean previous build if exists if exist "%BUILD_DIR%" ( echo Removing previous build directory... rmdir /s /q "%BUILD_DIR%" ) REM Create directories mkdir "%BUILD_DIR%" mkdir "%INSTALL_DIR%" REM Navigate to build directory cd /d "%BUILD_DIR%" echo. echo ================================================================ echo Configuring with CMake... echo ================================================================ REM Configure with CMake cmake -G "%CMAKE_GENERATOR%" ^ -DCMAKE_BUILD_TYPE=Release ^ -DCMAKE_INSTALL_PREFIX="%INSTALL_DIR%" ^ -DLLVM_TARGETS_TO_BUILD="X86" ^ -DLLVM_ENABLE_PROJECTS="clang;lld" ^ -DLLVM_ENABLE_RUNTIMES="" ^ -DLLVM_INCLUDE_TESTS=OFF ^ -DLLVM_INCLUDE_EXAMPLES=OFF ^ -DLLVM_INCLUDE_UTILS=OFF ^ -DLLVM_INSTALL_TOOLCHAIN_ONLY=OFF ^ -DLLVM_BUILD_TOOLS=ON ^ "%LLVM_SOURCE_DIR%\llvm" if errorlevel 1 ( echo ERROR: CMake configuration failed! exit /b 1 ) echo. echo ================================================================ echo Building... echo ================================================================ REM Build and install cmake --build . --config Release --target install --parallel %PARALLEL_JOBS% if errorlevel 1 ( echo ERROR: Build failed! exit /b 1 ) echo. echo ================================================================ echo Verifying stage1 compiler... echo ================================================================ REM Verify the compiler works "%INSTALL_DIR%\bin\clang++.exe" --version > nul if errorlevel 1 ( echo ERROR: Built compiler doesn't work! exit /b 1 ) "%INSTALL_DIR%\bin\clang++.exe" --version echo. echo Stage 1 completed successfully! echo Bootstrap compiler installed to: %INSTALL_DIR% echo. echo You can now run build-stage2.bat to build the complete toolchain. echo ================================================================