Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use std.os.windows.poll for std.posix.poll implementation rather than libc dependency #20396

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

mochalins
Copy link
Contributor

std.posix.poll implementation incorrectly depends on libc on Windows, despite std.os.windows.poll existing. Issue similar to #9971, and resolved similar to #15225.

@andrewrk
Copy link
Member

andrewrk commented Jul 9, 2024

Thanks, looks good. How did you test it?

@mochalins
Copy link
Contributor Author

mochalins commented Jul 10, 2024

Thanks, looks good. How did you test it?

I sanity-checked by running standard library tests on Linux, then ran zig-network's test suite using wine, with adjustments to use the POSIX poll on Windows (using zig build --zig-lib-dir) instead of ws2's select.

Without the patch (compilation failure due to requiring libc):

zig build test -Dtarget=x86_64-windows-gnu -fwine
test
└─ run test
   └─ zig test Debug x86_64-windows-gnu 1 errors
/home/***/Software/Install/lib/zig/std/c.zig:1840:12: error: dependency on libc must be explicitly specified in the build command
pub extern "c" fn poll(fds: [*]c.pollfd, nfds: c.nfds_t, timeout: c_int) c_int;
           ^~~
referenced by:
    poll: /home/***/Software/Install/lib/zig/std/posix.zig:6484:26
    waitForSocketEvent: network.zig:989:85
    1 reference(s) hidden; use '-freference-trace=3' to see all references
error: the following command failed with 1 compilation errors:
/home/***/Software/Install/bin/zig test -ODebug -target x86_64-windows-gnu -mcpu baseline --dep network -Mroot=/home/***/Projects/zig-network/testsuite.zig -Mnetwork=/home/***/Projects/zig-network/network.zig --cache-dir /home/***/Projects/zig-network/.zig-cache --global-cache-dir /home/***/.cache/zig --name test --listen=- 
Build Summary: 0/3 steps succeeded; 1 failed (disable with --summary none)
test transitive failure
└─ run test transitive failure
   └─ zig test Debug x86_64-windows-gnu 1 errors
error: the following build command failed with exit code 1:
/home/***/Projects/zig-network/.zig-cache/o/f04f1741572aaa666b5ce6df87305999/build /home/***/Software/Install/bin/zig /home/***/Projects/zig-network /home/***/Projects/zig-network/.zig-cache /home/***/.cache/zig --seed 0xa7d02b6f -Z13f5919b3699ea29 test -Dtarget=x86_64-windows-gnu -fwine

With the patch (all tests pass):

zig build --zig-lib-dir ../zig/lib test -Dtarget=x86_64-windows-gnu -fwine
test
└─ run test stderr
002c:fixme:winediag:loader_init wine-staging 9.5 is a testing version containing experimental patches.
002c:fixme:winediag:loader_init Please mention your exact version when filing bug reports on winehq.org.
142.250.76.142:80
[2404:6800:400a:805::200e]:80
Echo: Hi from socket!
0118:fixme:winsock:WSAIoctl SIO_UDP_CONNRESET stub
0118:fixme:winsock:WSAIoctl SIO_UDP_CONNRESET stub
0118:fixme:winsock:WSAIoctl SIO_UDP_CONNRESET stub

The branch used for testing this patch is here: https://github.com/mochalins/zig-network/tree/windows_poll

@andrewrk andrewrk enabled auto-merge (rebase) July 10, 2024 04:10
@andrewrk andrewrk merged commit f58ee38 into ziglang:master Jul 10, 2024
10 checks passed
@mochalins mochalins deleted the windows_poll_wsa2 branch July 10, 2024 05:35
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.

2 participants