Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 56 additions & 94 deletions llvm/utils/release/build_llvm_release.bat
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,14 @@ set common_cmake_flags=^
-DLLVM_BUILD_LLVM_C_DYLIB=ON ^
-DPython3_FIND_REGISTRY=NEVER ^
-DPACKAGE_VERSION=%package_version% ^
-DLLDB_RELOCATABLE_PYTHON=1 ^
-DLLDB_EMBED_PYTHON_HOME=OFF ^
-DCMAKE_CL_SHOWINCLUDES_PREFIX="Note: including file: " ^
-DLLVM_ENABLE_LIBXML2=FORCE_ON ^
-DLLDB_ENABLE_LIBXML2=OFF ^
-DCLANG_ENABLE_LIBXML2=OFF ^
-DCMAKE_C_FLAGS="%common_compiler_flags%" ^
-DCMAKE_CXX_FLAGS="%common_compiler_flags%" ^
-DLLVM_ENABLE_RPMALLOC=ON ^
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;compiler-rt;lldb;openmp"
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld" ^
-DLLVM_ENABLE_RUNTIMES="compiler-rt;openmp"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a feeling switching to the runtimes build is going to break us somehow, but I don't know how yet :)


if "%force-msvc%" == "" (
where /q clang-cl
Expand All @@ -185,15 +183,20 @@ if "%force-msvc%" == "" (
)
)

set common_lldb_flags=^
-DLLDB_RELOCATABLE_PYTHON=1 ^
-DLLDB_EMBED_PYTHON_HOME=OFF ^
-DLLDB_ENABLE_LIBXML2=OFF

set cmake_profile_flags=""

REM Preserve original path
set OLDPATH=%PATH%

REM Build the 32-bits and/or 64-bits binaries.
if "%x86%" == "true" call :do_build_32 || exit /b 1
if "%x64%" == "true" call :do_build_64 || exit /b 1
if "%arm64%" == "true" call :do_build_arm64 || exit /b 1
if "%x64%" == "true" call :do_build_64_common amd64 %python64_dir% || exit /b 1
if "%arm64%" == "true" call :do_build_64_common arm64 %pythonarm64_dir% || exit /b 1
exit /b 0

::==============================================================================
Expand All @@ -212,8 +215,6 @@ set "stage0_bin_dir=%build_dir%/build32_stage0/bin"
set cmake_flags=^
%common_cmake_flags% ^
-DLLVM_ENABLE_RPMALLOC=OFF ^
-DLLDB_TEST_COMPILER=%stage0_bin_dir%/clang.exe ^
-DPYTHON_HOME=%PYTHONHOME% ^
-DPython3_ROOT_DIR=%PYTHONHOME% ^
-DLIBXML2_INCLUDE_DIR=%libxmldir%/include/libxml2 ^
-DLIBXML2_LIBRARIES=%libxmldir%/lib/libxml2s.lib
Expand All @@ -231,6 +232,9 @@ REM CMake expects the paths that specifies the compiler and linker to be
REM with forward slash.
set all_cmake_flags=^
%cmake_flags% ^
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb;" ^
%common_lldb_flags% ^
-DPYTHON_HOME=%PYTHONHOME% ^
-DCMAKE_C_COMPILER=%stage0_bin_dir%/clang-cl.exe ^
-DCMAKE_CXX_COMPILER=%stage0_bin_dir%/clang-cl.exe ^
-DCMAKE_LINKER=%stage0_bin_dir%/lld-link.exe ^
Expand All @@ -254,32 +258,42 @@ exit /b 0
::==============================================================================

::==============================================================================
:: Build 64-bits binaries.
:: Build 64-bits binaries (common function for both x64 and arm64)
::==============================================================================
:do_build_64
call :set_environment %python64_dir% || exit /b 1
call "%vsdevcmd%" -arch=amd64 || exit /b 1
:do_build_64_common
set arch=%1
set python_dir=%2

call :set_environment %python_dir% || exit /b 1
call "%vsdevcmd%" -arch=%arch% || exit /b 1
@echo on
mkdir build64_stage0
cd build64_stage0
mkdir build_%arch%_stage0
cd build_%arch%_stage0
call :do_build_libxml || exit /b 1

REM Stage0 binaries directory; used in stage1.
set "stage0_bin_dir=%build_dir%/build64_stage0/bin"
set "stage0_bin_dir=%build_dir%/build_%arch%_stage0/bin"
set cmake_flags=^
%common_cmake_flags% ^
-DLLDB_TEST_COMPILER=%stage0_bin_dir%/clang.exe ^
-DPYTHON_HOME=%PYTHONHOME% ^
-DPython3_ROOT_DIR=%PYTHONHOME% ^
-DLIBXML2_INCLUDE_DIR=%libxmldir%/include/libxml2 ^
-DLIBXML2_LIBRARIES=%libxmldir%/lib/libxml2s.lib
-DLIBXML2_LIBRARIES=%libxmldir%/lib/libxml2s.lib ^
-DCLANG_DEFAULT_LINKER=lld
if "%arch%"=="arm64" (
set cmake_flags=%cmake_flags% ^
-DCOMPILER_RT_BUILD_SANITIZERS=OFF
)

cmake -GNinja %cmake_flags% %llvm_src%\llvm || exit /b 1
cmake -GNinja %cmake_flags% ^
-DLLVM_TARGETS_TO_BUILD=Native ^
%llvm_src%\llvm || exit /b 1
ninja || ninja || ninja || exit /b 1
ninja check-llvm || ninja check-llvm || ninja check-llvm || exit /b 1
ninja check-clang || ninja check-clang || ninja check-clang || exit /b 1
ninja check-lld || ninja check-lld || ninja check-lld || exit /b 1
ninja check-sanitizer || ninja check-sanitizer || ninja check-sanitizer || exit /b 1
if "%arch%"=="amd64" (
ninja check-runtimes || ninja check-runtimes || ninja check-runtimes || exit /b 1
)
ninja check-clang-tools || ninja check-clang-tools || ninja check-clang-tools || exit /b 1
ninja check-clangd || ninja check-clangd || ninja check-clangd || exit /b 1
cd..
Expand All @@ -293,24 +307,40 @@ set all_cmake_flags=^
-DCMAKE_LINKER=%stage0_bin_dir%/lld-link.exe ^
-DCMAKE_AR=%stage0_bin_dir%/llvm-lib.exe ^
-DCMAKE_RC=%stage0_bin_dir%/llvm-windres.exe
if "%arch%"=="arm64" (
set all_cmake_flags=%all_cmake_flags% ^
-DCPACK_SYSTEM_NAME=woa64
)
set cmake_flags=%all_cmake_flags:\=/%


mkdir build64
cd build64
mkdir build_%arch%
cd build_%arch%
call :do_generate_profile || exit /b 1
cmake -GNinja %cmake_flags% %cmake_profile_flags% %llvm_src%\llvm || exit /b 1
cmake -GNinja %cmake_flags% ^
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb;flang;mlir" ^
%common_lldb_flags% ^
-DPYTHON_HOME=%PYTHONHOME% ^
%cmake_profile_flags% %llvm_src%\llvm || exit /b 1
ninja || ninja || ninja || exit /b 1
ninja check-llvm || ninja check-llvm || ninja check-llvm || exit /b 1
ninja check-clang || ninja check-clang || ninja check-clang || exit /b 1
ninja check-lld || ninja check-lld || ninja check-lld || exit /b 1
ninja check-sanitizer || ninja check-sanitizer || ninja check-sanitizer || exit /b 1
if "%arch%"=="amd64" (
ninja check-runtimes || ninja check-runtimes || ninja check-runtimes || exit /b 1
)
ninja check-clang-tools || ninja check-clang-tools || ninja check-clang-tools || exit /b 1
ninja check-clangd || ninja check-clangd || ninja check-clangd || exit /b 1
REM ninja check-flang || ninja check-flang || ninja check-flang || exit /b 1
REM ninja check-mlir || ninja check-mlir || ninja check-mlir || exit /b 1
REM ninja check-lldb || ninja check-lldb || ninja check-lldb || exit /b 1
ninja package || exit /b 1

:: generate tarball with install toolchain only off
set filename=clang+llvm-%version%-x86_64-pc-windows-msvc
if "%arch%"=="amd64" (
set filename=clang+llvm-%version%-x86_64-pc-windows-msvc
) else (
set filename=clang+llvm-%version%-aarch64-pc-windows-msvc
)
cmake -GNinja %cmake_flags% %cmake_profile_flags% -DLLVM_INSTALL_TOOLCHAIN_ONLY=OFF ^
-DCMAKE_INSTALL_PREFIX=%build_dir%/%filename% ..\llvm-project\llvm || exit /b 1
ninja install || exit /b 1
Expand All @@ -320,75 +350,7 @@ cd ..
7z a -ttar -so %filename%.tar %filename% | 7z a -txz -si %filename%.tar.xz

exit /b 0
::==============================================================================

::==============================================================================
:: Build arm64 binaries.
::==============================================================================
:do_build_arm64
call :set_environment %pythonarm64_dir% || exit /b 1
call "%vsdevcmd%" -host_arch=x64 -arch=arm64 || exit /b 1
@echo on
mkdir build_arm64_stage0
cd build_arm64_stage0
call :do_build_libxml || exit /b 1

REM Stage0 binaries directory; used in stage1.
set "stage0_bin_dir=%build_dir%/build_arm64_stage0/bin"
set cmake_flags=^
%common_cmake_flags% ^
-DCLANG_DEFAULT_LINKER=lld ^
-DLIBXML2_INCLUDE_DIR=%libxmldir%/include/libxml2 ^
-DLIBXML2_LIBRARIES=%libxmldir%/lib/libxml2s.lib ^
-DPython3_ROOT_DIR=%PYTHONHOME% ^
-DCOMPILER_RT_BUILD_PROFILE=OFF ^
-DCOMPILER_RT_BUILD_SANITIZERS=OFF

REM We need to build stage0 compiler-rt with clang-cl (msvc lacks some builtins).
cmake -GNinja %cmake_flags% ^
-DCMAKE_C_COMPILER=clang-cl.exe ^
-DCMAKE_CXX_COMPILER=clang-cl.exe ^
%llvm_src%\llvm || exit /b 1
ninja || exit /b 1
::ninja check-llvm || exit /b 1
::ninja check-clang || exit /b 1
::ninja check-lld || exit /b 1
::ninja check-sanitizer || exit /b 1
::ninja check-clang-tools || exit /b 1
::ninja check-clangd || exit /b 1
cd..

REM CMake expects the paths that specifies the compiler and linker to be
REM with forward slash.
REM CPACK_SYSTEM_NAME is set to have a correct name for installer generated.
set all_cmake_flags=^
%cmake_flags% ^
-DCMAKE_C_COMPILER=%stage0_bin_dir%/clang-cl.exe ^
-DCMAKE_CXX_COMPILER=%stage0_bin_dir%/clang-cl.exe ^
-DCMAKE_LINKER=%stage0_bin_dir%/lld-link.exe ^
-DCMAKE_AR=%stage0_bin_dir%/llvm-lib.exe ^
-DCMAKE_RC=%stage0_bin_dir%/llvm-windres.exe ^
-DCPACK_SYSTEM_NAME=woa64
set cmake_flags=%all_cmake_flags:\=/%

mkdir build_arm64
cd build_arm64
cmake -GNinja %cmake_flags% %llvm_src%\llvm || exit /b 1
ninja || exit /b 1
REM Check but do not fail on errors.
ninja check-lldb
::ninja check-llvm || exit /b 1
::ninja check-clang || exit /b 1
::ninja check-lld || exit /b 1
::ninja check-sanitizer || exit /b 1
::ninja check-clang-tools || exit /b 1
::ninja check-clangd || exit /b 1
ninja package || exit /b 1
cd ..

exit /b 0
::==============================================================================
::
::==============================================================================
:: Set PATH and some environment variables.
::==============================================================================
Expand Down