[llvm] [llvm][release] Modernize the Windows release script (PR #228528)
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 2 11:55:54 PDT 2026
================
@@ -0,0 +1,2342 @@
+#!/usr/bin/env pwsh
+<#
+.SYNOPSIS
+ Script for building the LLVM installer on Windows,
+ used for the releases at https://github.com/llvm/llvm-project/releases
+
+.DESCRIPTION
+ Builds LLVM release packages for Windows (x64, arm64).
+ Performs a 2-stage build with a ThinLTO final stage and optional PGO.
+ Can bootstrap a fresh VM by installing all prerequisites.
+
+ By default, builds x64 using the local source tree and auto-detected
+ Python. Use -DownloadSource to download a tagged release tarball
+ instead.
+
+ Build steps (in order):
+ 1. libxml2 - Build libxml2, zlib, and zstd (inside stage 1 directory)
+ 2. stage1 - Build the stage 1 bootstrap compiler with the host compiler
+ 3. pgo - PGO instrumented build + training + profile merge
+ 4. stage2 - Build the stage 2 self-hosted compiler with stage 1 clang
+ 5. package - Create WiX MSI installer
+ 6. tarball - Generate full install tarball
+
+.PARAMETER Version
+ LLVM version string (e.g. "19.1.0"). If omitted, auto-detected from
+ the source tree.
+
+.PARAMETER x64
+ Build for x64 (64-bit). This is the default if no architecture is specified.
+
+.PARAMETER arm64
+ Build for ARM64 (AArch64).
+
+.PARAMETER DownloadSource
+ Download and extract the tagged release source tarball from GitHub
+ instead of using the local source tree. Requires -Version.
+
+.PARAMETER ForceMSVC
+ Force using MSVC (cl.exe) as the stage 0 host compiler instead of the
+ official LLVM release. Skips the LLVM release prerequisite.
+
+.PARAMETER FastBuild
+ Build only the stage 1 tools needed by stage 2 and skip the remaining
+ stage 1 targets, stage 1 tests, and PGO. Stage 2 tests still run.
+
+.PARAMETER InstallPrerequisites
+ Install build prerequisites (NetFx3, Visual Studio, official LLVM release,
+ CMake, Python and its psutil module, etc.)
+ before building. When used with -arm64, also installs ARM64 Python for
+ LLDB. Requests administrator elevation once for the entire prerequisite
+ installation when the current shell is not elevated.
+
+.PARAMETER Unattended
+ Never prompt for input. Missing prerequisites cause the build to fail
+ unless -InstallPrerequisites is also specified. An existing build
+ directory must be resumed with -StartAt or removed beforehand. Run
+ from an elevated shell when using -InstallPrerequisites.
+
+.PARAMETER StartAt
+ Resume a previous build from a specific step. Artifacts from earlier
+ steps must already exist on disk. The step being restarted gets a
+ clean directory; earlier steps are skipped entirely.
+
+ Valid steps: libxml2, stage1, pgo, stage2, package, tarball
+
+ Pass an empty string (-StartAt "") or "?" (-StartAt "?") to display
+ the list of available steps and exit.
+
+.PARAMETER Help
+ Display this help message and exit.
+
+.EXAMPLE
+ .\build_llvm_release.ps1
+ Full x64 build using the local source tree.
+
+.EXAMPLE
+ .\build_llvm_release.ps1 -x64 -arm64
+ Build for both x64 and ARM64.
+
+.EXAMPLE
+ .\build_llvm_release.ps1 -Version 19.1.0 -DownloadSource
+ Download version 19.1.0 sources and build x64.
+
+.EXAMPLE
+ .\build_llvm_release.ps1 -InstallPrerequisites -x64
+ Install prerequisites, then do a full x64 build.
+
+.EXAMPLE
+ .\build_llvm_release.ps1 -InstallPrerequisites -x64 -arm64
+ Install prerequisites (including ARM64 Python), then build both architectures.
+
+.EXAMPLE
+ .\build_llvm_release.ps1 -Unattended -InstallPrerequisites
+ From an elevated shell, install prerequisites and build without prompts.
+
+.EXAMPLE
+ .\build_llvm_release.ps1 -x64 -StartAt stage2
+ Resume from stage 2 (reuses the stage 1 bootstrap compiler and PGO profile).
+
+.EXAMPLE
+ .\build_llvm_release.ps1 -x64 -StartAt package
+ Resume at WiX MSI packaging, then regenerate the portable archive.
+
+.EXAMPLE
+ .\build_llvm_release.ps1 -StartAt ""
+ Display the list of available build steps and exit.
+
+.NOTES
+ Python is auto-detected from PATH for x64 builds. For ARM64 builds,
+ the script probes standard install locations for ARM64 Python. Use
+ -InstallPrerequisites to install it automatically.
+
+ Environment variables:
+ LLVM_NINJA_OVERRIDE - Override the ninja binary and optionally provide
+ extra flags. The first token is the executable,
+ remaining tokens are prepended to every ninja
+ invocation.
+ Example: LLVM_NINJA_OVERRIDE="myninja.exe --flag1 --flag2"
+#>
+
+param(
+ [string]$Version,
+ [switch]$x64,
+ [switch]$arm64,
+ [switch]$DownloadSource,
+ [switch]$ForceMSVC,
+ [switch]$FastBuild,
+ [switch]$InstallPrerequisites,
+ [switch]$Unattended,
+ [switch]$PrerequisitesOnly, # Internal mode for the elevated installer.
+ [string]$StartAt,
+ [switch]$Help
+)
+
+#===============================================================================
+# PowerShell 7 self-relaunch
+#
+# This script requires PowerShell 7+ features (ternary operator, null-
+# coalescing, improved error handling, etc.). If we detect we are running
+# under Windows PowerShell 5.x, we attempt to find or install PowerShell 7
+# and re-launch ourselves under it, forwarding all original arguments.
+#===============================================================================
+if ($PSVersionTable.PSVersion.Major -lt 7) {
----------------
aganea wrote:
I feel this is "standard" behavior as far as I am concerned. This is mostly to ease the user experience, if we start the `.ps1` directly on a clean image that doesn't have Powershell 7 installed. It would install it and re-start the script. We can fail here indeed, but the user would still need to install/upgrade Powershell manually, which I wanted to avoid.
https://github.com/llvm/llvm-project/pull/228528
More information about the llvm-commits
mailing list