From 98de4c1d08af0212d5e19415f76b8b60d84d8178 Mon Sep 17 00:00:00 2001
From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
Date: Sat, 15 Mar 2025 12:33:32 +0100
Subject: [PATCH 1/9] Add optimizing flag `WITH_COMPUTED_GOTOS` to support such
builds using
clang-cl on Windows. Patch by Chris Eibl.
---
.../2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst | 2 ++
PCbuild/pythoncore.vcxproj | 1 +
PCbuild/readme.txt | 14 ++++++++++++++
3 files changed, 17 insertions(+)
create mode 100644 Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
diff --git a/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst b/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
new file mode 100644
index 00000000000000..9f744540c0b7e5
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
@@ -0,0 +1,2 @@
+Add optimizing flag `WITH_COMPUTED_GOTOS` to support such builds using
+clang-cl on Windows. Patch by Chris Eibl.
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index cef0e81e11972c..045d109d2820a1 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -107,6 +107,7 @@
_Py_JIT;%(PreprocessorDefinitions)_Py_TIER2=$(UseTIER2);%(PreprocessorDefinitions)Py_TAIL_CALL_INTERP=1;%(PreprocessorDefinitions)
+ HAVE_COMPUTED_GOTOS;%(PreprocessorDefinitions)version.lib;ws2_32.lib;pathcch.lib;bcrypt.lib;%(AdditionalDependencies)
diff --git a/PCbuild/readme.txt b/PCbuild/readme.txt
index 33952d31681cbc..f878b4aaa035ac 100644
--- a/PCbuild/readme.txt
+++ b/PCbuild/readme.txt
@@ -310,6 +310,20 @@ See
for more on this topic.
+Optimization flags
+------------------
+You can set optimization flags either via
+ * environment variables, e.g.
+ set WITH_COMPUTED_GOTOS=true
+ * or pass them as parameters to `build.bat`, e.g.
+ 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
--------------
From 86cb64e408b6143ab04685bcca58af54a5707598 Mon Sep 17 00:00:00 2001
From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
Date: Sat, 15 Mar 2025 12:40:29 +0100
Subject: [PATCH 2/9] ups - double backticks needed
---
.../next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst b/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
index 9f744540c0b7e5..c68a362451c518 100644
--- a/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
+++ b/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
@@ -1,2 +1,2 @@
-Add optimizing flag `WITH_COMPUTED_GOTOS` to support such builds using
+Add optimizing flag ``WITH_COMPUTED_GOTOS`` to support such builds using
clang-cl on Windows. Patch by Chris Eibl.
From 3aabeeac836912820f241bdee40ad8c878413396 Mon Sep 17 00:00:00 2001
From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
Date: Sat, 15 Mar 2025 13:00:22 +0100
Subject: [PATCH 3/9] Apply suggestions from code review
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
---
...25-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst | 2 +-
PCbuild/readme.txt | 17 ++++++++++++-----
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst b/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
index c68a362451c518..e88abf48204f45 100644
--- a/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
+++ b/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
@@ -1,2 +1,2 @@
Add optimizing flag ``WITH_COMPUTED_GOTOS`` to support such builds using
-clang-cl on Windows. Patch by Chris Eibl.
+:prog:`clang-cl` on Windows. Patch by Chris Eibl.
diff --git a/PCbuild/readme.txt b/PCbuild/readme.txt
index f878b4aaa035ac..9f8c92bb253415 100644
--- a/PCbuild/readme.txt
+++ b/PCbuild/readme.txt
@@ -312,14 +312,21 @@ for more on this topic.
Optimization flags
------------------
+
You can set optimization flags either via
- * environment variables, e.g.
- set WITH_COMPUTED_GOTOS=true
- * or pass them as parameters to `build.bat`, e.g.
- build.bat "/p:WITH_COMPUTED_GOTOS=true"
- * or put them in `msbuild.rsp` in the `PCbuild` directory, one flag per line
+
+ * 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.
From ca22c81fe9c1697dc4c592ecb8fcb3006be4bb46 Mon Sep 17 00:00:00 2001
From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
Date: Sat, 15 Mar 2025 13:36:27 +0100
Subject: [PATCH 4/9] remove space before *
---
PCbuild/readme.txt | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/PCbuild/readme.txt b/PCbuild/readme.txt
index 9f8c92bb253415..8e82d4ea840fe1 100644
--- a/PCbuild/readme.txt
+++ b/PCbuild/readme.txt
@@ -315,20 +315,20 @@ Optimization flags
You can set optimization flags either via
- * environment variables, for example:
+* environment variables, for example:
- set WITH_COMPUTED_GOTOS=true
+ set WITH_COMPUTED_GOTOS=true
- * or pass them as parameters to `build.bat`, for example:
+* 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.
+ 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.
+* WITH_COMPUTED_GOTOS: build the interpreter using "computed gotos".
+ Currently only supported by clang-cl.
Static library
From 897c527aa91bb4e65238752dec1040c1ab41edf2 Mon Sep 17 00:00:00 2001
From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
Date: Sat, 15 Mar 2025 13:37:49 +0100
Subject: [PATCH 5/9] revert :prog:
---
.../next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst b/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
index e88abf48204f45..c68a362451c518 100644
--- a/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
+++ b/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
@@ -1,2 +1,2 @@
Add optimizing flag ``WITH_COMPUTED_GOTOS`` to support such builds using
-:prog:`clang-cl` on Windows. Patch by Chris Eibl.
+clang-cl on Windows. Patch by Chris Eibl.
From 1f5b55f7d5a23a748959cd1ec0ba92fec99a0d53 Mon Sep 17 00:00:00 2001
From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
Date: Sat, 15 Mar 2025 14:09:07 +0100
Subject: [PATCH 6/9] add whats new
---
Doc/whatsnew/3.14.rst | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst
index 8f58901b28e1b0..bf9853778db948 100644
--- a/Doc/whatsnew/3.14.rst
+++ b/Doc/whatsnew/3.14.rst
@@ -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
+ :gh:`130090`, :gh:`131035` and :gh:`131278`).
+
.. _whatsnew314-pep761:
PEP 761: Discontinuation of PGP signatures
From 905d2e4ce239c49ea5b4ff94ae55ab093f856888 Mon Sep 17 00:00:00 2001
From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
Date: Mon, 17 Mar 2025 18:52:47 +0100
Subject: [PATCH 7/9] Revert "add whats new"
This reverts commit 1f5b55f7d5a23a748959cd1ec0ba92fec99a0d53.
---
Doc/whatsnew/3.14.rst | 5 -----
1 file changed, 5 deletions(-)
diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst
index bf9853778db948..8f58901b28e1b0 100644
--- a/Doc/whatsnew/3.14.rst
+++ b/Doc/whatsnew/3.14.rst
@@ -1437,11 +1437,6 @@ 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
- :gh:`130090`, :gh:`131035` and :gh:`131278`).
-
.. _whatsnew314-pep761:
PEP 761: Discontinuation of PGP signatures
From fd3cb867138f39f9b48eae20cad0f324c9ed4783 Mon Sep 17 00:00:00 2001
From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
Date: Mon, 17 Mar 2025 18:55:56 +0100
Subject: [PATCH 8/9] apply Steve's suggestion to blurb
---
.../next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst b/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
index c68a362451c518..cb7120c4e702ef 100644
--- a/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
+++ b/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
@@ -1,2 +1,2 @@
-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.
\ No newline at end of file
From 59dac200b83281cc526b8e239a33506ce0c7d78b Mon Sep 17 00:00:00 2001
From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
Date: Mon, 17 Mar 2025 18:59:21 +0100
Subject: [PATCH 9/9] fix missing newline in blurb
---
.../next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst b/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
index cb7120c4e702ef..56e698383aa1ef 100644
--- a/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
+++ b/Misc/NEWS.d/next/Build/2025-03-15-12-32-56.gh-issue-131278.1nd0mJ.rst
@@ -1,2 +1,2 @@
Add optimizing flag ``WITH_COMPUTED_GOTOS`` to Windows builds for when
-using a compiler that supports it (currently clang-cl). Patch by Chris Eibl.
\ No newline at end of file
+using a compiler that supports it (currently clang-cl). Patch by Chris Eibl.