Skip to content

Commit a8ee1e1

Browse files
gh-130039: Tailcall for windows builds (GH-130040)
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 4192ce1 commit a8ee1e1

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

.github/workflows/tail-call.yml

+20-10
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ name: Tail calling interpreter
22
on:
33
pull_request:
44
paths:
5+
- '.github/workflows/tail-call.yml'
56
- 'Python/bytecodes.c'
67
- 'Python/ceval.c'
78
- 'Python/ceval_macros.h'
89
- 'Python/generated_cases.c.h'
910
push:
1011
paths:
12+
- '.github/workflows/tail-call.yml'
1113
- 'Python/bytecodes.c'
1214
- 'Python/ceval.c'
1315
- 'Python/ceval_macros.h'
@@ -35,7 +37,7 @@ jobs:
3537
target:
3638
# Un-comment as we add support for more platforms for tail-calling interpreters.
3739
# - i686-pc-windows-msvc/msvc
38-
# - x86_64-pc-windows-msvc/msvc
40+
- x86_64-pc-windows-msvc/msvc
3941
# - aarch64-pc-windows-msvc/msvc
4042
- x86_64-apple-darwin/clang
4143
- aarch64-apple-darwin/clang
@@ -48,9 +50,9 @@ jobs:
4850
# - target: i686-pc-windows-msvc/msvc
4951
# architecture: Win32
5052
# runner: windows-latest
51-
# - target: x86_64-pc-windows-msvc/msvc
52-
# architecture: x64
53-
# runner: windows-latest
53+
- target: x86_64-pc-windows-msvc/msvc
54+
architecture: x64
55+
runner: windows-latest
5456
# - target: aarch64-pc-windows-msvc/msvc
5557
# architecture: ARM64
5658
# runner: windows-latest
@@ -79,23 +81,31 @@ jobs:
7981

8082
- name: Native Windows (debug)
8183
if: runner.os == 'Windows' && matrix.architecture != 'ARM64'
84+
shell: cmd
8285
run: |
83-
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0
86+
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.5
87+
set PlatformToolset=clangcl
88+
set LLVMToolsVersion=${{ matrix.llvm }}.1.5
89+
set LLVMInstallDir=C:\Program Files\LLVM
8490
./PCbuild/build.bat --tail-call-interp -d -p ${{ matrix.architecture }}
8591
./PCbuild/rt.bat -d -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
8692
8793
# No tests (yet):
8894
- name: Emulated Windows (release)
8995
if: runner.os == 'Windows' && matrix.architecture == 'ARM64'
96+
shell: cmd
9097
run: |
91-
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0
98+
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.5
99+
set PlatformToolset=clangcl
100+
set LLVMToolsVersion=${{ matrix.llvm }}.1.5
101+
set LLVMInstallDir=C:\Program Files\LLVM
92102
./PCbuild/build.bat --tail-call-interp -p ${{ matrix.architecture }}
93103
94104
# The `find` line is required as a result of https://github.com/actions/runner-images/issues/9966.
95105
# This is a bug in the macOS runner image where the pre-installed Python is installed in the same
96106
# directory as the Homebrew Python, which causes the build to fail for macos-13. This line removes
97107
# the symlink to the pre-installed Python so that the Homebrew Python is used instead.
98-
- name: Native macOS (debug)
108+
- name: Native macOS (release)
99109
if: runner.os == 'macOS'
100110
run: |
101111
brew update
@@ -104,16 +114,16 @@ jobs:
104114
export SDKROOT="$(xcrun --show-sdk-path)"
105115
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
106116
export PATH="/usr/local/opt/llvm/bin:$PATH"
107-
CC=clang-19 ./configure --with-tail-call-interp --with-pydebug
117+
CC=clang-19 ./configure --with-tail-call-interp
108118
make all --jobs 4
109119
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
110120
111-
- name: Native Linux (release)
121+
- name: Native Linux (debug)
112122
if: runner.os == 'Linux' && matrix.target != 'free-threading'
113123
run: |
114124
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
115125
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
116-
CC=clang-19 ./configure --with-tail-call-interp
126+
CC=clang-19 ./configure --with-tail-call-interp --with-pydebug
117127
make all --jobs 4
118128
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
119129

Include/internal/pycore_debug_offsets.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extern "C" {
2323
declaration \
2424
_GENERATE_DEBUG_SECTION_LINUX(name)
2525

26-
#if defined(MS_WINDOWS)
26+
#if defined(MS_WINDOWS) && !defined(__clang__)
2727
#define _GENERATE_DEBUG_SECTION_WINDOWS(name) \
2828
_Pragma(Py_STRINGIFY(section(Py_STRINGIFY(name), read, write))) \
2929
__declspec(allocate(Py_STRINGIFY(name)))

PCbuild/build.bat

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ echo. --experimental-jit Enable the experimental just-in-time compiler
4040
echo. --experimental-jit-off Ditto but off by default (PYTHON_JIT=1 enables).
4141
echo. --experimental-jit-interpreter Enable the experimental Tier 2 interpreter.
4242
echo. --pystats Enable PyStats collection.
43+
echo. --tail-call-interp Enable tail-calling interpreter (requires LLVM 19 or higher).
4344
echo.
4445
echo.Available flags to avoid building certain modules.
4546
echo.These flags have no effect if '-e' is not given:
@@ -95,6 +96,7 @@ if "%~1"=="--experimental-jit-off" (set UseJIT=true) & (set UseTIER2=3) & shift
9596
if "%~1"=="--experimental-jit-interpreter" (set UseTIER2=4) & shift & goto CheckOpts
9697
if "%~1"=="--experimental-jit-interpreter-off" (set UseTIER2=6) & shift & goto CheckOpts
9798
if "%~1"=="--pystats" (set PyStats=1) & shift & goto CheckOpts
99+
if "%~1"=="--tail-call-interp" (set UseTailCallInterp=true) & shift & goto CheckOpts
98100
rem These use the actual property names used by MSBuild. We could just let
99101
rem them in through the environment, but we specify them on the command line
100102
rem anyway for visibility so set defaults after this
@@ -189,6 +191,7 @@ echo on
189191
/p:UseJIT=%UseJIT%^
190192
/p:UseTIER2=%UseTIER2%^
191193
/p:PyStats=%PyStats%^
194+
/p:UseTailCallInterp=%UseTailCallInterp%^
192195
%1 %2 %3 %4 %5 %6 %7 %8 %9
193196

194197
@echo off

PCbuild/pythoncore.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
<PreprocessorDefinitions Condition="$(IncludeExternals)">_Py_HAVE_ZLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
107107
<PreprocessorDefinitions Condition="'$(UseJIT)' == 'true'">_Py_JIT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
108108
<PreprocessorDefinitions Condition="'$(UseTIER2)' != '' and '$(UseTIER2)' != '0'">_Py_TIER2=$(UseTIER2);%(PreprocessorDefinitions)</PreprocessorDefinitions>
109+
<PreprocessorDefinitions Condition="'$(UseTailCallInterp)' == 'true'">Py_TAIL_CALL_INTERP=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
109110
</ClCompile>
110111
<Link>
111112
<AdditionalDependencies>version.lib;ws2_32.lib;pathcch.lib;bcrypt.lib;%(AdditionalDependencies)</AdditionalDependencies>

0 commit comments

Comments
 (0)