Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-131278: Support building using "computed gotos" for clang-cl on Windows #131279

Merged
merged 9 commits into from
Mar 17, 2025

Conversation

chris-eibl
Copy link
Contributor

@chris-eibl chris-eibl commented Mar 15, 2025

clang-cl on Windows. Patch by Chris Eibl.
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

Some readability comments. Do you want to actually add a What's New as well? (I don't know how wide is the audience)

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@Fidget-Spinner
Copy link
Member

I don't remember if we had a Whats New for the original clang-cl issue. We should definitely mention in the whats new that clang cl building on Windows is now possible, and say PGO too.

@Fidget-Spinner
Copy link
Member

Woops sorry pressed the wrong button!

@picnixz
Copy link
Member

picnixz commented Mar 15, 2025

@chris-eibl How do you plan to address:

We should definitely mention in the whats new that clang cl building on Windows is now possible, and say PGO too.

Are there more PRs for those kind of optimizations on Windows? if so, we can delay everything until they are done. Otherwise, let's mention that in the What's New entry

@chris-eibl
Copy link
Contributor Author

I don't remember if we had a Whats New for the original clang-cl issue. We should definitely mention in the whats new that clang cl building on Windows is now possible, and say PGO too.

Building with clang-cl has been possible for a very long time: #101352.

The only fixes I am aware of are just these two (and just main and current 3.14 alphas are/have been affected):

So maybe just mention PGO in the Whats New?
Maybe this here and -flto=thin, too?

@zooba treats clang-cl as quite optional in #129907 (comment)
but I think a Whats New entry would not hurt.

Shall I give it a go here and mention those three things?

@chris-eibl
Copy link
Contributor Author

@Fidget-Spinner : your tail call for Windows #130040 (comment) came without What's new, too. Shall I add an entry, too?

Are there more PRs for those kind of optimizations on Windows?

I'd like to work on the many warnings clang-cl emits, but IMHO that won't go into What's new. Regarding optimizations, I think that's it atm, we can amend later, anyway.

@Fidget-Spinner
Copy link
Member

@Fidget-Spinner : your tail call for Windows #130040 (comment) came without What's new, too. Shall I add an entry, too?

We don't need it, as there's already a whats new for tail call in general.

@@ -1437,6 +1437,11 @@ Build changes
with :c:expr:`Py_NO_LINK_LIB`. (Contributed by Jean-Christophe
Fillion-Robin in :gh:`82909`.)

* building with clang-cl on Windows now supports PGO (profile guided
optimization), uses ``-flto=thin`` and can be configured to use
computed gotos. (Contributed by Chris Eibl in
Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMHO "computed gotos and/or tail calls" would be better here, but up to @Fidget-Spinner 's liking :)

@zooba
Copy link
Member

zooba commented Mar 17, 2025

I think we want to be careful putting too much into What's New, since we still aren't technically supporting clang-cl on Windows yet, we're really just unblocking it. No doubt if @chris-eibl sticks around it'll remain unblocked, but also, if Clang one day breaks down and MSVC is fine then we're still going to release.

A simple entry (which should already be there?) stating that build.bat now has a clang-cl specific option (previously you needed to set PlatformToolset but that was the only difference) and perhaps calling out that this enables some clang-specific optimisations, referencing PCbuild\readme.txt for more info seems to hit the balance. Let's avoid using the word "support" in regards to our source code.

@chris-eibl
Copy link
Contributor Author

previously you needed to set PlatformToolset but that was the only difference

This is still true, we do not have a "clang" switch for build.bat, yet.

I am fine with entirely removing the whatsnew if that makes it easier :)

Copy link
Member

@zooba zooba left a comment

Choose a reason for hiding this comment

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

PCbuild changes look good, just suggesting some clarifications to the docs.

Comment on lines 1 to 2
Add optimizing flag ``WITH_COMPUTED_GOTOS`` to support such builds using
clang-cl on Windows. Patch by Chris Eibl.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Add optimizing flag ``WITH_COMPUTED_GOTOS`` to support such builds using
clang-cl on Windows. Patch by Chris Eibl.
Add optimizing flag ``WITH_COMPUTED_GOTOS`` to Windows builds for when
using a compiler that supports it (currently clang-cl). Patch by Chris Eibl.

@@ -1437,6 +1437,11 @@ Build changes
with :c:expr:`Py_NO_LINK_LIB`. (Contributed by Jean-Christophe
Fillion-Robin in :gh:`82909`.)

* building with clang-cl on Windows now supports PGO (profile guided
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* building with clang-cl on Windows now supports PGO (profile guided
* clang-cl builds on Windows now work with ``--pgo`` (profile guided

@@ -1437,6 +1437,11 @@ Build changes
with :c:expr:`Py_NO_LINK_LIB`. (Contributed by Jean-Christophe
Fillion-Robin in :gh:`82909`.)

* building with clang-cl on Windows now supports PGO (profile guided
optimization), uses ``-flto=thin`` and can be configured to use
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
optimization), uses ``-flto=thin`` and can be configured to use
optimization), and can be configured to use

Is using -flto=thin important to call out? It shouldn't change the ABI of the build output at all, and it's not configurable.

@zooba
Copy link
Member

zooba commented Mar 17, 2025

This is still true, we do not have a "clang" switch for build.bat, yet.

(Seen after submitting my review.) Oh don't we? Okay, yeah, let's treat all clang-cl specific changes as undocumented then. The day it gets an option is when we'd start putting notes in the Build section of NEWS, and give the option a brief mention in What's New.

This reverts commit 1f5b55f.
@zooba zooba merged commit 468a7aa into python:main Mar 17, 2025
39 checks passed
@chris-eibl chris-eibl deleted the param_cg branch March 18, 2025 05:25
colesbury pushed a commit to colesbury/cpython that referenced this pull request Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants