Skip to content

Fix compilation of pingora-core on 32-bit Windows - #1120

Open
lopatnov wants to merge 1 commit into
cloudflare:mainfrom
lopatnov:fix-windows-32bit-raw-socket
Open

lopatnov wants to merge 1 commit into
cloudflare:mainfrom
lopatnov:fix-windows-32bit-raw-socket

Conversation

@lopatnov

Copy link
Copy Markdown

Fixes #1119.

pingora-core does not compile for 32-bit Windows. listeners::l4::from_raw_fd passes fd as u64 to TcpStream::from_raw_socket, but std::os::windows::io::RawSocket is u32 when target_pointer_width = "32" and u64 when it is "64":

error[E0308]: mismatched types
   --> pingora-core\src\listeners\l4.rs:240:85
    |
240 |             let std_listener_socket = unsafe { std::net::TcpStream::from_raw_socket(fd as u64) };
    |                                                ------------------------------------ ^^^^^^^^^ expected `u32`, found `u64`

Change

Cast to the RawSocket alias instead of the concrete type (and import it). One line plus the use.

  • 64-bit Windows: RawSocket is u64, so fd as RawSocket is exactly the previous fd as u64. No behavior change.
  • 32-bit Windows: RawSocket is u32, so it compiles. The fd: i32 to socket conversion is otherwise untouched.
  • Every other platform: the line is under #[cfg(windows)], so it is not compiled.

Testing

On main (3f87e92), Windows 11, rustc 1.99.0:

cargo check -p pingora-core --target i686-pc-windows-msvc cargo check -p pingora-core (x86_64-pc-windows-msvc)
before fails: the error above, the only one passes
after passes passes
  • cargo fmt -p pingora-core -- --check is clean (the first version of the line was reformatted by rustfmt, as it is now).
  • cargo clippy -p pingora-core, for both targets, reports nothing at the changed lines.
  • Beyond the crate: a reverse proxy built on pingora-core 0.9.1 with this one-line change (Conduit) builds for i686-pc-windows-msvc with four feature sets and its test suite passes on that target (32-bit executables on a 64-bit Windows runner).
  • No test is added: the change only matters on a target the project's CI does not build (it runs Linux only), and a unit test of a type alias would not exercise it. If you would like a 32-bit Windows cargo check job for pingora-core in CI, I can add one in a follow-up.

🤖 Generated with Claude Code

`from_raw_fd` cast the descriptor to `u64` before `TcpStream::from_raw_socket`, but `RawSocket` is `u32` on
32-bit Windows (`u64` only where the pointer is 64 bits), so `pingora-core` failed to compile for
`i686-pc-windows-msvc` ("expected `u32`, found `u64`"). Cast to the `RawSocket` alias instead; on 64-bit
Windows it is the same `u64` as before, so nothing changes there.

Fixes cloudflare#1119

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
lopatnov added a commit to lopatnov/conduit that referenced this pull request Nov 11, 2026
…and in the npm package (#696, #671)

Five new platforms, each in the four builds (full: bare binary and archive without a suffix; standard, gateway,
static: archives): i686-unknown-linux-gnu, armv7-unknown-linux-gnueabihf, arm-unknown-linux-gnueabihf (ARMv6),
arm-unknown-linux-gnueabi (all four built with cross on the stock images) and aarch64-pc-windows-msvc (native, on
the windows-11-arm runner, zip like the x86-64 one). The probe builds of #696 compiled and linked all 20 builds
(runs 42972530836 and 42975317527) and `windows-11-arm` has been green in CI on every recent pull request, the
condition #671 set. The npm package maps `linux-ia32`, `linux-arm` (Node itself needs ARMv7 there, so the armv7
build) and `win32-arm64`; there are no musl builds for the 32-bit pair, so Alpine gets the "unsupported" message.

`scripts/test_release_matrix.py` expects every bundle on every one of the 13 platforms and each npm row to ask
for the right asset; the npm test fixture lists the new assets.

Not released: i686-pc-windows-msvc (pingora-core does not compile there until cloudflare/pingora#1120 is in a
release) and Android (Pingora does not support it).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

pingora-core does not compile on 32-bit Windows (i686-pc-windows-msvc): from_raw_socket(fd as u64)

1 participant