Skip to content

GH-148047: Check early whether tail-calling is possible for MSVC builds on Windows#148036

Open
chris-eibl wants to merge 4 commits intopython:mainfrom
chris-eibl:CheckTailCalling
Open

GH-148047: Check early whether tail-calling is possible for MSVC builds on Windows#148036
chris-eibl wants to merge 4 commits intopython:mainfrom
chris-eibl:CheckTailCalling

Conversation

@chris-eibl
Copy link
Copy Markdown
Member

@chris-eibl chris-eibl commented Apr 3, 2026

Rather than failing late when compiling e.g. a debug configuration

build.bat -c debug --tail-call-interp

with hundreds of

error C4737: Unable to perform required tail call. Performance may be degraded.

lets fail early with an explicit error message for configurations that are not supported by MSVC.

This is a follow-up on #140513 / #140548.

@chris-eibl
Copy link
Copy Markdown
Member Author

chris-eibl commented Apr 3, 2026

TSan https://github.com/python/cpython/actions/runs/23948631142/job/69850491565?pr=148036 failure for sure unreleated: this is a pure Windows change and would result in a build error on onsupported (Windows) hosts when using --tail-call-interp. Note that there are no such hosts in CI nor in buildbots, and if there were, they would have already failed (but with tons of Unable to perform required tail call messages).

I've checked manually that I get all the expected errors for unsupported configurations.

@Fidget-Spinner
Copy link
Copy Markdown
Member

Please open a separate issue for this, rather than reusing the same closed issue. Thanks!

@chris-eibl chris-eibl changed the title GH-139922: Check early whether tail calling is possible GH-148047: Check early whether tail calling is possible Apr 3, 2026
@chris-eibl chris-eibl added OS-windows build The build process and cross-build and removed skip news labels Apr 3, 2026
@chris-eibl chris-eibl changed the title GH-148047: Check early whether tail calling is possible GH-148047: Check early whether tail-calling is possible for MSVC builds on Windows Apr 3, 2026
Copy link
Copy Markdown
Contributor

@itamaro itamaro left a comment

Choose a reason for hiding this comment

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

Overall looks good, thank you for this!

<Delete Files="$(OutDir)pybuilddir.txt" />
</Target>

<Target Name="_CheckTailCalling" BeforeTargets="PrepareForBuild" Condition="'$(UseTailCallInterp)' == 'true' and $(PlatformToolset) != 'ClangCL'">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should the condition match on "is msvc" instead of "not clangcl"?

<Error Text="Platform toolset >= v145 is required for tail-calling."
Condition="$(PlatformToolset.Replace('v', '0')) &lt; '145'" />
<Error Text="MSVC requires optimization to be enabled for tail-calling."
Condition="$(Configuration) == 'Debug'" />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't remember all the possible knobs and switches to configure the Windows build -- is 'config is Debug' the canonical and reliable way to determine "optimizations not enabled"?
Is it possible, using the correct incantation, to enable optimizations while keeping the config as "Debug"? or have non-Debug config while disabling optimizations?

@@ -0,0 +1,2 @@
Check early whether tail-calling is possible for MSVC builds on Windows.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe make this more about "fail fast with an explicit and clear error message" (which is the primary user-facing benefit here)

@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Apr 4, 2026

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

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

Labels

awaiting changes build The build process and cross-build OS-windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants