Skip to content

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

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

Merged
merged 9 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

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.

computed gotos. (Contributed by Chris Eibl in
Copy link
Member 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 :)

:gh:`130090`, :gh:`131035` and :gh:`131278`).

.. _whatsnew314-pep761:

PEP 761: Discontinuation of PGP signatures
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,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.

1 change: 1 addition & 0 deletions PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<PreprocessorDefinitions Condition="'$(UseJIT)' == 'true'">_Py_JIT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(UseTIER2)' != '' and '$(UseTIER2)' != '0'">_Py_TIER2=$(UseTIER2);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(UseTailCallInterp)' == 'true'">Py_TAIL_CALL_INTERP=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(WITH_COMPUTED_GOTOS)' != ''">HAVE_COMPUTED_GOTOS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>version.lib;ws2_32.lib;pathcch.lib;bcrypt.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand Down
21 changes: 21 additions & 0 deletions PCbuild/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,27 @@ See
for more on this topic.


Optimization flags
------------------

You can set optimization flags either via

* environment variables, for example:

set WITH_COMPUTED_GOTOS=true

* or pass them as parameters to `build.bat`, for example:

build.bat "/p:WITH_COMPUTED_GOTOS=true"

* or put them in `msbuild.rsp` in the `PCbuild` directory, one flag per line.

Supported flags are:

* WITH_COMPUTED_GOTOS: build the interpreter using "computed gotos".
Currently only supported by clang-cl.


Static library
--------------

Expand Down
Loading