[llvm] b7c81c1 - On Windows, make the release script work with the local git checkout (#78273)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 17 08:14:54 PST 2024


Author: Alexandre Ganea
Date: 2024-01-17T11:14:49-05:00
New Revision: b7c81c1f91994fb6938875b62337ddc2a49bfd51

URL: https://github.com/llvm/llvm-project/commit/b7c81c1f91994fb6938875b62337ddc2a49bfd51
DIFF: https://github.com/llvm/llvm-project/commit/b7c81c1f91994fb6938875b62337ddc2a49bfd51.diff

LOG: On Windows, make the release script work with the local git checkout (#78273)

Add two new flags to the release script:
  `--skip-checkout` builds from the local source folder, instead of the downloaded source package
  `--local-python` uses whichever local Python version is installed, instead of a specific version (3.10)

If the LLVM source is already in `C:\git\llvm-project` then one can do in a admin prompt:
```
C:\git>llvm-project\llvm\utils\release\build_llvm_release.bat --version 18.0.0 --x64 --skip-checkout
...
```
This allows for iterating more easily on build issues, just before a new LLVM package is made.

Also fix some warnings on the second stage build (`-Wbackend-plugin`).

Added: 
    

Modified: 
    llvm/utils/release/build_llvm_release.bat

Removed: 
    


################################################################################
diff  --git a/llvm/utils/release/build_llvm_release.bat b/llvm/utils/release/build_llvm_release.bat
index 2a1503eef8ae5c..67bb22de7606df 100755
--- a/llvm/utils/release/build_llvm_release.bat
+++ b/llvm/utils/release/build_llvm_release.bat
@@ -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]
+echo Usage: build_llvm_release.bat --version ^<version^> [--x86,--x64, --arm64] [--skip-checkout] [--local-python]
 echo.
 echo Options:
 echo --version: [required] version to build
@@ -15,6 +15,8 @@ echo --help: display this help
 echo --x86: build and test x86 variant
 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.
 echo Note: At least one variant to build is required.
 echo.
@@ -30,6 +32,8 @@ set help=
 set x86=
 set x64=
 set arm64=
+set skip-checkout=
+set local-python=
 call :parse_args %*
 
 if "%help%" NEQ "" goto usage
@@ -126,16 +130,23 @@ if exist %build_dir% (
 mkdir %build_dir%
 cd %build_dir% || exit /b 1
 
-echo Checking out %revision%
-curl -L https://github.com/llvm/llvm-project/archive/%revision%.zip -o src.zip || exit /b 1
-7z x src.zip || exit /b 1
-mv llvm-project-* llvm-project || exit /b 1
+if "%skip-checkout%" == "true" (
+  echo Using local source
+  set llvm_src=%~dp0..\..\..
+) else (
+  echo Checking out %revision%
+  curl -L https://github.com/llvm/llvm-project/archive/%revision%.zip -o src.zip || exit /b 1
+  7z x src.zip || exit /b 1
+  mv llvm-project-* llvm-project || exit /b 1
+  set llvm_src=%build_dir%\llvm-project
+)
 
 curl -O https://gitlab.gnome.org/GNOME/libxml2/-/archive/v2.9.12/libxml2-v2.9.12.tar.gz || exit /b 1
 tar zxf libxml2-v2.9.12.tar.gz
 
 REM Setting CMAKE_CL_SHOWINCLUDES_PREFIX to work around PR27226.
 REM Common flags for all builds.
+set common_compiler_flags=-DLIBXML_STATIC
 set common_cmake_flags=^
   -DCMAKE_BUILD_TYPE=Release ^
   -DLLVM_ENABLE_ASSERTIONS=OFF ^
@@ -150,11 +161,11 @@ set common_cmake_flags=^
   -DLLVM_ENABLE_LIBXML2=FORCE_ON ^
   -DLLDB_ENABLE_LIBXML2=OFF ^
   -DCLANG_ENABLE_LIBXML2=OFF ^
-  -DCMAKE_C_FLAGS="-DLIBXML_STATIC" ^
-  -DCMAKE_CXX_FLAGS="-DLIBXML_STATIC" ^
+  -DCMAKE_C_FLAGS="%common_compiler_flags%" ^
+  -DCMAKE_CXX_FLAGS="%common_compiler_flags%" ^
   -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;compiler-rt;lldb;openmp"
 
-set cmake_profile_flag=""
+set cmake_profile_flags=""
 
 REM Preserve original path
 set OLDPATH=%PATH%
@@ -186,7 +197,7 @@ set cmake_flags=^
   -DLIBXML2_INCLUDE_DIRS=%libxmldir%/include/libxml2 ^
   -DLIBXML2_LIBRARIES=%libxmldir%/lib/libxml2s.lib
 
-cmake -GNinja %cmake_flags% ..\llvm-project\llvm || exit /b 1
+cmake -GNinja %cmake_flags% %llvm_src%\llvm || exit /b 1
 ninja || ninja || ninja || exit /b 1
 REM ninja check-llvm || ninja check-llvm || ninja check-llvm || exit /b 1
 REM ninja check-clang || ninja check-clang || ninja check-clang || exit /b 1
@@ -208,7 +219,7 @@ set cmake_flags=%all_cmake_flags:\=/%
 
 mkdir build32
 cd build32
-cmake -GNinja %cmake_flags% ..\llvm-project\llvm || exit /b 1
+cmake -GNinja %cmake_flags% %llvm_src%\llvm || exit /b 1
 ninja || ninja || ninja || exit /b 1
 REM ninja check-llvm || ninja check-llvm || ninja check-llvm || exit /b 1
 REM ninja check-clang || ninja check-clang || ninja check-clang || exit /b 1
@@ -242,7 +253,7 @@ set cmake_flags=^
   -DLIBXML2_INCLUDE_DIRS=%libxmldir%/include/libxml2 ^
   -DLIBXML2_LIBRARIES=%libxmldir%/lib/libxml2s.lib
 
-cmake -GNinja %cmake_flags% ..\llvm-project\llvm || exit /b 1
+cmake -GNinja %cmake_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
@@ -267,7 +278,7 @@ set cmake_flags=%all_cmake_flags:\=/%
 mkdir build64
 cd build64
 call :do_generate_profile || exit /b 1
-cmake -GNinja %cmake_flags% %cmake_profile_flag% ..\llvm-project\llvm || exit /b 1
+cmake -GNinja %cmake_flags% %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
@@ -307,7 +318,7 @@ 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-project\llvm || exit /b 1
+  %llvm_src%\llvm || exit /b 1
 ninja || exit /b 1
 ::ninja check-llvm || exit /b 1
 ::ninja check-clang || exit /b 1
@@ -332,7 +343,7 @@ set cmake_flags=%all_cmake_flags:\=/%
 
 mkdir build_arm64
 cd build_arm64
-cmake -GNinja %cmake_flags% ..\llvm-project\llvm || exit /b 1
+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
@@ -358,8 +369,13 @@ set PATH=%OLDPATH%
 set python_dir=%1
 
 REM Set Python environment
-%python_dir%/python.exe --version || exit /b 1
-set PYTHONHOME=%python_dir%
+if "%local-python%" == "true" (
+  FOR /F "delims=" %%i IN ('where python.exe ^| head -1') DO set python_exe=%%i
+  set PYTHONHOME=!python_exe:~0,-11!
+) else (
+  %python_dir%/python.exe --version || exit /b 1
+  set PYTHONHOME=%python_dir%
+)
 set PATH=%PYTHONHOME%;%PATH%
 
 set "VSCMD_START_DIR=%build_dir%"
@@ -402,7 +418,7 @@ REM Build Clang with instrumentation.
 mkdir instrument
 cd instrument
 cmake -GNinja %cmake_flags% -DLLVM_TARGETS_TO_BUILD=Native ^
-  -DLLVM_BUILD_INSTRUMENTED=IR ..\..\llvm-project\llvm || exit /b 1
+  -DLLVM_BUILD_INSTRUMENTED=IR %llvm_src%\llvm || exit /b 1
 ninja clang || ninja clang || ninja clang || exit /b 1
 set instrumented_clang=%cd:\=/%/bin/clang-cl.exe
 cd ..
@@ -414,14 +430,17 @@ cmake -GNinja %cmake_flags% ^
   -DCMAKE_CXX_COMPILER=%instrumented_clang% ^
   -DLLVM_ENABLE_PROJECTS=clang ^
   -DLLVM_TARGETS_TO_BUILD=Native ^
-  ..\..\llvm-project\llvm || exit /b 1
+  %llvm_src%\llvm || exit /b 1
 REM Drop profiles generated from running cmake; those are not representative.
 del ..\instrument\profiles\*.profraw
 ninja tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/Sema.cpp.obj
 cd ..
 set profile=%cd:\=/%/profile.profdata
 %stage0_bin_dir%\llvm-profdata merge -output=%profile% instrument\profiles\*.profraw || exit /b 1
-set cmake_profile_flag=-DLLVM_PROFDATA_FILE=%profile%
+set common_compiler_flags=%common_compiler_flags% -Wno-backend-plugin
+set cmake_profile_flags=-DLLVM_PROFDATA_FILE=%profile% ^
+  -DCMAKE_C_FLAGS="%common_compiler_flags%" ^
+  -DCMAKE_CXX_FLAGS="%common_compiler_flags%"
 exit /b 0
 
 ::=============================================================================


        


More information about the llvm-commits mailing list