diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 27e07a5f91bf37..3a32b1fe4e39e0 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -95,11 +95,11 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build CPython
- run: .\PCbuild\build.bat -e -p Win32
+ run: .\PCbuild\build.bat -e -p Win32 -d
- name: Display build info
run: .\python.bat -m test.pythoninfo
- name: Tests
- run: .\PCbuild\rt.bat -p Win32 -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
+ run: .\PCbuild\rt.bat -p Win32 -d -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
build_win_amd64:
name: 'Windows (x64)'
@@ -111,11 +111,11 @@ jobs:
- name: Register MSVC problem matcher
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
- name: Build CPython
- run: .\PCbuild\build.bat -e -p x64
+ run: .\PCbuild\build.bat -e -p x64 -d
- name: Display build info
run: .\python.bat -m test.pythoninfo
- name: Tests
- run: .\PCbuild\rt.bat -p x64 -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
+ run: .\PCbuild\rt.bat -p x64 -d -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
build_macos:
name: 'macOS'
diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index 896a292c3356e8..c861324e909127 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -284,6 +284,11 @@ CPython bytecode changes
Build Changes
=============
+* On Windows, enable compiler optimizations on the debug build to make tests
+ run faster and to reduce the stack memory usage, especially with static
+ inline functions used in Python public header files.
+ (Contributed by Victor Stinner in :issue:`45115`.)
+
Deprecated
==========
diff --git a/Misc/NEWS.d/next/Build/2021-09-06-17-22-14.bpo-45115.4n0_eo.rst b/Misc/NEWS.d/next/Build/2021-09-06-17-22-14.bpo-45115.4n0_eo.rst
new file mode 100644
index 00000000000000..01dc50ca0aca78
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2021-09-06-17-22-14.bpo-45115.4n0_eo.rst
@@ -0,0 +1,3 @@
+On Windows, enable compiler optimizations on the debug build to make tests
+run faster and to reduce the stack memory usage, especially with static
+inline functions used in Python public header files.
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index b8cadf469355f4..a2881fa302a6e2 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -104,6 +104,8 @@
$(zlibDir);%(AdditionalIncludeDirectories)
_USRDLL;Py_BUILD_CORE;Py_BUILD_CORE_BUILTIN;Py_ENABLE_SHARED;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions)
_Py_HAVE_ZLIB;%(PreprocessorDefinitions)
+ MaxSpeed
+ Default
version.lib;shlwapi.lib;ws2_32.lib;pathcch.lib;bcrypt.lib;%(AdditionalDependencies)