Skip to content

build(win): compile WebSocket on Windows - #303

Merged
EdmondDantes merged 1 commit into
mainfrom
win-websocket-build
Aug 25, 2026
Merged

EdmondDantes merged 1 commit into
mainfrom
win-websocket-build

Conversation

@EdmondDantes

Copy link
Copy Markdown
Contributor

config.w32 named core, http1, formats, log, room, static and llhttp, and never src/websocket or the bundled wslay. So TrueAsync\WebSocket did not exist in a Windows build and its entire phpt group failed — most of what WINDOWS_X64_ZTS_RELEASE has been reporting as red on main. Nothing platform-specific stood in the way; the recipe simply did not list the sources.

Three things the port needed, and each is a trap worth naming:

  • The wslay translation units include no PHP header. A macro that reaches ours through main/config.w32.h never arrives there, so HAVE_WSLAY and HAVE_HTTP_SERVER_WEBSOCKET are passed on the command line, exactly as fix(build): pass the compression feature macros to the Windows build #292 had to do for compression.
  • wslay.h types its callbacks with ssize_t, which MSVC does not have. php-src answers this with #define ssize_t SSIZE_T in main/config.w32.h — a header those units never see. SSIZE_T itself comes from BaseTsd.h, force-included because wslay.h includes only stdint.h, stdlib.h and sys/types.h.
  • The block sits below the include-path section on purpose. ADD_FLAG skips a flag that is a substring of one already added: with the wslay include path added first, the module root's own /I was dropped and every file reached through php_true_async_server.h stopped resolving.

CI needs no change — the Windows workflow does not pass --disable-all, so the new --enable-websocket (default yes, mirroring config.m4) applies on its own.

Evidence. On this Windows build the group goes from absent to 60 of 61 executed tests passing; the whole phpt tree reads 496 tests, 270 passed, 224 skipped, 2 failed.

One of those two is real and outside this change: websocket/035-recv-queue-overflow fails 2 runs of 3 here with client saw close: NULL, while the handler side reports 1013 correctly. Its client reads the socket into one buffer and looks for the CLOSE opcode at byte 0, so anything the server sends ahead of the close leaves it parsing a data frame's header forever. That is a framing assumption in the test, not a build problem, and it wants its own change.

The other failure is core/078-listener-port-zero, which belongs to #302 and is present in the working copy but not in this build.

`config.w32` listed core, http1, formats, log, room, static and llhttp,
and never `src/websocket` or the bundled wslay: the class did not exist
in a Windows build and its whole phpt group failed, which is most of
what `WINDOWS_X64_ZTS_RELEASE` reports as red on main. Nothing platform
specific was in the way — the recipe simply did not name the sources.

Three things the port needed. wslay's translation units include no PHP
header, so the macros this extension owns are passed on the command line
as the compression block already does. `wslay.h` types its callbacks
with `ssize_t`, which MSVC does not have and php-src answers with
`#define ssize_t SSIZE_T` in a header those units never see; SSIZE_T
comes from BaseTsd.h, force-included because wslay includes no Windows
header of its own. And the block sits below the include-path section
because ADD_FLAG skips a flag that is a substring of one already added:
the wslay include path added first swallowed the module root's own `/I`.

CI needs no change: it does not pass `--disable-all`, so the new
`--enable-websocket` takes its default.

Evidence: the group goes from absent to 60 of 61 executed tests passing
on Windows; the whole phpt tree reads 496 tests, 270 passed, 2 failed.
One is `websocket/035-recv-queue-overflow`, which fails 2 of 3 runs here
and is not a build problem: its client reads the stream expecting the
CLOSE frame first and misparses anything the server sends ahead of it.
The other is a test of an unrelated branch present in the working copy.
@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Total lines: 82.98% → 82.99% (+0.02 pp)

File Baseline Current Δ Touched
src/core/http_connection_tls.c 73.83% 73.55% -0.28 pp
src/http3/http3_callbacks.c 83.44% 84.18% +0.74 pp
src/websocket/ws_session.c 90.41% 90.04% -0.37 pp

@EdmondDantes
EdmondDantes merged commit 5557cd9 into main Aug 25, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant