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

Using std.os.poll on windows causes undefined reference error #16122

Open
IntegratedQuantum opened this issue Jun 20, 2023 · 2 comments
Open
Labels
bug Observed behavior contradicts documented or intended behavior os-windows standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@IntegratedQuantum
Copy link
Contributor

IntegratedQuantum commented Jun 20, 2023

Zig Version

0.11.0-dev.3655+a2f54fce5

Steps to Reproduce and Observed Behavior

const std = @import("std");

pub fn main() !void {
	_ = try std.os.poll(undefined, undefined);
}

Output:

$ zig run test.zig -target x86_64-windows-gnu -lc -lws2_32
error: lld-link: undefined symbol: poll
    note: referenced by /home/mint/Downloads/zig/lib/std/os.zig:6518
    note:               /home/mint/.cache/zig/o/3527c68e3a1bc7e3e4fe3d635ecb99dc/test.exe.obj:(os.poll)

Expected Behavior

std.os should use ws2_32.WSAPoll instead of using the non-existant extern function std.c.poll

@IntegratedQuantum IntegratedQuantum added the bug Observed behavior contradicts documented or intended behavior label Jun 20, 2023
@iamtimmy
Copy link

iamtimmy commented Jun 21, 2023

I would highly recommend against this, as WSAPoll is bugged and will not be fixed.
see: https://curl.se/mail/lib-2012-10/0038.html

As far as I know rust uses (a variation of) the following as an alternative internally:
https://github.com/piscisaureus/wepoll

@rohlem
Copy link
Contributor

rohlem commented Jun 21, 2023

Related:
#5019 : std.os functions really provide a POSIX-ish layer so should be moved to std.posix. (not currently accepted)
#6600 : std.os shouldn't provide a POSIX-ish layer and instead be designed for all systems equally. (currently accepted)

My understanding of this:
Short-term it seems like std.os.poll is just not supported on Windows, and should be guarded by a @compileError stating this.
Long-term some mechanism like std.os.poll that supports Windows should be added,
however note that std is currently designed around the needs of Zig itself.
Therefore if Zig doesn't need such a mechanism on Windows, it might just not provide it there
(especially if it's not fully reliable as mentioned above).

@andrewrk andrewrk added standard library This issue involves writing Zig code for the standard library. os-windows labels Jul 23, 2023
@andrewrk andrewrk added this to the 0.11.1 milestone Jul 23, 2023
@andrewrk andrewrk modified the milestones: 0.11.1, 0.12.0, 0.13.0 Jan 29, 2024
@andrewrk andrewrk modified the milestones: 0.14.0, 0.16.0 Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior os-windows standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

No branches or pull requests

4 participants