Skip to content

Commit 7cb7b2d

Browse files
authored
[llvm] Build Windows release package with clang-cl if possible (#135446)
If `clang-cl.exe` and `lld-link.exe` are installed in `%PATH%`, the Windows release build script will now use these by default, in place of MSVC. The reason for doing this is that MSVC still has, for the past year(s), a O(N^2) behavior when building certain LLVM source files, which leads to long build times (minutes per file). A report was filled here: https://developercommunity.visualstudio.com/t/ON2-in-SparseBitVectorBase-when-com/10657991 Also added a `--force-msvc` option to the script, to use MSVC even if clang-cl is installed.
1 parent 9c73eba commit 7cb7b2d

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

llvm/utils/release/build_llvm_release.bat

+21-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ goto begin
77
echo Script for building the LLVM installer on Windows,
88
echo used for the releases at https://github.com/llvm/llvm-project/releases
99
echo.
10-
echo Usage: build_llvm_release.bat --version ^<version^> [--x86,--x64, --arm64] [--skip-checkout] [--local-python]
10+
echo Usage: build_llvm_release.bat --version ^<version^> [--x86,--x64, --arm64] [--skip-checkout] [--local-python] [--force-msvc]
1111
echo.
1212
echo Options:
1313
echo --version: [required] version to build
@@ -17,6 +17,7 @@ echo --x64: build and test x64 variant
1717
echo --arm64: build and test arm64 variant
1818
echo --skip-checkout: use local git checkout instead of downloading src.zip
1919
echo --local-python: use installed Python and does not try to use a specific version (3.10)
20+
echo --force-msvc: use MSVC compiler for stage0, even if clang-cl is present
2021
echo.
2122
echo Note: At least one variant to build is required.
2223
echo.
@@ -34,6 +35,7 @@ set x64=
3435
set arm64=
3536
set skip-checkout=
3637
set local-python=
38+
set force-msvc=
3739
call :parse_args %*
3840

3941
if "%help%" NEQ "" goto usage
@@ -165,6 +167,24 @@ set common_cmake_flags=^
165167
-DLLVM_ENABLE_RPMALLOC=ON ^
166168
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;compiler-rt;lldb;openmp"
167169

170+
if "%force-msvc%" == "" (
171+
where /q clang-cl
172+
if errorlevel 0 (
173+
where /q lld-link
174+
if errorlevel 0 (
175+
set common_compiler_flags=%common_compiler_flags% -fuse-ld=lld
176+
177+
set common_cmake_flags=%common_cmake_flags%^
178+
-DCMAKE_C_COMPILER=clang-cl.exe ^
179+
-DCMAKE_CXX_COMPILER=clang-cl.exe ^
180+
-DCMAKE_LINKER=lld-link.exe ^
181+
-DLLVM_ENABLE_LLD=ON ^
182+
-DCMAKE_C_FLAGS="%common_compiler_flags%" ^
183+
-DCMAKE_CXX_FLAGS="%common_compiler_flags%"
184+
)
185+
)
186+
)
187+
168188
set cmake_profile_flags=""
169189

170190
REM Preserve original path

0 commit comments

Comments
 (0)