[llvm] c5e1000 - Add build for Windows on Arm in packaging script

Muhammad Omair Javaid via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 13 01:37:10 PST 2023


Author: Pierrick Bouvier
Date: 2023-02-13T14:36:37+05:00
New Revision: c5e1000b291540587d656ff00190f965af3fffd1

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

LOG: Add build for Windows on Arm in packaging script

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D142983

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 9ffcf9c098b2b..e83e4c9991b29 100755
--- a/llvm/utils/release/build_llvm_release.bat
+++ b/llvm/utils/release/build_llvm_release.bat
@@ -7,13 +7,14 @@ 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]
+echo Usage: build_llvm_release.bat --version ^<version^> [--x86,--x64, --arm64]
 echo.
 echo Options:
 echo --version: [required] version to build
 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.
 echo Note: At least one variant to build is required.
 echo.
@@ -28,6 +29,7 @@ set version=
 set help=
 set x86=
 set x64=
+set arm64=
 call :parse_args %*
 
 if "%help%" NEQ "" goto usage
@@ -38,9 +40,9 @@ if "%version%" == "" (
     goto usage
 )
 
-if "%x64%" == "" if "%x86%" == "" (
+if "%arm64%" == "" if "%x64%" == "" if "%x86%" == "" (
     echo nothing to build!
-    echo choose one or several variants from: --x86 --x64
+    echo choose one or several variants from: --x86 --x64 --arm64
     exit /b 1
 )
 
@@ -107,6 +109,7 @@ echo Using VS devcmd: %vsdevcmd%
 
 set python32_dir=C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310-32
 set python64_dir=C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310
+set pythonarm64_dir=C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python311-arm64
 
 set revision=llvmorg-%version%
 set package_version=%version%
@@ -133,7 +136,7 @@ curl -O https://gitlab.gnome.org/GNOME/libxml2/-/archive/v2.9.12/libxml2-v2.9.12
 tar zxf libxml2-v2.9.12.tar.gz
 
 REM Setting CMAKE_CL_SHOWINCLUDES_PREFIX to work around PR27226.
-REM Common flags for both 32/64 builds.
+REM Common flags for all builds.
 set common_cmake_flags=^
   -DCMAKE_BUILD_TYPE=Release ^
   -DLLVM_ENABLE_ASSERTIONS=OFF ^
@@ -157,35 +160,19 @@ 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
 exit /b 0
 
 ::==============================================================================
 :: Build 32-bits binaries.
 ::==============================================================================
 :do_build_32
-REM Restore original path
-set PATH=%OLDPATH%
-
-REM TODO: Run the "check-all" tests.
-
-REM Set Python environment
-set PYTHONHOME=%python32_dir%
-set PATH=%PYTHONHOME%;%PATH%
-%python32_dir%/python.exe --version || exit /b 1
-
-set "VSCMD_START_DIR=%build_dir%"
+call :set_environment %python32_dir% || exit /b 1
 call "%vsdevcmd%" -arch=x86 || exit /b 1
 @echo on
 mkdir build32_stage0
 cd build32_stage0
-
-mkdir libxmlbuild
-cd libxmlbuild
-cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DBUILD_SHARED_LIBS=OFF -DLIBXML2_WITH_C14N=OFF -DLIBXML2_WITH_CATALOG=OFF -DLIBXML2_WITH_DEBUG=OFF -DLIBXML2_WITH_DOCB=OFF -DLIBXML2_WITH_FTP=OFF -DLIBXML2_WITH_HTML=OFF -DLIBXML2_WITH_HTTP=OFF -DLIBXML2_WITH_ICONV=OFF -DLIBXML2_WITH_ICU=OFF -DLIBXML2_WITH_ISO8859X=OFF -DLIBXML2_WITH_LEGACY=OFF -DLIBXML2_WITH_LZMA=OFF -DLIBXML2_WITH_MEM_DEBUG=OFF -DLIBXML2_WITH_MODULES=OFF -DLIBXML2_WITH_OUTPUT=ON -DLIBXML2_WITH_PATTERN=OFF -DLIBXML2_WITH_PROGRAMS=OFF -DLIBXML2_WITH_PUSH=OFF -DLIBXML2_WITH_PYTHON=OFF -DLIBXML2_WITH_READER=OFF -DLIBXML2_WITH_REGEXPS=OFF -DLIBXML2_WITH_RUN_DEBUG=OFF -DLIBXML2_WITH_SAX1=OFF -DLIBXML2_WITH_SCHEMAS=OFF -DLIBXML2_WITH_SCHEMATRON=OFF -DLIBXML2_WITH_TESTS=OFF -DLIBXML2_WITH_THREADS=ON -DLIBXML2_WITH_THREAD_ALLOC=OFF -DLIBXML2_WITH_TREE=ON -DLIBXML2_WITH_VALID=OFF -DLIBXML2_WITH_WRITER=OFF -DLIBXML2_WITH_XINCLUDE=OFF -DLIBXML2_WITH_XPATH=OFF -DLIBXML2_WITH_XPTR=OFF -DLIBXML2_WITH_ZLIB=OFF ../../libxml2-v2.9.12 || exit /b 1
-ninja install || exit /b 1
-set libxmldir=%cd%\install
-set "libxmldir=%libxmldir:\=/%"
-cd ..
+call :do_build_libxml || exit /b 1
 
 REM Stage0 binaries directory; used in stage1.
 set "stage0_bin_dir=%build_dir%/build32_stage0/bin"
@@ -236,27 +223,12 @@ exit /b 0
 :: Build 64-bits binaries.
 ::==============================================================================
 :do_build_64
-REM Restore original path
-set PATH=%OLDPATH%
-
-REM Set Python environment
-set PYTHONHOME=%python64_dir%
-set PATH=%PYTHONHOME%;%PATH%
-%python64_dir%/python.exe --version || exit /b 1
-
-set "VSCMD_START_DIR=%build_dir%"
+call :set_environment %python64_dir% || exit /b 1
 call "%vsdevcmd%" -arch=amd64 || exit /b 1
 @echo on
 mkdir build64_stage0
 cd build64_stage0
-
-mkdir libxmlbuild
-cd libxmlbuild
-cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DBUILD_SHARED_LIBS=OFF -DLIBXML2_WITH_C14N=OFF -DLIBXML2_WITH_CATALOG=OFF -DLIBXML2_WITH_DEBUG=OFF -DLIBXML2_WITH_DOCB=OFF -DLIBXML2_WITH_FTP=OFF -DLIBXML2_WITH_HTML=OFF -DLIBXML2_WITH_HTTP=OFF -DLIBXML2_WITH_ICONV=OFF -DLIBXML2_WITH_ICU=OFF -DLIBXML2_WITH_ISO8859X=OFF -DLIBXML2_WITH_LEGACY=OFF -DLIBXML2_WITH_LZMA=OFF -DLIBXML2_WITH_MEM_DEBUG=OFF -DLIBXML2_WITH_MODULES=OFF -DLIBXML2_WITH_OUTPUT=ON -DLIBXML2_WITH_PATTERN=OFF -DLIBXML2_WITH_PROGRAMS=OFF -DLIBXML2_WITH_PUSH=OFF -DLIBXML2_WITH_PYTHON=OFF -DLIBXML2_WITH_READER=OFF -DLIBXML2_WITH_REGEXPS=OFF -DLIBXML2_WITH_RUN_DEBUG=OFF -DLIBXML2_WITH_SAX1=OFF -DLIBXML2_WITH_SCHEMAS=OFF -DLIBXML2_WITH_SCHEMATRON=OFF -DLIBXML2_WITH_TESTS=OFF -DLIBXML2_WITH_THREADS=ON -DLIBXML2_WITH_THREAD_ALLOC=OFF -DLIBXML2_WITH_TREE=ON -DLIBXML2_WITH_VALID=OFF -DLIBXML2_WITH_WRITER=OFF -DLIBXML2_WITH_XINCLUDE=OFF -DLIBXML2_WITH_XPATH=OFF -DLIBXML2_WITH_XPTR=OFF -DLIBXML2_WITH_ZLIB=OFF ../../libxml2-v2.9.12 || exit /b 1
-ninja install || exit /b 1
-set libxmldir=%cd%\install
-set "libxmldir=%libxmldir:\=/%"
-cd ..
+call :do_build_libxml || exit /b 1
 
 REM Stage0 binaries directory; used in stage1.
 set "stage0_bin_dir=%build_dir%/build64_stage0/bin"
@@ -305,6 +277,119 @@ cd ..
 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
+ at 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_DIRS=%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-project\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-project\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.
+::==============================================================================
+:set_environment
+REM Restore original path
+set PATH=%OLDPATH%
+
+set python_dir=%1
+
+REM Set Python environment
+%python_dir%/python.exe --version || exit /b 1
+set PYTHONHOME=%python_dir%
+set PATH=%PYTHONHOME%;%PATH%
+
+set "VSCMD_START_DIR=%build_dir%"
+
+exit /b 0
+
+::=============================================================================
+
+::==============================================================================
+:: Build libxml.
+::==============================================================================
+:do_build_libxml
+mkdir libxmlbuild
+cd libxmlbuild
+cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install ^
+  -DBUILD_SHARED_LIBS=OFF -DLIBXML2_WITH_C14N=OFF -DLIBXML2_WITH_CATALOG=OFF ^
+  -DLIBXML2_WITH_DEBUG=OFF -DLIBXML2_WITH_DOCB=OFF -DLIBXML2_WITH_FTP=OFF ^
+  -DLIBXML2_WITH_HTML=OFF -DLIBXML2_WITH_HTTP=OFF -DLIBXML2_WITH_ICONV=OFF ^
+  -DLIBXML2_WITH_ICU=OFF -DLIBXML2_WITH_ISO8859X=OFF -DLIBXML2_WITH_LEGACY=OFF ^
+  -DLIBXML2_WITH_LZMA=OFF -DLIBXML2_WITH_MEM_DEBUG=OFF -DLIBXML2_WITH_MODULES=OFF ^
+  -DLIBXML2_WITH_OUTPUT=ON -DLIBXML2_WITH_PATTERN=OFF -DLIBXML2_WITH_PROGRAMS=OFF ^
+  -DLIBXML2_WITH_PUSH=OFF -DLIBXML2_WITH_PYTHON=OFF -DLIBXML2_WITH_READER=OFF ^
+  -DLIBXML2_WITH_REGEXPS=OFF -DLIBXML2_WITH_RUN_DEBUG=OFF -DLIBXML2_WITH_SAX1=OFF ^
+  -DLIBXML2_WITH_SCHEMAS=OFF -DLIBXML2_WITH_SCHEMATRON=OFF -DLIBXML2_WITH_TESTS=OFF ^
+  -DLIBXML2_WITH_THREADS=ON -DLIBXML2_WITH_THREAD_ALLOC=OFF -DLIBXML2_WITH_TREE=ON ^
+  -DLIBXML2_WITH_VALID=OFF -DLIBXML2_WITH_WRITER=OFF -DLIBXML2_WITH_XINCLUDE=OFF ^
+  -DLIBXML2_WITH_XPATH=OFF -DLIBXML2_WITH_XPTR=OFF -DLIBXML2_WITH_ZLIB=OFF ^
+  ../../libxml2-v2.9.12 || exit /b 1
+ninja install || exit /b 1
+set libxmldir=%cd%\install
+set "libxmldir=%libxmldir:\=/%"
+cd ..
+
+exit /b 0
 ::=============================================================================
 :: Parse command line arguments.
 :: The format for the arguments is:


        


More information about the llvm-commits mailing list