deps: compile unicodectype.c unoptimised in the Windows arm64 Python (#15719)

VS 2026's ARM64 code generator needs about 27 GB for
_PyUnicode_ToNumeric, a switch with 1951 cases in
Objects/unicodetype_db.h; the same file takes under 1 GB on x64. The
16 GB CI runner has an 18.9 GB commit limit and only gets through when
Windows grows the pagefile on the temp disk in time, so cold arm64
dependency builds fail at random with C1002 "compiler is out of heap
space". build_release_vs.bat returns 0 on failure, so the job still
reports success and the incomplete dependencies are cached.

A property sheet compiles that one file with optimisation off on arm64;
the rest stays whole-program optimised and x64 is unchanged.
MSBuild reads it from PCbuild/msbuild.rsp, which is now written at
configure time and copied in, so a checkout path with spaces works too.
This commit is contained in:
Kris Austin
2026-09-15 11:55:11 -03:00
committed by GitHub
parent ac3997c0d1
commit 7e545651bb
2 changed files with 23 additions and 1 deletions
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Compiles Objects/unicodectype.c without optimisation. VS 2026's ARM64 code
generator needs about 27 GB for _PyUnicode_ToNumeric, a switch with 1951
cases. CPython has the same workaround (python/cpython#153668). -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Update="..\Objects\unicodectype.c">
<Optimization>Disabled</Optimization>
<WholeProgramOptimization>false</WholeProgramOptimization>
</ClCompile>
</ItemGroup>
</Project>
+11 -1
View File
@@ -88,8 +88,18 @@ if(WIN32)
list(APPEND _python_env_args "PreferredToolArchitecture=${_python_tool_arch}")
endif()
# MSBuild reads extra switches from PCbuild/msbuild.rsp.
set(_python_rsp "/p:PlatformToolset=${_python_platform_toolset}\n")
# VS 2026's ARM64 code generator needs about 27 GB for one function in
# Objects/unicodectype.c (python/cpython#153668); the property sheet compiles
# that file without optimisation.
if(_python_pcbuild_platform STREQUAL "ARM64")
file(TO_NATIVE_PATH "${CMAKE_CURRENT_LIST_DIR}/arm64-unicodectype.props" _python_arm64_props)
string(APPEND _python_rsp "/p:ForceImportAfterCppTargets=\"${_python_arm64_props}\"\n")
endif()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/python3-msbuild.rsp" "${_python_rsp}")
set(_conf_cmd
cmd /c "echo /p:PlatformToolset=${_python_platform_toolset}>PCbuild\\msbuild.rsp"
${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/python3-msbuild.rsp" <SOURCE_DIR>/PCbuild/msbuild.rsp
)
set(_build_cmd
${CMAKE_COMMAND} -E env ${_python_env_args}