ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
33.72k stars 2.48k forks source link

Darwin: kevent64_s not defined anymore #21200

Open steeve opened 2 weeks ago

steeve commented 2 weeks ago

Zig Version

0.14.0-dev.1304+7d54c62c8

Steps to Reproduce and Observed Behavior

Trying to update libxev to the latest zig, I'm running into a undefined decl for std.posix.system.kevent64_s at: https://github.com/mitchellh/libxev/blob/43c7e4b3308f359e5b758db2d824d7c447f4ed3f/src/backend/kqueue.zig#L1672-L1675

The breaking change happened in https://github.com/ziglang/zig/commit/e8c4e79499fbb2a83a0f4fe2cac0d80e5d12a07e

It seems it might just be as easy as importing darwin.kevent64_s to c.zig, in which case I'll send a PR.

Also cc @mitchellh for visibility.

Expected Behavior

Should be able to use std.posix.system.kevent64_s on macOS.

alexrp commented 2 weeks ago

It seems it might just be as easy as importing darwin.kevent64_s to c.zig, in which case I'll send a PR.

Seems that way; please do.

steeve commented 2 weeks ago

It seems other symbols are missing too such as MACH_SEND_MSG and MACH_RCV_MSG. Most coming from https://github.com/ziglang/zig/commit/8c4a2dc1dfe05a67eb9811b8c8291c5541816a99

Should I just go ahead and import them? I'm not sure this is the right solution as it makes me question why there is a darwin.zig in the first place?

Perhaps a solution is to expose const darwin as pub const ?

I'm not sure

alexrp commented 2 weeks ago

The idea is that a symbol should be available in std.c when it's available for the targeted OS/libc. If it's not available for the target, it should be defined to void (for types) or {} (for functions).

Please see: https://github.com/ziglang/zig/pull/20679

steeve commented 2 weeks ago

Super clear, thank you

steeve commented 2 weeks ago

First shot: https://github.com/ziglang/zig/pull/21218