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
22 changes: 21 additions & 1 deletion llvm/utils/release/build_llvm_release.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ goto begin
echo Script for building the LLVM installer on Windows,
echo used for the releases at https://github.com/llvm/llvm-project/releases
echo.
echo Usage: build_llvm_release.bat --version ^<version^> [--x86,--x64, --arm64] [--skip-checkout] [--local-python]
echo Usage: build_llvm_release.bat --version ^<version^> [--x86,--x64, --arm64] [--skip-checkout] [--local-python] [--force-msvc]
echo.
echo Options:
echo --version: [required] version to build
Expand All @@ -17,6 +17,7 @@ echo --x64: build and test x64 variant
echo --arm64: build and test arm64 variant
echo --skip-checkout: use local git checkout instead of downloading src.zip
echo --local-python: use installed Python and does not try to use a specific version (3.10)
echo --force-msvc: use MSVC compiler for stage0, even if clang-cl is present
echo.
echo Note: At least one variant to build is required.
echo.
Expand All @@ -34,6 +35,7 @@ set x64=
set arm64=
set skip-checkout=
set local-python=
set force-msvc=
call :parse_args %*

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

if "%force-msvc%" == "" (
where /q clang-cl
if errorlevel 0 (
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose I should have caught this in review, but I ran into it when building 20.1.0-rc1 instead :-)

Apparently if errorlevel 0 will succeed if the error level is >= 0, i.e. in our case we will take the branch also when where /q clang-cl is not successful. (E.g. https://devblogs.microsoft.com/oldnewthing/20080926-00/?p=20743)

I'll work around this by passing --force-msvc, but it also needs to be fixed.

where /q lld-link
if errorlevel 0 (
set common_compiler_flags=%common_compiler_flags% -fuse-ld=lld

set common_cmake_flags=%common_cmake_flags%^
-DCMAKE_C_COMPILER=clang-cl.exe ^
-DCMAKE_CXX_COMPILER=clang-cl.exe ^
-DCMAKE_LINKER=lld-link.exe ^
-DLLVM_ENABLE_LLD=ON ^
-DCMAKE_C_FLAGS="%common_compiler_flags%" ^
-DCMAKE_CXX_FLAGS="%common_compiler_flags%"
)
)
)

set cmake_profile_flags=""

REM Preserve original path
Expand Down