Building Python 3.14 with tail-call interpreter

Please help me improve how I build Python 3.14 with tail-call interpreter on Windows 11.

py314_variables.cmd
SET pathCLang=C:\clones\clang_msvc
SET LLVMToolsVersion=22

SET tag=3.14
SET version=%tag%.3
SET z=z
SET tag_z=%tag%%z%

SET pathRootPython=%LOCALAPPDATA%\Python
SET pathRelative314=Python-%version%
SET path314raw=%pathRootPython%\%pathRelative314%

SET path314zCompiled=%path314raw%\PCbuild\amd64
SET path314zInstalled=%LOCALAPPDATA%\Programs\Python\Python314

LLVMupdate.cmd
@ECHO OFF

:: Check installed version
SET "versionLLVM=none"
FOR /F "tokens=3" %%G IN ('"%pathCLang%\bin\clang.exe" --version ^| findstr clang') DO SET versionLLVM=%%G
SET versionLLVM

FOR /F "delims=" %%G IN ('curl -L -s -o NUL -w "%%{url_effective}" "https://github.com/llvm/llvm-project/releases/latest"') DO SET "URL=%%G"
FOR /F "tokens=7 delims=/" %%G IN ("%URL%") DO SET "LLVMtag=%%G"

SET "versionLLVMlatest=%LLVMtag:llvmorg-=%"
SET "pathRelativeLLVM=clang+llvm-%versionLLVMlatest%-x86_64-pc-windows-msvc"
SET "filename_tar=%pathRelativeLLVM%.tar"
SET "filename_xz=%filename_tar%.xz"
SET "URL=https://github.com/llvm/llvm-project/releases/download/%LLVMtag%/%filename_xz%"

SET versionLLVMlatest

IF "%versionLLVM%"=="%versionLLVMlatest%" exit /b 0

:: Download
IF NOT EXIST "%pathCLang%" MKDIR "%pathCLang%"

curl -L "%URL%" -o "%pathCLang%\%filename_xz%"

CALL 7z x -aoa "-o%pathCLang%" "%pathCLang%\%filename_xz%"
CALL 7z x -aoa "-o%pathCLang%" "%pathCLang%\%filename_tar%" "%pathRelativeLLVM%\*"

ROBOCOPY "%pathCLang%\%pathRelativeLLVM%" "%pathCLang%" /MOVE /E /NJH /NDL /NFL

DEL "%pathCLang%\%filename_tar%"
DEL "%pathCLang%\%filename_xz%"

ECHO Verifying installation...
"%pathCLang%\bin\clang.exe" --version

py314_downloadRaw.cmd
@ECHO OFF

IF NOT EXIST "%pathRootPython%" MKDIR "%pathRootPython%"

SET "filename_tar=%pathRelative314%.tar"
SET "filename_xz=%filename_tar%.xz"
SET "URL=https://www.python.org/ftp/python/%version%/%filename_xz%"

curl -L "%URL%" -o "%pathRootPython%\%filename_xz%"

CALL 7z x -aoa "-o%pathRootPython%" "%pathRootPython%\%filename_xz%"
CALL 7z x -aoa "-o%pathRootPython%" "%pathRootPython%\%filename_tar%" "%pathRelative314%\*"

DEL "%pathRootPython%\%filename_xz%"
DEL "%pathRootPython%\%filename_tar%"

I use these switches because other switches cause build errors. I don’t actually know that these are the correct options. Furthermore, the 500-750 warnings during the build process are a little unnerving.

py314_buildTailcall.cmd

@ECHO OFF

PUSHd "%path314raw%\PCbuild"

CALL build.bat --pgo --tail-call-interp "/p:PlatformToolset=ClangCL" "/p:LLVMInstallDir=%pathCLang%" "/p:LLVMToolsVersion=%LLVMToolsVersion%" "/p:WholeProgramOptimization=true"

POPd

I noticed that 3.13 and 3.13t (free-threaded) share a directory and seem to share some files; 3.14 and 3.14t do the same thing. I created this script so that 3.14z (tail-call interpreter) would mimic 3.14t. But I have not created a 1-to-1 correlation between 3.14t and 3.14z files, and I don’t really know whether or not this is wise.

py314_copyFiles314z.cmd

@ECHO OFF

COPY /Y "%path314zCompiled%\python.exe" "%path314zInstalled%\python%tag_z%.exe"
COPY /Y "%path314zCompiled%\pythonw.exe" "%path314zInstalled%\pythonw%tag_z%.exe"

COPY /Y "%path314zCompiled%\python314.dll" "%path314zInstalled%\python314%z%.dll"
COPY /Y "%path314zCompiled%\python3.dll" "%path314zInstalled%\python3%z%.dll"

IF EXIST "%path314zCompiled%\python.pdb" COPY /Y "%path314zCompiled%\python.pdb" "%path314zInstalled%\python%tag_z%.pdb"
IF EXIST "%path314zCompiled%\pythonw.pdb" COPY /Y "%path314zCompiled%\pythonw.pdb" "%path314zInstalled%\pythonw%tag_z%.pdb"
IF EXIST "%path314zCompiled%\python314.pdb" COPY /Y "%path314zCompiled%\python314.pdb" "%path314zInstalled%\python314%z%.pdb"
IF EXIST "%path314zCompiled%\python3.pdb" COPY /Y "%path314zCompiled%\python3.pdb" "%path314zInstalled%\python3%z%.pdb"

IF NOT EXIST "%path314zInstalled%\libs" MKDIR "%path314zInstalled%\libs"
IF EXIST "%path314zCompiled%\python314.lib" COPY /Y "%path314zCompiled%\python314.lib" "%path314zInstalled%\libs\python314%z%.lib"
IF EXIST "%path314zCompiled%\python3.lib" COPY /Y "%path314zCompiled%\python3.lib" "%path314zInstalled%\libs\python3%z%.lib"

"%path314zInstalled%\python%tag_z%.exe" -VV

Again, I mimicked 3.13t and 3.14t when creating the registry entries for 3.14z. This seems to be working well now.

py314_register314z.cmd

@ECHO OFF

SET "ROOT=HKCU\Software\Python\PythonCore\%tag_z%"

REG ADD "%ROOT%" /F /V DisplayName /T REG_SZ /D "Python %tag% (64-bit, tail-call interpreter)"
REG ADD "%ROOT%" /F /V SupportUrl /T REG_SZ /D "https://www.python.org/"
REG ADD "%ROOT%" /F /V Version /T REG_SZ /D "%tag%"
REG ADD "%ROOT%" /F /V SysVersion /T REG_SZ /D "%tag%"
REG ADD "%ROOT%" /F /V SysArchitecture /T REG_SZ /D "64bit"

REG ADD "%ROOT%\InstallPath" /F /VE /T REG_SZ /D %path314zInstalled%\
REG ADD "%ROOT%\InstallPath" /F /V ExecutablePath /T REG_SZ /D "%path314zInstalled%\python%tag_z%.exe"
REG ADD "%ROOT%\InstallPath" /F /V WindowedExecutablePath /T REG_SZ /D "%path314zInstalled%\pythonw%tag_z%.exe"

REG ADD "%ROOT%\PythonPath" /F /VE /T REG_SZ /D "%path314zInstalled%\Lib\;%path314zInstalled%\DLLs\"

@ECHO Registered %tag_z% at %path314zInstalled%