GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-130039: Tailcall for windows builds by Fidget-Spinner · Pull Request #130040 · python/cpython

Conversation

@Fidget-Spinner

@Fidget-Spinner Fidget-Spinner commented Feb 12, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Tail calling interpreter for Windows #130039

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

colesbury, Wulian233, and chris-eibl reacted with hooray emoji
All reactions
  • 🎉 3 reactions
Fidget-Spinner added 3 commits February 12, 2025 20:54
@Fidget-Spinner
Tail-calling flag for Window
ab0a611
@Fidget-Spinner
Update pythoncore.vcxproj
d57c175
@Fidget-Spinner
Add Windows to the tailcall CI
3eb568f
@Fidget-Spinner
Fidget-Spinner requested review from a team, AA-Turner, ezio-melotti and hugovk as code owners February 12, 2025 13:58
@bedevere-app bedevere-app Bot added the awaiting core review label Feb 12, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Feb 12, 2025
Tail calling interpreter for Windows #130039
Closed
@Fidget-Spinner
Fidget-Spinner requested a review from mdboom February 12, 2025 13:58
@Fidget-Spinner
Update tail-call.yml
4dd19cf
@Fidget-Spinner Fidget-Spinner added the skip news label Feb 12, 2025
@Fidget-Spinner

Fidget-Spinner commented Feb 12, 2025

Copy link
Copy Markdown
Member Author

@mdboom I'm baffled by the error in the CI. By any chance do you know how to fix it? https://github.com/python/cpython/actions/runs/13287244377/job/37098802007?pr=130040

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mdboom

mdboom commented Feb 12, 2025

Copy link
Copy Markdown
Contributor

@mdboom I'm baffled by the error in the CI. By any chance do you know how to fix it? https://github.com/python/cpython/actions/runs/13287244377/job/37098802007?pr=130040

I can try poking at this locally a bit later today, but my first guess is that it's because the equals sign is getting swallowed here:

/p:PlatformToolset clangcl

...so clangcl is just seen as another project name.

I don't really understand the quoting rules for PowerShell -- maybe "/p:PlatformToolset\=clangcl" is needed?

I think I ran into this same problem in bench-runner, and I ultimately gave up and used cmd rather than PowerShell, which you can do by putting shell: cmd above the run: ... in the yml file. See here for how I solved a similar problem in bench_runner.

Fidget-Spinner reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner
Update tail-call.yml
7f91920
@Fidget-Spinner

Fidget-Spinner commented Feb 12, 2025

Copy link
Copy Markdown
Member Author

That makes sense. Thanks. Applied the change to use cmd instead!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner

Fidget-Spinner commented Feb 12, 2025

Copy link
Copy Markdown
Member Author

@chris-eibl I guess we're blocked on getting patches to make clang-cl build CPython. Currently there's a few build errors which I assume you patched out on your branch? Do you mind upstreaming those patches? I can review them.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner
Update pycore_debug_offsets.h
c3d656b
@Fidget-Spinner

Fidget-Spinner commented Feb 12, 2025

Copy link
Copy Markdown
Member Author

Nevermind, I will try to patch them into this PR as well, so that we can do an integration test.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chris-eibl

chris-eibl commented Feb 12, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I don't really understand the quoting rules for PowerShell -- maybe "/p:PlatformToolset\=clangcl" is needed?

Yeah, see this part of build.bat -h:

If the argument contains an '=', the
entire argument must be quoted (e.g. `build.bat "/p:PlatformToolset=v141"`).

Had a quick look at the PR and everything looks fine to me.

The build log of your latest commit 7f91920 shows

  Performing Custom Build Tools
   Assembling: D:\a\cpython\cpython\externals\mpdecimal-4.0.0\libmpdec\vcdiv64.asm
  error: symbol 'AsyncioDebug' is already defined

I have never seen that error before.

For sure not during assembling, must come out of _asynciomodule.c:

GENERATE_DEBUG_SECTION(AsyncioDebug, Py_AsyncioModuleDebugOffsets AsyncioDebug)

That's the only occurence I've found.

Ah - you've found it yourself while I was typing :)

Interestingly: I cannot reproduce locally for the failing commit 7f91920 using:

build.bat --tail-call-interp -p x64 -c Release "/p:PlatformToolset=clangcl" "/p:PreferredToolArchitecture=x64"

with Visual Studio 2022 17.13.0 Preview 5.0, which ships with cl.exe 19.43.34808 and clang 19.1.1.

Let's see whether your latest commit fixes CI - looks promising :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mdboom

mdboom commented Feb 12, 2025

Copy link
Copy Markdown
Contributor

Yeah, see this part of build.bat -h:

If the argument contains an '=', the
entire argument must be quoted (e.g. `build.bat "/p:PlatformToolset=v141"`).

I'm pretty sure this advice assumes using cmd, not PowerShell (which is the default on Github Actions). Overriding the shell used on Github Actions seems to be the easy solution. The harder solution is figuring out PowerShell's escaping rules...

chris-eibl reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner

Fidget-Spinner commented Feb 12, 2025

Copy link
Copy Markdown
Member Author

with Visual Studio 2022 17.13.0 Preview 5.0, which ships with cl.exe 19.43.34808 and clang 19.1.1.

Let's see whether your latest commit fixes CI - looks promising :)

That didn't fix it :(.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chris-eibl

chris-eibl commented Feb 12, 2025

Copy link
Copy Markdown
Member

Ups - still the same error - very weird. No idea atm - sorry ...

Fidget-Spinner reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chris-eibl

chris-eibl commented Feb 12, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Unfortunately I cannot reproduce locally. Have a different clang version, though. Did also use clang 19.1.6 a lot.

Will fire up a build for this commit ...

Update:
Commit 7f91920 builds for me with clang 19.1.6, too:

build.bat --tail-call-interp -p x64 -c Release "/p:PlatformToolset=clangcl" "/p:LLVMToolsVersion=19.1.6" "/p:LLVMInstallDir=clang+llvm-19.1.6-x86_64-pc-windows-msvc"

Fidget-Spinner reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner

Fidget-Spinner commented Feb 12, 2025

Copy link
Copy Markdown
Member Author

Ah.. I think I forgot to add parentheses :) my bad

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner
Update pycore_debug_offsets.h
3638cda
@Fidget-Spinner

Fidget-Spinner commented Feb 12, 2025

Copy link
Copy Markdown
Member Author

Nevermind, that didn't fix it. Now that I look at the macros closer, it shouldn't fix it either.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner
Update pycore_debug_offsets.h
b8b79ed
@chris-eibl

chris-eibl commented Feb 12, 2025

Copy link
Copy Markdown
Member

Really strange why that happens on CI. Cannot reproduce with clang 19.1.1 and 19.1.6.
The CI seems to use 19.1.5 - but hard to believe this is the culprit.

Those macros have been touched recently #129223.
Yet, I never had an issue with clang-cl so far (and still have not).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner

Fidget-Spinner commented Feb 12, 2025

Copy link
Copy Markdown
Member Author

Fixed it on CI!

chris-eibl, colesbury, AlexWaygood, and Eclips4 reacted with hooray emoji
All reactions
  • 🎉 4 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chris-eibl chris-eibl mentioned this pull request Feb 13, 2025
gh-130090: Support PGO for clang-cl #129907
Merged
@Fidget-Spinner
Address review by using env vars
c811b8a
@Fidget-Spinner
Fidget-Spinner requested a review from zooba February 13, 2025 15:37
Fidget-Spinner added 3 commits February 13, 2025 23:39
@Fidget-Spinner
Merge remote-tracking branch 'upstream/main' into tailcall_for_windows
904b7ee
@Fidget-Spinner
Merge remote-tracking branch 'upstream/main' into tailcall_for_windows
991b50f
@Fidget-Spinner
Update pythoncore.vcxproj
166187c
@chris-eibl chris-eibl mentioned this pull request Feb 24, 2025
GH-130213: clang-cl: blake2module.c needs to "see" the AVX intrinsics during compiling #130447
Closed
@Fidget-Spinner

Fidget-Spinner commented Mar 5, 2025

Copy link
Copy Markdown
Member Author

@zooba gentle ping for a review please. Thanks again for reviewing that other PR on getting PGO working on clang-cl. This should be relatively tame in comparison :).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hugovk
hugovk reviewed Mar 5, 2025
View reviewed changes
Comment thread .github/workflows/tail-call.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Fidget-Spinner and others added 2 commits March 5, 2025 17:14
@Fidget-Spinner @hugovk
Update .github/workflows/tail-call.yml
5f7ad24
Co-authored-by: Hugo van Kemenade <[email protected]>
@Fidget-Spinner
Update tail-call.yml
6d7b689
zooba
zooba reviewed Mar 5, 2025
View reviewed changes
Comment thread .github/workflows/tail-call.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Include/internal/pycore_debug_offsets.h
_GENERATE_DEBUG_SECTION_LINUX(name)

#if defined(MS_WINDOWS)
#if defined(MS_WINDOWS) && !defined(__clang__)

@zooba zooba Mar 5, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need an alternate definition for Windows + clang?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Fidget-Spinner Fidget-Spinner Mar 5, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, below there's a default that it uses is we're not one of the supported platforms. And that default works for Clang Windows.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread PCbuild/build.bat Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .github/workflows/tail-call.yml Outdated
on:
pull_request:
paths:
- '.github/workflows/tail-call.yml'

@zooba zooba Mar 5, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels wrong to me, but if it's needed, then sure. Hopefully someone else can sign off on this part of the change.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@hugovk hugovk Mar 5, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine: when changing this file, it's good to run it as well to make sure we didn't break it -- which is rather too easy with YAML.


(And let's strip the trailing spaces.)

Suggested change
- '.github/workflows/tail-call.yml'
- '.github/workflows/tail-call.yml'

(We should add yaml to this list, feel free to include it in the PR if you like:)

cpython/.pre-commit-config.yaml

Line 49 in 2904ec2

types_or: [c, inc, python, rst]

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Fidget-Spinner added 2 commits March 6, 2025 01:21
@Fidget-Spinner
Address review
aadfec4
@Fidget-Spinner
Partially revert "Address review"
1d7c051
We can't specify the minor version as the apt script doesn't recognize it.
@Fidget-Spinner Fidget-Spinner mentioned this pull request Mar 5, 2025
Update Windows builds to use ClangCL astral-sh/python-build-standalone#549
Draft
@Fidget-Spinner
Fidget-Spinner requested a review from zooba March 7, 2025 17:00
chris-eibl added a commit to chris-eibl/cpython that referenced this pull request Mar 9, 2025
@chris-eibl
Interestingly, for debug builds I now need this, too.
0bd337d
python#130040 (comment)
@chris-eibl chris-eibl mentioned this pull request Mar 9, 2025
GH-130090: build time analysis #131005
Closed
@zooba

zooba commented Mar 10, 2025

Copy link
Copy Markdown
Member

Looks fine to me.

I hope we can justify (one day) taking options out of build.bat without deprecation periods and warnings. I think we probably can. In any case, this PR isn't the cause of sprawling options, so no harm in merging it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chris-eibl

chris-eibl commented Mar 10, 2025

Copy link
Copy Markdown
Member

@zooba: I understand. But doing that options in build.bat is the only way to get it configurable without modifying/hardcoding it in pythoncore.vcxproj. Which I manually had to do when trying computed gotos builds in #130090, and thus always had a "dirty repo".

Would it be okay for you if I create a similar PR for computed gotos?

Or is there a better way?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner
Fidget-Spinner merged commit a8ee1e1 into python:main Mar 11, 2025
@bedevere-app bedevere-app Bot removed the awaiting core review label Mar 11, 2025
@Fidget-Spinner
Fidget-Spinner deleted the tailcall_for_windows branch March 11, 2025 02:53
@zooba

zooba commented Mar 11, 2025

Copy link
Copy Markdown
Member

Environment variables pass through into the build just fine, and are exposed as MSBuild properties (provided we don't immediately overwrite them). I have no problem (well, fewer problems) with enabling a feature by environment variable, it's just the batch file option that worries me.

The main difference is that if we remove the setting and it was only used by environment variable, the build will still succeed. If we remove a build.bat option, builds will break. So arguably a good dividing line is whether builds ought to break if/when we remove the option - most optimisations and experimental features aren't in that category, IMHO.

Fidget-Spinner and chris-eibl reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chris-eibl

chris-eibl commented Mar 11, 2025

Copy link
Copy Markdown
Member

That would be fine with me, too. IIUC, e.g. just add

<PreprocessorDefinitions Condition="'$(HAVE_COMPUTED_GOTOS)' == 'true'">HAVE_COMPUTED_GOTOS;%(PreprocessorDefinitions)</PreprocessorDefinitions>

and leave it to the user to

  • either add "/p:HAVE_COMPUTED_GOTOS=true" when invoking build.bat
  • or just set the environment variable HAVE_COMPUTED_GOTOS=true before invoking build.bat

up to their liking.

Either way, build.bat does not have to "learn" all of that things. Might have been better for some of the existing switches, too - but it's too late for that. Maybe not for tailcall, since this is new?

And if it is really important to warn or fail if a variable does not make sense any longer, we could do something like

<Message Text="HAVE_COMPUTED_GOTOS are no longer supported" Condition="$(HAVE_COMPUTED_GOTOS) == "true" Importance="high" />

or

<Error Text="HAVE_COMPUTED_GOTOS are no longer supported" Condition="$(HAVE_COMPUTED_GOTOS) == "true" Code="1" />

Regarding documentation: shall this still be available via build.bat -h (still less clutter) or only via PCbuild/readme.txt?

PS: we even could do some meaningful defaults like enabling tail calling if not given and LLVMToolsVersion indicates clang-cl >= 19.x.x.

Likewise, we could enable cg if HAVE_COMPUTED_GOTOS is not given (or true) but disable it if HAVE_COMPUTED_GOTOS=false, etc ...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chris-eibl

chris-eibl commented Mar 11, 2025

Copy link
Copy Markdown
Member

Ah, and the "switch" shall maybe be named WITH_COMPUTED_GOTOS in analogy to --with-computed-gotos in the configure script and the other --with things, where build.bat tries to mimic configure.

Naming is always hard :(

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zooba

zooba commented Mar 11, 2025

Copy link
Copy Markdown
Member

IIUC, ...

Yeah, though I'd test for != '' rather than a specific value. And it only really needs mentioning in PCbuild\README.txt, probably with a note that they are subject to change at any time.

I'm okay with meaningful defaults, but do be very careful about the checks. It's very easy to break unrelated builds, because basically everything gets evaluated all the time and there's not much in the way of error handling.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Mar 15, 2025
Support building using "computed gotos" for clang-cl on Windows #131278
Closed
GH-131278: Support building using "computed gotos" for clang-cl on Windows #131279
Merged
@chris-eibl chris-eibl mentioned this pull request Apr 4, 2025
gh-132132: Upgrade LLVM on tail calling CI #132098
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hugovk hugovk hugovk left review comments
@ezio-melotti ezio-melotti Awaiting requested review from ezio-melotti ezio-melotti is a code owner
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
@mdboom mdboom Awaiting requested review from mdboom
@zooba zooba Awaiting requested review from zooba

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@Fidget-Spinner @mdboom @chris-eibl @zooba @hugovk
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.