From b45060a6c867cab9dc2539f0e633d8b02fee6b77 Mon Sep 17 00:00:00 2001 From: Diego Russo Date: Thu, 19 Nov 2026 11:50:55 +0000 Subject: [PATCH 1/3] gh-159521: Enable tail-calling interpreter on Windows ARM64 --- .github/workflows/build.yml | 8 +++----- InternalDocs/interpreter.md | 5 +++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 50b0469867c1a4..a8e706608cafff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -167,14 +167,12 @@ jobs: - true interpreter: - switch-case + - tail-call exclude: # Skip Win32 on free-threaded builds - { arch: Win32, free-threading: true } - include: - # msvc::musttail is currently only supported on x64, - # and only supported on 3.15+. - - { arch: x64, free-threading: false, interpreter: tail-call } - - { arch: x64, free-threading: true, interpreter: tail-call } + # Skip Win32 on tail-call interpreter builds + - { arch: Win32, interpreter: tail-call } uses: $/.github/workflows/reusable-windows.yml with: arch: ${{ matrix.arch }} diff --git a/InternalDocs/interpreter.md b/InternalDocs/interpreter.md index fa89996aa65429..987ac7bbed181b 100644 --- a/InternalDocs/interpreter.md +++ b/InternalDocs/interpreter.md @@ -525,8 +525,9 @@ There are three different types of interpreters to choose from based on compiler [preserve_none](https://clang.llvm.org/docs/AttributeReference.html#preserve-none) calling convention between the small C functions that implement individual Python opcodes. - Not all compilers support these and if they do not all targets might be supported (for example, - MSVC currently only supports x64 and only in optimized builds). + Support depends on the compiler and target architecture. With MSVC, the + tail-calling interpreter is available only in optimized builds. The minimum + MSVC version is 14.50 for x64 and 14.52 for ARM64. In addition, compilers must do [escape analysis](https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#index-musttail) of the lifetimes of automatic variables, function parameters, and temporaries to ensure proper tail-calls. They From 3be9238f98752e73de2b60ac7256492ad12c51b4 Mon Sep 17 00:00:00 2001 From: Diego Russo Date: Thu, 19 Nov 2026 16:20:50 +0000 Subject: [PATCH 2/3] Select the native toolchain on Windows ARM64 --- .github/workflows/reusable-windows.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/reusable-windows.yml b/.github/workflows/reusable-windows.yml index eb6c22f2c4cf43..a03c1ff7b2fc88 100644 --- a/.github/workflows/reusable-windows.yml +++ b/.github/workflows/reusable-windows.yml @@ -37,6 +37,17 @@ jobs: - name: Register MSVC problem matcher if: inputs.arch != 'Win32' run: echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Select native ARM64 MSBuild + if: inputs.arch == 'arm64' + shell: pwsh + run: | + # The x86-hosted linker can run out of heap space during LTCG. + $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" + $msbuild = & $vswhere -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.ARM64 -find 'MSBuild\Current\Bin\arm64\MSBuild.exe' + if (!$msbuild -or !(Test-Path -LiteralPath $msbuild -PathType Leaf)) { + throw 'Native ARM64 MSBuild was not found.' + } + ('MSBUILD="{0}"' -f $msbuild) >> $env:GITHUB_ENV - name: Build CPython # msvc::musttail is not supported for debug builds, so we have to # switch to release. From 09601af68b060d95d054c9abf30cc0c4e3357e8b Mon Sep 17 00:00:00 2001 From: Diego Russo Date: Mon, 23 Nov 2026 13:44:14 +0000 Subject: [PATCH 3/3] Revert "Select the native toolchain on Windows ARM64" This reverts commit 3be9238f98752e73de2b60ac7256492ad12c51b4. --- .github/workflows/reusable-windows.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/reusable-windows.yml b/.github/workflows/reusable-windows.yml index a03c1ff7b2fc88..eb6c22f2c4cf43 100644 --- a/.github/workflows/reusable-windows.yml +++ b/.github/workflows/reusable-windows.yml @@ -37,17 +37,6 @@ jobs: - name: Register MSVC problem matcher if: inputs.arch != 'Win32' run: echo "::add-matcher::.github/problem-matchers/msvc.json" - - name: Select native ARM64 MSBuild - if: inputs.arch == 'arm64' - shell: pwsh - run: | - # The x86-hosted linker can run out of heap space during LTCG. - $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" - $msbuild = & $vswhere -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.ARM64 -find 'MSBuild\Current\Bin\arm64\MSBuild.exe' - if (!$msbuild -or !(Test-Path -LiteralPath $msbuild -PathType Leaf)) { - throw 'Native ARM64 MSBuild was not found.' - } - ('MSBUILD="{0}"' -f $msbuild) >> $env:GITHUB_ENV - name: Build CPython # msvc::musttail is not supported for debug builds, so we have to # switch to release.