Skip to content

Commit 9d27b60

Browse files
ondrejmirtesclaude
andcommitted
Windows build spike for the turbo extension
config.w32 for the phpize/configure/nmake flow — the extension version is passed as a bare preprocessor token and stringized in main.cpp, since quote characters do not survive the configure-to-nmake pipeline — plus a temporary branch-only workflow building on windows-latest with the php-sdk-binary-tools toolchain (bison and friends) and running the differential battery against the built DLL. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013j6ePxd1BobZkr8YVLnNet
1 parent 94e684c commit 9d27b60

3 files changed

Lines changed: 144 additions & 2 deletions

File tree

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Temporary iteration workflow for the Windows turbo extension build.
2+
# Runs alone on pushes to the turbo-windows branch; folded into phar.yml
3+
# (and this file deleted) once the build and the differential tests are
4+
# green on windows-latest.
5+
6+
name: "Turbo Windows Spike"
7+
8+
permissions:
9+
contents: read
10+
11+
on:
12+
push:
13+
branches:
14+
- "turbo-windows"
15+
16+
env:
17+
# php/php-sdk-binary-tools — the toolchain every PHP Windows build uses
18+
# (ships bison and the unix tools the phpize/configure scripts expect).
19+
PHP_SDK_COMMIT: "c73faaf1cce914e2fc04da5587132f8f425996af" # php-sdk-2.7.1
20+
21+
jobs:
22+
windows:
23+
name: "Windows PHP ${{ matrix.php-version }}"
24+
runs-on: "windows-latest"
25+
timeout-minutes: 40
26+
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
php-version: ["8.4", "8.5"]
31+
32+
steps:
33+
- name: "Checkout"
34+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
35+
with:
36+
persist-credentials: false
37+
# full history: the extension version is baked from git log over
38+
# the watched paths
39+
fetch-depth: 0
40+
41+
- name: "Install PHP"
42+
uses: "shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240" # v2.37.2
43+
with:
44+
coverage: "none"
45+
php-version: "${{ matrix.php-version }}"
46+
47+
- name: "Compute the extension version and download the build tools"
48+
shell: bash
49+
run: |
50+
MAPPED_PHP=$(jq -r '[.[] | select(.vendored != true) | .php] | join(" ")' turbo-ext/shadowed-classes.json)
51+
SHA=$(git log -1 --format=%H -- turbo-ext/src $MAPPED_PHP | cut -c1-7)
52+
echo "extension version: $SHA"
53+
echo "PHPSTANTURBO_VERSION=$SHA" >> "$GITHUB_ENV"
54+
55+
FULL=$(php -r 'echo PHP_VERSION;')
56+
PACK="php-devel-pack-$FULL-nts-Win32-vs17-x64.zip"
57+
echo "devel pack: $PACK"
58+
curl -fsSLo devel-pack.zip "https://windows.php.net/downloads/releases/$PACK" \
59+
|| curl -fsSLo devel-pack.zip "https://windows.php.net/downloads/releases/archives/$PACK"
60+
unzip -q devel-pack.zip -d /c/php-devel
61+
62+
git clone -q https://github.com/php/php-sdk-binary-tools.git /c/php-sdk
63+
git -C /c/php-sdk checkout -q "$PHP_SDK_COMMIT"
64+
65+
- name: "Set up MSVC environment"
66+
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
67+
with:
68+
arch: x64
69+
70+
- name: "Build the extension"
71+
shell: cmd
72+
working-directory: turbo-ext
73+
run: |
74+
for /d %%d in (C:\php-devel\php-*-devel-*) do set DEVEL=%%d
75+
set PATH=%DEVEL%;C:\php-sdk\bin;C:\php-sdk\usr\bin;%PATH%
76+
call phpize.bat
77+
if errorlevel 1 exit /b 1
78+
call configure.bat --enable-phpstan-turbo
79+
if errorlevel 1 exit /b 1
80+
nmake
81+
82+
- name: "Verify the built extension reports the expected version"
83+
shell: bash
84+
run: |
85+
find turbo-ext -name "php_phpstan_turbo.dll" | head -3
86+
DLL=$(find turbo-ext -name "php_phpstan_turbo.dll" | head -1)
87+
[ -n "$DLL" ]
88+
TURBO_DLL=$(cygpath -w "$PWD/$DLL")
89+
echo "TURBO_DLL=$TURBO_DLL" >> "$GITHUB_ENV"
90+
REPORTED="$(php -d extension="$TURBO_DLL" -r 'echo phpversion("phpstan_turbo");')"
91+
EXPECTED="$(sed -n "s/.*EXPECTED_EXTENSION_VERSION = '\([^']*\)'.*/\1/p" src/Turbo/TurboExtensionEnabler.php)"
92+
echo "built extension reports: $REPORTED, enabler expects: $EXPECTED"
93+
[ "$REPORTED" = "$EXPECTED" ]
94+
95+
- uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v4.0.0
96+
97+
- name: "Smoke test (differential: native vs PHP implementations)"
98+
shell: bash
99+
run: php -d extension="$TURBO_DLL" turbo-ext/tests/smoke.php
100+
101+
- name: "Signature parity (reflect native classes against the PHP twins)"
102+
shell: bash
103+
run: php -d extension="$TURBO_DLL" turbo-ext/tests/signature-parity.php
104+
105+
- name: "Parser corpus (differential: native vs PHP ASTs must be byte-identical)"
106+
shell: bash
107+
run: php -d extension="$TURBO_DLL" -d memory_limit=4G turbo-ext/tests/parser-corpus.php

‎turbo-ext/config.w32‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// phpstan_turbo — Windows build (php-devel-pack: phpize && configure && nmake).
2+
// The extension version is baked from the PHPSTANTURBO_VERSION environment
3+
// variable at configure time (the CI workflow computes it the same way the
4+
// Makefile does); it defaults to "dev", which the enabler rejects.
5+
6+
ARG_ENABLE("phpstan-turbo", "phpstan turbo extension", "no");
7+
8+
if (PHP_PHPSTAN_TURBO != "no") {
9+
var version = WScript.CreateObject("WScript.Shell").Environment("PROCESS")("PHPSTANTURBO_VERSION");
10+
if (!version || version == "") {
11+
version = "dev";
12+
}
13+
14+
// /EHsc: the C++ standard library assumes unwinding; /bigobj: the
15+
// generated parser action files exceed the default section limit.
16+
// The version is passed as a bare token (main.cpp stringizes it) —
17+
// quote characters do not survive the configure-to-nmake pipeline.
18+
var flags = "/std:c++17 /EHsc /bigobj /DPHPSTANTURBO_VERSION_RAW=" + version;
19+
20+
EXTENSION("phpstan_turbo",
21+
"src/main.cpp src/support.cpp src/CombinationsHelper.cpp src/ConditionalExpressionHolder.cpp src/ExpressionTypeHolder.cpp src/NodeScanner.cpp src/NodeTraverser.cpp src/ScopeOps.cpp src/TrinaryLogic.cpp src/TypeCombinatorCache.cpp",
22+
true,
23+
flags);
24+
ADD_SOURCES(configure_module_dirname + "/src/parser",
25+
"ParserRunner.cpp ParserRunnerActions1.cpp ParserRunnerActions2.cpp ParserRunnerActions3.cpp ParserRunnerHelpers.cpp",
26+
"phpstan_turbo");
27+
}

‎turbo-ext/src/main.cpp‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,16 @@
1111
#include "support.h"
1212
#include "reg.h"
1313

14-
/* Baked by the Makefile from git (short SHA of the last commit touching the
15-
* watched set); "dev" outside a git checkout, which the enabler rejects. */
14+
/* Baked from git (short SHA of the last commit touching the watched set);
15+
* "dev" outside a git checkout, which the enabler rejects. The Makefile
16+
* passes the quoted string directly; config.w32 passes the bare token as
17+
* PHPSTANTURBO_VERSION_RAW — quote characters do not survive the Windows
18+
* configure-to-nmake pipeline — and it is stringized here. */
19+
#ifdef PHPSTANTURBO_VERSION_RAW
20+
#define PT_VERSION_STR2(x) #x
21+
#define PT_VERSION_STR(x) PT_VERSION_STR2(x)
22+
#define PHPSTANTURBO_VERSION PT_VERSION_STR(PHPSTANTURBO_VERSION_RAW)
23+
#endif
1624
#ifndef PHPSTANTURBO_VERSION
1725
#define PHPSTANTURBO_VERSION "dev"
1826
#endif

0 commit comments

Comments
 (0)