Skip to content

gh-159521: Enable tail-calling interpreter on Windows ARM64 - #162279

Merged
diegorusso merged 4 commits into
python:mainfrom
diegorusso:winarm64-tail-call
Nov 24, 2026
Merged

diegorusso merged 4 commits into
python:mainfrom
diegorusso:winarm64-tail-call

Conversation

@diegorusso

@diegorusso diegorusso commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

The Windows on Arm image on GitHub runners ships Visual Studio 2026 18.12 with MSVC 14.52, which supports __preserve_none and [[msvc::musttail]] on native ARM64.

Microsoft release notes: https://learn.microsoft.com/en-us/visualstudio/releases/2026/release-notes

@python-cla-bot

python-cla-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@diegorusso

Copy link
Copy Markdown
Contributor Author

Apologies for the force push, the commit's email was wrong 😅

@diegorusso

Copy link
Copy Markdown
Contributor Author

I had to change reusable-windows.yml‎ to select the right native toolchain on arm64 because find_msbuild.bat returned the x86 one. I think the best solution is to change the find_msbuild.bat to select the right native toolchain to do the compilation of CPython. I leave though the last word to @zooba :)

manoelcalixto added a commit to Electivus/pstack-claude that referenced this pull request Nov 19, 2026
…ntext has reported (#41)

## What and why

- `watch-pr` must not call a pending check advisory while a required
check has not reported yet.
#38 built the required
set only from checks already on the head commit. python/cpython requires
"All required checks pass", a job GitHub creates only after the build
and test jobs finish. Until then every pending check was called
advisory, and a PR held as blocked stopped the watcher with a merge-gate
blocker and exit 6 instead of a wait.
- The lookup in the port-only `watch-pr/advisory.ts` now adds the status
checks that the base branch's rulesets and classic branch protection
require. It names an advisory set only when every required check has
reported, and on the `gh pr checks` path only when each one is in the
list it labels.
- Classic protection comes from `GET
repos/{owner}/{repo}/branches/{base}`, not from the protection endpoint.
The protection endpoint answers 404 to a reader without admin rights, as
it did on python/cpython, so reading 404 as "no protection" would keep
the bug.
- If either read fails, every pending check counts as required, as
before #38. #38's intent stays: when the required checks are green and
only advisory ones are pending, the watcher says so and does not report
`READY`.
- Released as 0.9.148 (0.9.147 went to #39). No upstream-owned file
changed, so `tools/forks.json` needs no update.

## Linked issue

Related to #10. Fixes the regression from
#38.

## Test run

```text
scripts: bun install --frozen-lockfile: ok
scripts: bun run typecheck: ok, no errors
scripts: bun test watch-pr check-plan.test.ts: 249 pass, 0 fail
scripts: bunx prettier@3.6.2 --check .: all files use Prettier code style
red: watch-pr/advisory.cli.test.ts on the test-only commit: 1 pass, 3 fail (exit 6 merge-blocked, "advisory": true)
root: bun install --frozen-lockfile; bun install --frozen-lockfile --cwd plugins: ok
root: bun tools/generate.mjs --check: ok
root: bun test tests/: 2205 pass, 161 skip, 0 fail
root: bun tools/sync.mjs --check-rules: ok, 99 rules match
root: bun tools/ci-local.mjs: all CI lint jobs pass
root: bun tools/check-release.mjs origin/main: ok, 0.9.147 to 0.9.148
live, before (0.9.146), python/cpython#162283 mid-CI:
  --status-only: "required green, 25 advisory pending" beside "blocked"
  --timeout 45: BLOCKER: merge-blocked, exit 6
live, after, same PR, "All required checks pass" not yet created (final head):
  --timeout 45: WAITING: frontier=#162283; 7 checks pending / TIMEOUT: checks still pending, exit 5
live: --status-only on Electivus/pstack-claude #39 and #40: rows print, CI green
live: ghRequiredNames called directly:
  #40: the 9 ruleset checks
  python/cpython#162279 (finished): the 7 classic-protection checks
  python/cpython#162283 (mid-CI): null
```

Not run live: the advisory verdict itself, on a PR whose required checks
have all reported while advisory checks are still pending. The direct
lookup calls above show the required set is read on both kinds of
protection. The verdict has unit and spawn tests only.

## Checklist

- [x] I ran `bun install --frozen-lockfile`, `bun tools/generate.mjs`,
and `bun test tests/`, and committed the generator's output.
- [x] `bun tools/generate.mjs --check` exits 0.
- [x] I changed model defaults only in `plugins/pstack/models.json`, and
every Pi model ID is in Pi's catalog for that provider. (No model
defaults changed.)
- [x] If `bun tools/check-release.mjs origin/main` reports a shipped
path, I ran `bun tools/release.mjs` and committed `VERSION`,
`CHANGES.md`, and the manifests it wrote.
- [x] If this touches `plugins/pstack/pi/`, `pi-tools.md`,
`plugins/pstack/hooks/`, `copilot-tools.md`, or `setup-pstack`, I ran
the runtime checks that
[CONTRIBUTING.md](https://github.com/Electivus/pstack-claude/blob/main/CONTRIBUTING.md#before-you-open-a-pr)
lists for those paths. (None touched.)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
manoelcalixto added a commit to Electivus/pstack-claude that referenced this pull request Nov 19, 2026
…cannot name (#47)

## What and why

- `watch-pr` must never call a check advisory while it still gates the
merge. It built the required set from `isRequired`, the ruleset's
`required_status_checks` rules, and classic protection, and skipped
every other ruleset rule. This repository's `main` ruleset also has a
`code_scanning` rule for CodeQL. It holds the merge on the "CodeQL"
check and the "Analyze (...)" jobs, and none of them is among the 9
required contexts. Once those 9 passed while CodeQL still ran, the
watcher could label the CodeQL checks advisory and stop with `BLOCKER:
merge-blocked`, exit 6, instead of waiting. #41 fixed the same failure
for a required context that had not reported yet.
- `parseRulesetContexts` in the port-only `watch-pr/advisory.ts` now
returns `null` when the ruleset holds a rule type outside
`RULES_WITH_NAMED_CHECKS`. That list holds `required_status_checks`,
which names its checks, and the types that hold the merge on no check,
taken from GitHub's [REST rules
reference](https://docs.github.com/en/rest/repos/rules?apiVersion=2022-11-28).
`readRequiredNames` then returns `null`, so every pending check counts
as required, as when a read fails.
- It is an allow-list, so a rule type GitHub adds later costs the
advisory label, never a false `merge-blocked`. Outside the list:
`code_scanning`, `workflows`, `code_quality`,
`license_compliance_scanning`, `merge_queue`, `required_deployments`.
`code_coverage` is inside, because GitHub documents that it "does not
wait for coverage uploads" and asks that the uploading check be a
required status check, which the watcher already reads.
`copilot_code_review` is inside, because it only requests a review.
- A narrower mapping from the `code_scanning` tool name to a check of
that name was rejected on evidence. On #44's head, the "CodeQL" check
(github-advanced-security) completed at 20:40:59 while "Analyze
(python)", "(javascript-typescript)" and "(java-kotlin)" ran until
20:41:21 to 20:41:33. With that mapping, "CodeQL" would read as required
and green, and the Analyze jobs, whose names no rule carries, would
still be called advisory.
- **Cost.** A base branch with such a rule gets no advisory label at
all, so on this repository the watcher waits on every pending check
again, as before 0.9.146. On #44 the last required context finished at
20:42:47 and the last non-required check at 20:43:56, and on this PR's
first head 22:15:41 and 22:16:14, so a watch here runs 30 to 70 seconds
longer before it reports. Repositories with only classic protection or
check-free rules keep the label.
- Released as 0.9.152, rebased onto main after 0.9.150 and 0.9.151
shipped. The code diff is unchanged. No upstream-owned file changed, so
`tools/forks.json` needs no update.

## Linked issue

Fixes #42

## Test run

```text
red: watch-pr/advisory.cli.test.ts on the test-only commit 2c4765f: 5 pass, 1 fail
  ruleset with code_scanning: expected TIMEOUT exit 5 pending-checks, got BLOCKER merge-gate merge-blocked exit 6
scripts: bun install --frozen-lockfile: ok
scripts: bun run typecheck: ok
scripts: bun test watch-pr check-plan.test.ts: 251 pass, 0 fail
scripts: bunx prettier@3.6.2 --check .: ok
scripts: bun watch-pr/live-merge-safety.mjs --live-disposable: 6 PASS, fixture repository deleted
root: bun install --frozen-lockfile; bun install --frozen-lockfile --cwd plugins: ok
root: bun tools/generate.mjs --check: ok, 62 generated files current
root: bun test tests/: 2241 pass, 95 skip, 2 fail, both in tests/worktree-audit.test.mjs, which this PR does not touch
  (the submodule test hit bun's default 5 s timeout; the 1 MiB git status test failed once, cause not established)
root: bun test --timeout 30000 tests/worktree-audit.test.mjs, CI's command: 175 pass, 0 fail; CI's macOS and Windows worktree audit jobs pass on 6e03a07
root: bun tools/ci-local.mjs: all CI lint jobs pass
root: bun tools/check-release.mjs origin/main: shipped path changed, released 0.9.149 to 0.9.150 at the first head; after the rebase, 0.9.151 to 0.9.152
live, read-only, ghRequiredNames called directly:
  #44 on 0.9.149: the 9 ruleset contexts
  #44 with this change: null
  python/cpython#162279 with this change: the 7 classic-protection contexts
live repro missed: on this PR's head the last Analyze job finished at 22:15:23 and the last
  required context ("Generated files current") at 22:15:41, so the window never opened; `gh run rerun` on the
  default-setup CodeQL run answers "This workflow run cannot be retried"
live, the cost, on this PR's head 9c519b0 with the 9 required contexts green and 4 other checks pending:
  0.9.149 --status-only: "required green, 4 advisory pending"; 45 s watch: TIMEOUT advisory-pending, exit 5
  this change --status-only: "4 pending"; the watch then waited and ended READY, exit 0, mergeStateStatus=CLEAN
```

Not run live: the verdict itself on a PR whose 9 required contexts
passed while CodeQL still ran. The spawn test that fails before the fix
and passes after, and the direct lookup calls above, stand in for it.

## Checklist

- [x] I ran `bun install --frozen-lockfile`, `bun tools/generate.mjs`,
and `bun test tests/`, and committed the generator's output.
- [x] `bun tools/generate.mjs --check` exits 0.
- [x] I changed model defaults only in `plugins/pstack/models.json`, and
every Pi model ID is in Pi's catalog for that provider. (No model
change.)
- [x] If `bun tools/check-release.mjs origin/main` reports a shipped
path, I ran `bun tools/release.mjs`. (0.9.152.)
- [x] If this touches `plugins/pstack/pi/`, `pi-tools.md`,
`plugins/pstack/hooks/`, `copilot-tools.md`, or `setup-pstack`, I ran
the runtime checks. (It touches none.)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01B94FjNwuVDaTeSu5Vgqeaf

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@diegorusso

Copy link
Copy Markdown
Contributor Author

I've debugged a little bit more the build/linker failure and I was able to reproduce it on my machine as well. Both Windows ARM64 Release tail-call jobs failed during link-time code generation.
Despite the native version being present, build.bat picked up the 32-bit MSBuild executable, which selected HostX86\arm64\link.exe.
That linker ran out of heap space (C1002) and the automatic retry with the x64-hosted linker finished code generation successfully. Unfortunately MSBuild had already recorded the error and still failed the build.

The change in the PR actually tells build.bat to use the native version of the toolchain if it is present in the image. Still, want to have a second opinion by @zooba of what the right fix is and if we need to report the issue to the MSVC team.

@diegorusso

diegorusso commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Ah, I see this might have been fixed here! 3d248a2 I've updated my branch and reverted the change in the workflow file.

@chris-eibl

Copy link
Copy Markdown
Member

Yupp, 14.52 is also affected and #162262 should fix it. The compiler bug is reported, see the associated issue for the link to the MSVC bug report.

I agree regarding find_msbuild.bat, especially since PreferredToolArchitecture does not work on ARM, see #153668 (comment) and #158244 (comment), having also the benefit that CI would be faster.

@diegorusso
diegorusso merged commit ebebe05 into python:main Nov 24, 2026
109 of 111 checks passed
@diegorusso
diegorusso deleted the winarm64-tail-call branch November 24, 2026 12:06
@diegorusso

Copy link
Copy Markdown
Contributor Author

Thanks everyone for the review, this is now merged.

@vzarytovskii

Copy link
Copy Markdown

Oh, nice to see if it's merged. I've implemented it for ARM in MSVC, feel free to reach out if you'll hit any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants